// Package Created When clicked Save Button private void BtnSave_Click(object sender, EventArgs e) { string PackName = txtPackName.Text.Trim(); string PackQuantity = txtPackQuantity.Text.Trim(); string PackPrice = txtPackPrice.Text.Trim(); if (!string.IsNullOrEmpty(PackName) || !string.IsNullOrEmpty(PackQuantity) || !string.IsNullOrEmpty(PackPrice)) { if (ValidatePackage()) { Package package = new Package(); package.Name = uniMetods.FirstCharToUpper(PackName); package.EntryQuantity = byte.Parse(uniMetods.FirstCharToUpper(PackQuantity)); package.Price = double.Parse(uniMetods.FirstCharToUpper(PackPrice)); package.Status = true; _context.Packages.Add(package); _context.SaveChanges(); FillPackageList(); } } else { MessageBox.Show("Please, Fill all fields"); } }
// Customer Created When clicked Save Button private void BtnSave_Click(object sender, EventArgs e) { Fname = txtFname.Text.Trim(); Lname = txtLname.Text.Trim(); Bdate = txtBirthdate.Text.Trim(); Phone = txtPhone.Text.Trim(); Blnc = txtBalance.Text.Trim(); if (!string.IsNullOrEmpty(Fname) || !string.IsNullOrEmpty(Lname) || !string.IsNullOrEmpty(Bdate) || !string.IsNullOrEmpty(Phone) || !string.IsNullOrEmpty(Blnc)) { if (ValidatePayment()) { Customer customer = new Customer(); customer.Firstname = uniMetods.FirstCharToUpper(Fname); customer.Lastname = uniMetods.FirstCharToUpper(Lname); customer.Birthdate = DateTime.Parse(Bdate); customer.Phone = uniMetods.FirstCharToUpper(Phone); customer.Balance = double.Parse(Blnc); customer.Status = true; _context.Customers.Add(customer); _context.SaveChanges(); FillCustomerList(); } } else { MessageBox.Show("Please, Fill all fields"); } }
// Product Created When clicked Save Button private void BtnSave_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtName.Text.Trim()) || !string.IsNullOrEmpty(txtPrice.Text.Trim())) { if (ValidateProduct()) { MenuItem menuItem = new MenuItem(); string TxtName = txtName.Text.Trim(); string TxtPrice = txtPrice.Text.Trim(); menuItem.Name = uniMetods.FirstCharToUpper(TxtName); double Price = double.Parse(TxtPrice); menuItem.Price = Price; menuItem.Status = true; _context.MenuItems.Add(menuItem); _context.SaveChanges(); FillProductList(); } } else { MessageBox.Show("Please, Fill all fields"); } }