Exemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            model.Name     = txt1.Text.Trim();
            model.INN      = txt2.Text.Trim();
            model.City     = txt3.Text.Trim();
            model.Street   = txt4.Text.Trim();
            model.DomAndKV = txt5.Text.Trim();
            model.Status   = txt6.Text.Trim();
            using (КудашкинEntities1 db = new КудашкинEntities1())
            {
                if (model.IdSuppler == 0)//Insert
                {
                    db.Supplier.Add(model);
                }
                else //Update
                {
                    db.Entry(model).State = EntityState.Modified;
                }
                db.SaveChanges();
            }

            Clear();
            PopulateDataGridView();
            MessageBox.Show("Submitted Successfully");
        }
Exemplo n.º 2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are You Sure to Delete this Record ?", "EF CRUD Operation", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         using (КудашкинEntities1 db = new КудашкинEntities1())
         {
             var entry = db.Entry(model);
             if (entry.State == EntityState.Detached)
             {
                 db.DannyS.Attach(model);
             }
             db.DannyS.Remove(model);
             db.SaveChanges();
             PopulateDataGridView();
             Clear();
             MessageBox.Show("Deleted Successfully");
         }
     }
 }
Exemplo n.º 3
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     model.Article = txtArt.Text.Trim();
     model.Name    = txtName.Text.Trim();
     model.Remove  = txtRemove.Text.Trim();
     using (КудашкинEntities1 db = new КудашкинEntities1())
     {
         if (model.IdGoods == 0)//Insert
         {
             db.IdProdukts.Add(model);
         }
         else //Update
         {
             db.Entry(model).State = EntityState.Modified;
         }
         db.SaveChanges();
     }
     Clear();
     PopulateDataGridView();
     MessageBox.Show("Submitted Successfully");
 }
Exemplo n.º 4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     model.IdContract = int.Parse(txt1.Text.Trim());
     model.IdGoods    = int.Parse(txt2.Text.Trim());
     model.Price      = txt3.Text.Trim();
     model.Count      = txt4.Text.Trim();
     model.Status     = txt5.Text.Trim();
     using (КудашкинEntities1 db = new КудашкинEntities1())
     {
         if (model.IdContract == 0)//Insert
         {
             db.DannyS.Add(model);
         }
         else //Update
         {
             db.Entry(model).State = EntityState.Modified;
         }
         db.SaveChanges();
     }
     Clear();
     PopulateDataGridView();
     MessageBox.Show("Submitted Successfully");
 }