private void Duzenle_Load(object sender, EventArgs e) { YeniKayit ynk = new YeniKayit(); textBox1.Text = ynk.dataGridView1.CurrentRow.Cells[1].Value.ToString(); textBox2.Text = ynk.dataGridView1.CurrentRow.Cells[2].Value.ToString(); textBox3.Text = ynk.dataGridView1.CurrentRow.Cells[3].Value.ToString(); comboBox4.Text = ynk.dataGridView1.CurrentRow.Cells[5].Value.ToString(); textBox8.Text = ynk.dataGridView1.CurrentRow.Cells[6].Value.ToString(); textBox12.Text = ynk.dataGridView1.CurrentRow.Cells[7].Value.ToString(); comboBox1.Text = ynk.dataGridView1.CurrentRow.Cells[8].Value.ToString(); comboBox2.Text = ynk.dataGridView1.CurrentRow.Cells[9].Value.ToString(); }
private void button2_Click(object sender, EventArgs e) { if (textBox1.Text.Trim() != "" && textBox2.Text.Trim() != "" && textBox3.Text.Trim() != "") { con.Open(); komut.Connection = con; komut.CommandText = "Update Yenikayit Set Ad='" + textBox2.Text + "',Soyad='" + textBox3.Text + "',DogumYeri='" + comboBox4.Text + "',BabaAdi='" + textBox8.Text + "',AnneAdi='" + textBox12.Text + "',Cinsiyet='" + comboBox1.Text + "',EgitimDurum='" + comboBox2.Text + "' where KimlikNo='" + textBox1.Text + "'"; komut.ExecuteNonQuery(); con.Close(); YeniKayit ynk = new YeniKayit(); ynk.listele(); Temizle(); MessageBox.Show("Güncelleme İşlemi Gerçekleşti..."); this.Close(); } else { MessageBox.Show("Boş alan bırakmayınız"); } }
void baglantim() { string kadi = txtKadi.Text; string sifre = txtSifre.Text; if (rdbYonetici.Checked == true) { if (txtKadi.Text == "" && txtSifre.Text == "" && rdbDoktor.Checked == false && rdbYonetici.Checked == false) { MessageBox.Show("Kullanıcı Adı,Şifre veya Mesleği Seçiniz..."); } try { if (kadi != "" && sifre != "") { SqlConnection baglanti = new SqlConnection(); baglanti.ConnectionString = " Data Source=.;Initial Catalog=HuzurEviOtomasyonu;Integrated Security=True"; SqlCommand sorgu = new SqlCommand("SELECT KullaniciAdi,Sifre FROM KullaniciGiris", baglanti); SqlDataReader okuyucu; bool onay = false; try { baglanti.Open(); okuyucu = sorgu.ExecuteReader(); while (okuyucu.Read()) { if ((kadi == okuyucu["KullaniciAdi"].ToString()) && (sifre == okuyucu["Sifre"].ToString())) { onay = true; break;// veri tabanıyla doğru ise kullanıcı girişi yap } } baglanti.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (onay == true) { kullanici = kadi; YeniKayit ynk = new YeniKayit(); ynk.Show(); ynk.label21.Text = kullanici; this.Hide(); } else { baglanti.Close(); MessageBox.Show("Kullanıcı Adı,Şifreyi veya Mesleği Yanlış Girdiniz", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtKadi.Text = ""; txtSifre.Text = ""; } } } catch (Exception exp) { MessageBox.Show(exp.ToString()); } } if (rdbYonetici.Checked == false) { if (txtKadi.Text == "" && txtSifre.Text == "") { MessageBox.Show("Kullanıcı Adı veya Şifre Boş Girilemez..."); } try { if (kadi != "" && sifre != "") { SqlConnection baglanti = new SqlConnection(); baglanti.ConnectionString = " Data Source=.;Initial Catalog=HuzurEviOtomasyonu;Integrated Security=True"; SqlCommand sorgu = new SqlCommand("SELECT KullaniciAdi,Sifre FROM Doktor", baglanti); SqlDataReader okuyucu; bool onay = false; try { baglanti.Open(); okuyucu = sorgu.ExecuteReader(); while (okuyucu.Read()) { if ((kadi == okuyucu["KullaniciAdi"].ToString()) && (sifre == okuyucu["Sifre"].ToString())) { onay = true; break;// veri tabanıyla doğru ise kullanıcı girişi yap } } baglanti.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (onay == true) { kullanici = kadi; Doktor d1 = new Doktor(); d1.Show(); d1.label22.Text = kullanici; this.Hide(); } else { baglanti.Close(); MessageBox.Show("Kullanıcı Adı ve Şifreyi Yanlış Girdiniz", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtKadi.Text = ""; txtSifre.Text = ""; } } } catch (Exception exp) { MessageBox.Show(exp.ToString()); } } }