private void SaveButton_Click(object sender, EventArgs e) { CustomerInfo customerInfo = new CustomerInfo(); customerInfo.CustomerID = this.customerID; customerInfo.Name = CustomerNameTextBox.Text; customerInfo.Mobile = CustomerMobileTextBox.Text; customerInfo.Address = CustomerAddressTextBox.Text; if (IsValid()) { if (this.IsUpdate) { using (MyPOSContext db = new MyPOSContext()) { db.Entry(customerInfo).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); MessageBox.Show("Customer detail is updated succesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearControls(); } } else { using (MyPOSContext db = new MyPOSContext()) { db.CustomerInfoes.Add(customerInfo); db.SaveChanges(); MessageBox.Show("Customer detail is saved succesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearControls(); } } } }
public void SalvarModificacoes(List <TEntity> objEntity) { using (MyPOSContext context = new MyPOSContext()) { objEntity.ForEach(e => context.Entry(e).State = EntityState.Modified); context.SaveChanges(); } }
public void SalvarModificacoes(TEntity objEntity) { using (MyPOSContext context = new MyPOSContext()) { context.Entry(objEntity).State = EntityState.Modified; context.SaveChanges(); } }
public void RemoverItem(TEntity objEntity) { using (MyPOSContext context = new MyPOSContext()) { context.Entry(objEntity).State = EntityState.Deleted; context.SaveChanges(); } }
public void InserirNovo(TEntity objEntity) { using (MyPOSContext context = new MyPOSContext()) { context.Set <TEntity>().Add(objEntity); context.Entry(objEntity).State = EntityState.Added; context.SaveChanges(); } }
public void InsertOrUpdate(TEntity objEntity) { using (MyPOSContext context = new MyPOSContext()) { var obj = Obter(objEntity); if (obj is null) { context.Entry(objEntity).State = EntityState.Added; } else { context.Entry(obj).State = EntityState.Modified; } context.SaveChanges(); } }