private void BtnKaydet_Click(object sender, EventArgs e) { try { if (comboBoxSofor.Enabled == true) { int id = int.Parse(comboBoxSofor.SelectedValue.ToString()); var sofor = db.Sofor.Find(id); sofor.SoforAdSoyad = textBoxSoforAdSoyad.Text + " " + textBoxSoyad.Text; sofor.SoforAd = textBoxSoforAdSoyad.Text; sofor.SoforSoyad = textBoxSoyad.Text; sofor.SoforTC = textBoxTCNo.Text; sofor.SoforTelefon = textBoxTelefon.Text; sofor.Arsiv = false; db.Entry(sofor).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); Global.sonsofor = sofor; } else { var sofor = new Sofor(); sofor.SoforAdSoyad = textBoxSoforAdSoyad.Text + " " + textBoxSoyad.Text; sofor.SoforAd = textBoxSoforAdSoyad.Text; sofor.SoforSoyad = textBoxSoyad.Text; sofor.SoforTC = textBoxTCNo.Text; sofor.SoforTelefon = textBoxTelefon.Text; sofor.Arsiv = false; db.Sofor.Add(sofor); db.SaveChanges(); Global.sonsofor = sofor; } mesaj.Mesaj("İşlem Başarılı", FontAwesome.Sharp.IconChar.Check, System.Drawing.Color.DarkGreen); } catch (Exception ex) { mesaj.Mesaj(ex.Message, FontAwesome.Sharp.IconChar.Times, System.Drawing.Color.DarkRed); } FormTemizle(); }
public void FormDoldur(Sofor sofor) { textBoxSoforAdSoyad.Text = sofor.SoforAdSoyad; textBoxTelefon.Text = sofor.SoforTelefon; textBoxTCNo.Text = sofor.SoforTC; }