private void btnSaveChangesProduct_Click(object sender, RoutedEventArgs e) { try { using (InventoryDBEntitiesFK ctx = new InventoryDBEntitiesFK()) { Product p = ctx.Products.Find(Convert.ToInt32(lblProductIdEdit.Content)); p.ProductName = tbProductNameEdit.Text; p.Category = tbCategoryEdit.Text; p.Description = tbDescriptionEdit.Text; p.Price = Convert.ToDecimal(this.tbPriceEdit.Text); p.SCU = Convert.ToInt32(this.tbSCUEdit.Text); p.Quantity = Convert.ToInt32(this.tbQuantityEdit.Text); p.Location = tbLocationEdit.Text; p.SupplierName = tbSupplierEdit.Text; ctx.SaveChanges(); this.Close(); man.refreshProductsList(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnDeleteUser_Click(object sender, RoutedEventArgs e) { try { using (InventoryDBEntitiesFK ctx = new InventoryDBEntitiesFK()) { User selected = (User)lvUsersList.SelectedItem; User u = ctx.Users.Find(Convert.ToInt32(selected.EmployeeId)); ctx.Users.Remove(u); ctx.SaveChanges(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } refreshUsersList(); }
private void btnSaveChanges_Click(object sender, RoutedEventArgs e) { try { using (InventoryDBEntitiesFK ctx = new InventoryDBEntitiesFK()) { User u = ctx.Users.Find(Convert.ToInt32(lblUserId.Content)); u.EmployeeName = tbUserNameInModify.Text; u.Password = tbPasswordInmodify.Text; u.Role = comboBoxRoleInModify.Text; ctx.SaveChanges(); MessageBox.Show("Cogradulations!!! Record has been modified"); // win.refreshUsersList(); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ModifyUser() { InitializeComponent(); db = new InventoryDBEntitiesFK(); }
public AddProduct() { InitializeComponent(); db = new InventoryDBEntitiesFK(); }