Exemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox2.Text == string.Empty)
     {
         textBox2.Focus(); return;
     }
     if (textBox3.Text == string.Empty)
     {
         textBox3.Focus(); return;
     }
     models.Togarrr tg = new Togarrr()
     {
         name    = textBox2.Text,
         phone   = textBox3.Text,
         type_id = Int32.Parse(metroComboBox1.SelectedValue.ToString())
     };
     if (button1.Text == "اضافة")
     {
         crd.togaar(tg, System.Data.Entity.EntityState.Added);
         MessageBox.Show("تم الاضافة بنجاح");
     }
     else
     {
         tg.id = int.Parse(textBox1.Text);
         crd.togaar(tg, System.Data.Entity.EntityState.Modified);
         MessageBox.Show("تم التعديل بنجاح");
     }
     Close();
 }
Exemplo n.º 2
0
 public void togaar(Togarrr ms, EntityState n)
 {
     db.Entry(ms).State = n;
     db.SaveChanges();
 }