-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form5.cs
88 lines (77 loc) · 4.18 KB
/
Form5.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication1
{
public partial class Form5 : Form
{
public static string baglantiYolu = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\hhk19\Google Drive\hospitalmanagementProject\WindowsFormsApplication1\WindowsFormsApplication1\Torun.mdf;Integrated Security = True";
int id;
string pass;
public Form5(int r1,string r2)
{
InitializeComponent();
id = r1;
pass = r2;
bilgilericek();
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection baglanti = new SqlConnection(baglantiYolu);
baglanti.Open();
//SqlCommand komut = new SqlCommand("update PatientLogin set Id='" + Convert.ToInt32(textBox1.Text) + "',Name='" + textBox2.Text + "' ,Surname='" + textBox4.Text + "' ,Sex='" + comboBox1.SelectedItem.ToString() + "' ,Address='" + richTextBox1.Text + "' ,Email='" +textBox3.Text+ "' ,PhoneNumber='" + textBox5.Text + "' ,DateofBirth='" + dateTimePicker1.Value.Date + "' ,Password='"+textBox6.Text+"' where Id='" + id + "'and Password='"+pass+"'", baglanti);
SqlCommand komut = new SqlCommand("update PatientLogin set Id=@Id,Name=@name,Surname=@surname,Sex=@sex,Address=@Address,Email=@Email,PhoneNumber=@PhoneNumber,DateofBirth=@dateofbirth,Password=@password where Id=@id1 and Password=@pass1");
komut.Connection = baglanti;
komut.Parameters.AddWithValue("@Id", Convert.ToInt32(textBox1.Text));
komut.Parameters.AddWithValue("@name", textBox2.Text);
komut.Parameters.AddWithValue("@surname", textBox4.Text);
komut.Parameters.AddWithValue("@sex", comboBox1.SelectedItem.ToString());
komut.Parameters.AddWithValue("@Address", richTextBox1.Text);
komut.Parameters.AddWithValue("@Email", textBox3.Text);
komut.Parameters.AddWithValue("@PhoneNumber", textBox5.Text);
komut.Parameters.AddWithValue("@dateofbirth", dateTimePicker1.Value.Date);
komut.Parameters.AddWithValue("@password", textBox6.Text);
komut.Parameters.AddWithValue("@id1",id);
komut.Parameters.AddWithValue("@pass1",pass);
komut.ExecuteNonQuery();
MessageBox.Show("Updated!");
baglanti.Close();
// temizle();
}
public void temizle() {
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
textBox6.Clear();
}
public void bilgilericek() {
SqlConnection baglanti = new SqlConnection(baglantiYolu);
baglanti.Open();
SqlCommand komut = new SqlCommand("Select * from PatientLogin where Id=" + id + "and Password="+pass);
komut.Connection = baglanti;
SqlDataAdapter adaptor = new SqlDataAdapter();
adaptor.SelectCommand = komut;
DataSet sonuc = new DataSet();
adaptor.Fill(sonuc);
baglanti.Close();
textBox1.Text = Convert.ToString(sonuc.Tables[0].Rows[0]["Id"]);
textBox2.Text = Convert.ToString(sonuc.Tables[0].Rows[0]["Name"]);
textBox4.Text = Convert.ToString(sonuc.Tables[0].Rows[0]["Surname"]);
textBox6.Text = Convert.ToString(sonuc.Tables[0].Rows[0]["Password"]);
comboBox1.SelectedIndex = comboBox1.FindString(Convert.ToString(sonuc.Tables[0].Rows[0]["Sex"]));
richTextBox1.Text = Convert.ToString(sonuc.Tables[0].Rows[0]["Address"]);
textBox3.Text = Convert.ToString(sonuc.Tables[0].Rows[0]["Email"]);
textBox5.Text = Convert.ToString(sonuc.Tables[0].Rows[0]["PhoneNumber"]);
dateTimePicker1.Value = Convert.ToDateTime(sonuc.Tables[0].Rows[0]["DateOfBirth"]);
}
}
}