private void button1_Click(object sender, EventArgs e) { string phrase = txtStockQuantity.Text; double number; bool isNumeric = double.TryParse(phrase, out number); if (isNumeric == true) { if ((phrase.Length < 9) && Convert.ToInt32(txtStockQuantity.Text) > 0) { int id = Globals.MStockpassing; Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id); itemEdited.Stock_Item_Quantity = itemEdited.Stock_Item_Quantity + Convert.ToInt32(txtStockQuantity.Text); db.SaveChanges(); MessageBox.Show("Stock item checked out successfully,quantity: +" + txtStockQuantity.Text); Globals.refresher = true; this.Close(); } else { MessageBox.Show("Error:Quantity less than 1 or too large"); } } else { MessageBox.Show("Error: Value entered is not in correct format(not numeric)"); } }
private void empBtn_Click_1(object sender, EventArgs e) { try { header.Text = "Employee"; //EmployeePan.Visible = false; CustomerPan.Visible = false; SalesPan.Visible = false; MenuPan.Visible = false; ComboPan.Visible = false; StockPan.Visible = false; EmployeePan.Visible = true; EmployeePan.BringToFront(); if (navButton != empBtn) { navigate(empBtn); } var customers = from p in db.Employees select new { ID = p.Employee_ID, NAME = p.Employee_Name, SURNAME = p.Employee_Surname, IDENTITY = p.Employee_Identity_Number, ADRESS = p.Adress, EMAIL = p.Email_Adress, CONTACTNO = p.Contact_Number, NEXTOFKINNAME = p.Next_Of_Kin_Name, NEXTOFKINNUMBER = p.Next_Of_Kin_Contact_Number, GENDERID = p.Gender_ID, USERID = p.User_ID }; dgvEmployee.DataSource = customers.ToList(); db.SaveChanges(); ; dgvEmployee.MouseClick += new MouseEventHandler(employeeClick); } catch { } }
private void btnCheckIn_Click(object sender, EventArgs e) { string phrase = txtStockQuantity.Text; double number; bool isNumeric = double.TryParse(phrase, out number); if (isNumeric == true) { int id = Globals.MStockpassing; Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id); Check_In checkitem = new Check_In(); Check_In_Line checkitemline = new Check_In_Line(); if ((phrase.Length < 9) && (Convert.ToInt32(txtStockQuantity.Text) <= itemEdited.Stock_Item_Quantity) && (Convert.ToInt32(txtStockQuantity.Text) > 0)) { itemEdited.Stock_Item_Quantity = itemEdited.Stock_Item_Quantity - Convert.ToInt32(txtStockQuantity.Text); checkitem.Stock_Item_Name = itemEdited.Stock_Item_Name; checkitem.Check_In_Date = DateTime.Today; checkitemline.Check_In_ID = checkitem.Check_In_ID; checkitemline.Stock_ID = itemEdited.Stock_ID; checkitemline.Quantity = Convert.ToInt32(txtStockQuantity.Text); checkitemline.Stock_Item_Name = itemEdited.Stock_Item_Name; db.Check_In_Line.Add(checkitemline); db.Check_In.Add(checkitem); db.SaveChanges(); int id2 = Globals.LogedUser; Employee emp = db.Employees.FirstOrDefault(c => c.Employee_ID == id2); Audit ad = new Audit(); ad.Audit_Name = emp.Employee_Name; ad.Audit_Table = "Stock_Item"; ad.Audit_Description = "Item_CheckIn"; ad.User_ID = Globals.LogedUser; ad.transactionNumber = checkitem.Check_In_ID; ad.auditDate = DateTime.Now; db.Audits.Add(ad); db.SaveChanges(); MessageBox.Show("Stock item checked in successfully,quantity: -" + txtStockQuantity.Text); Globals.refresher = true; this.Close(); } else { MessageBox.Show("Error:Quantity exceeds stock items available/Quantity less than 1 or too large"); } } else { MessageBox.Show("Error: Value entered is not in correct format(not numeric)"); } }
public void load() { var orderList = from p in db.Stock_Order.Where(x => x.Stock_Order_Status_ID == 1) join q in db.Stock_Order_Line on p.Stock_Order_ID equals q.Stock_Order_ID join x in db.Stock_Order_Status on p.Stock_Order_Status_ID equals x.Stock_Order_Status_ID join y in db.Suppliers on p.Supplier_ID equals y.Supplier_ID select new { Order_No = p.Stock_Order_ID, Stock_Item = q.Stock_Item.Stock_Item_Name, Supplier_Name = y.Supplier_Name, Quantity = q.Stock_Order_Quantity, Order_Date = p.Stock_Order_Issue_Date, Order_Status = x.Stock_Order_Status_Description, }; dgvPlacedOrder.DataSource = orderList.ToList(); dgvPlacedOrder.ClearSelection(); db.SaveChanges(); var orderL = from p in db.Stock_Order.Where(x => x.Stock_Order_Status_ID == 2) join q in db.Stock_Order_Line on p.Stock_Order_ID equals q.Stock_Order_Line_ID join x in db.Stock_Order_Status on p.Stock_Order_Status_ID equals x.Stock_Order_Status_ID join y in db.Suppliers on p.Supplier_ID equals y.Supplier_ID select new { Order_No = p.Stock_Order_ID, Stock_Item = q.Stock_Item.Stock_Item_Name, Supplier_Name = y.Supplier_Name, QuantityReceived = q.Stock_Order_Quantity, Order_Date = p.Stock_Order_Issue_Date, // Date_Received = p.DateReceived ?? DateTime.Now, }; dgvReceivedOrder.DataSource = orderL.ToList(); dgvReceivedOrder.ClearSelection(); db.SaveChanges(); }
private void button2_Click(object sender, EventArgs e) { // saveFileDialog1.InitialDirectory = @"C:\Users\phindulo\Pictures"; //if(saveFileDialog1.ShowDialog() == DialogResult.OK) //{ // pictureBox1.Image.Save(saveFileDialog1.FileName); try { ItemsPicture itempic = new ItemsPicture(); { itempic.ItemName = Globals.emNameImage; itempic.imageVar = Globals.ConvertImageToBinary(pictureBox1.Image); itempic.ImageID = Globals.imageIdEmployee; itempic.EmployeeID = Globals.imageIdEmployee; db.ItemsPictures.Add(itempic); db.SaveChanges(); Globals.imageIdEmployee = 0; Globals.emNameImage = ""; Globals.refresher = true; this.Close(); } } catch (Exception i) { MessageBox.Show(i.ToString()); } // } }
private void Stock_ItemList_Load(object sender, EventArgs e) { var stockList = from p in db.Stock_Item join q in db.Stock_Price on p.Stock_ID equals q.Stock_Price_ID //join r in db.Stock_Type // on p.Stock_ID equals r.Stock_Type_ID select new { StockId = p.Stock_ID, StockItemName = p.Stock_Item_Name, AvailableQuantity = p.Stock_Item_Quantity, StockDescription = p.Stock_Item_Description, //StockType = r.Stock_Type_Description, StockPrice = q.Stock_Price1, }; dgvListStock.DataSource = stockList.ToList(); dgvListStock.ClearSelection(); db.SaveChanges(); //MessageBox.Show("hahahahaha"); dgvListStock.MouseClick += new MouseEventHandler(mouse_click); }
private void button7_Click(object sender, EventArgs e) { string phrase = txtMenuPrice.Text; int number; bool isNumeric = int.TryParse(phrase, out number); if (isNumeric == true) { int id = Globals.MenuCombopassing; Menu_Item item = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == id); Menu_Item_Type type = db.Menu_Item_Type.FirstOrDefault(c => c.Menu_Item_Description == cmbMenuItemType.Text); Menu_Item_Price price = db.Menu_Item_Price.FirstOrDefault(c => c.Menu_Price_ID == id); price.Menu_Price = Convert.ToDouble(txtMenuPrice.Text); // db.Menu_Item_Price.Add(price); item.Menu_Item_Name = txtMenuItemName.Text; item.Menu_Item_Description = richDescription.Text; item.Menu_Item_Type_ID = type.Menu_Item_Type_ID; item.Menu_Item_Price = price.Menu_Price; item.Menu_Price_ID = price.Menu_Price_ID; //item.fileName =fileName = ConvertImageToBinary(pictureBox1.Image); // db.Menu_Item.Add(item); //item = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_Name == txtMenuItemName.Text); ItemsPicture itempic = db.ItemsPictures.FirstOrDefault(c => c.Menu_Item_ID == id); { if ((Globals.browse == true) && (itempic != null)) { itempic.ItemName = Globals.fileName; itempic.imageVar = Globals.ConvertImageToBinary(pictureBox1.Image); // itempic.ImageID = item.Combo_ID; // Globals.browse = false; } } //itempic.ImageID = item.Menu_Item_ID; // itempic.Menu_Item_ID = item.Menu_Item_ID; //db.ItemsPictures.Add(itempic); db.SaveChanges(); Globals.refresher = true; MessageBox.Show("Menu item updated successfully"); this.Close(); } else { MessageBox.Show("Error: Values entered is not in correct format(not numeric)"); } }
private void btnSubmit_Click(object sender, EventArgs e) { //if (txtOrderQuantity.Text == "" && txtSelectStock.Text == "" && txtSelectSupplier.Text == "") //{ // btnSubmit.Enabled = false; //} //else // btnSubmit.Enabled = true; Stock_Order sOrder = new Stock_Order(); // orderLine.Q = orderLine.Stock_Order_Quantity; sOrder.Stock_Order_Description = "Description"; sOrder.Stock_Order_Issue_Date = DateTime.Now; sOrder.Stock_Order_Status_ID = 1; sOrder.Supplier_ID = supplierID; db.Stock_Order.Add(sOrder); db.SaveChanges(); foreach (var item in Globals.StockOrders) { Stock_Order_Line orderLine = new Stock_Order_Line(); orderLine.Stock_ID = item.OrderNo; orderLine.Stock_Order_Quantity = item.sOrderQuantity; orderLine.Stock_Order_ID = sOrder.Stock_Order_ID; // sOrder.Stock_Order_ID = item.OrderNo; db.Stock_Order_Line.Add(orderLine); db.SaveChanges(); // parent.load(); //} //SendEmail(); //// parent.loadReceivedOrder(); //MessageBox.Show("New Order Placed"); } }
private /*async*/ void button7_Click(object sender, EventArgs e) { string phrase = txtMenuPrice.Text; int number; bool isNumeric = int.TryParse(phrase, out number); if (isNumeric == true) { Menu_Item item = new Menu_Item(); Menu_Item_Type type = db.Menu_Item_Type.FirstOrDefault(c => c.Menu_Item_Description == cmbMenuItemType.Text); Menu_Item_Price price = new Menu_Item_Price(); price.Menu_Price = Convert.ToDouble(txtMenuPrice.Text); db.Menu_Item_Price.Add(price); item.Menu_Item_Name = txtMenuItemName.Text; item.Menu_Item_Description = richDescription.Text; item.Menu_Item_Type_ID = type.Menu_Item_Type_ID; item.Menu_Item_Price = price.Menu_Price; item.Menu_Price_ID = price.Menu_Price_ID; //item.fileName =fileName = ConvertImageToBinary(pictureBox1.Image); db.Menu_Item.Add(item); //item = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_Name == txtMenuItemName.Text); ItemsPicture itempic = new ItemsPicture(); { itempic.ItemName = item.Menu_Item_Name; itempic.imageVar = Globals.ConvertImageToBinary(pictureBox1.Image); itempic.ImageID = item.Menu_Item_ID; itempic.Menu_Item_ID = item.Menu_Item_ID; db.ItemsPictures.Add(itempic); //db.SaveChanges(); } db.SaveChanges(); Globals.refresher = true; MessageBox.Show("Menu item added successfully"); txtMenuItemName.Text = ""; txtMenuPrice.Text = ""; richDescription.Text = ""; pictureBox1.Image = null; } else { MessageBox.Show("Error: Values entered is not in correct format(not numeric)"); } }
private void button1_Click(object sender, EventArgs e) { string phrase = txtCostPrice.Text; double number; bool isNumeric = double.TryParse(phrase, out number); if ((phrase.Length < 9) && isNumeric == true) { int id = Globals.MStockpassing; Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id); Stock_Price priceEdit = db.Stock_Price.FirstOrDefault(c => c.Stock_Price_ID == id); itemEdited.Stock_Item_Name = txtStockItemNameMaint.Text; itemEdited.Stock_Item_Description = txtStockItemDescriptionMaint.Text; priceEdit.Stock_Price1 = Convert.ToDouble(txtCostPrice.Text); if (cmbSTypeMaint.Text == "Ingredient") { Stock_Type idTracker = db.Stock_Type.FirstOrDefault(c => c.Stock_Type_Description == "Ingredient"); itemEdited.Stock_Type_ID = idTracker.Stock_Type_ID; } else if (cmbSTypeMaint.Text == "Product") { Stock_Type idTracker = db.Stock_Type.FirstOrDefault(c => c.Stock_Type_Description == "Product"); itemEdited.Stock_Type_ID = idTracker.Stock_Type_ID; } db.SaveChanges(); MessageBox.Show("Stock item updated successfully"); Globals.refresher = true; this.Close(); } else { MessageBox.Show("Error: Price value entered is not in correct format or value too large"); } }
private void button1_Click(object sender, EventArgs e) { try { User_Role role = new User_Role(); role.User_Role_Description = txtdes.Text; role.Access_Level_ID = Convert.ToInt32(cmbAccess.Text); db.User_Role.Add(role); db.SaveChanges(); MessageBox.Show("Role added successfully"); } catch (Exception i) { MessageBox.Show(i.ToString()); } }
private void button7_Click_1(object sender, EventArgs e) { Customer cust = new Customer(); if (ValidateChildren(ValidationConstraints.Enabled)) { try { //City city = db.Cities.FirstOrDefault(c => c.City_Name == txtCity.Text); Suburb suburb = db.Suburbs.FirstOrDefault(c => c.Suburb_Name == txtSurburb.Text); cust.Customer_Name = txtCustomerNames.Text; cust.Customer_Surname = txtCustomerSurname.Text; if ((suburb != null)) { // cust.City_ID = city.City_ID; cust.Suburb_ID = suburb.Suburb_ID; } else { MessageBox.Show("Error:City or Suburb not found"); return; } cust.Customer_Address = txtProvimce.Text + " " + "\n " + suburb.Suburb_Name + " " + txtStreeName.Text; cust.Customer_Contact_Number = Convert.ToInt32(txtContactNo.Text); db.Customers.Add(cust); db.SaveChanges(); Globals.addCustomer = true; Globals.custId = cust.Customer_ID; Globals.refresher = true; MessageBox.Show("New customer added successfully"); } catch (Exception i) { MessageBox.Show(Convert.ToString(i)); } } }
private void button1_Click(object sender, EventArgs e) { string phrase = txtMaxPeople.Text; double number; bool isNumeric = double.TryParse(phrase, out number); if ((phrase.Length < 11) && (isNumeric == true)) { if (Convert.ToInt32(txtMaxPeople.Text) > -1) { try { Employee_Shifts shift = new Employee_Shifts(); shift.Employee_Shift_Start_Time = dtStartTime.Text; shift.Employee_Shift_End_Time = dtEndTime.Text; shift.MaximumCashiers = Convert.ToInt32(txtMaxPeople.Text); shift.MaximumCooks = Convert.ToInt32(txtCashiers.Text); db.Employee_Shifts.Add(shift); db.SaveChanges(); MessageBox.Show("Shift created successfully"); } catch (Exception i) { MessageBox.Show(i.ToString()); } } else { MessageBox.Show("Error:Value invalid"); } } else { MessageBox.Show("Error:value not numeric,enter a numeric value"); } }
public void ListSupplier() { var customers = from p in db.Suppliers join q in db.Addresses on p.Supplier_ID equals q.Supplier_ID join y in db.Supplier_Contact_Details on p.Supplier_ID equals y.Supplier_ID select new { SupplierId = p.Supplier_ID, SupplierName = p.Supplier_Name, SupplierEmail = y.Supplier_Email_Adress, SupplierContactNumber = y.Supplier_Contact_Number, Province = q.Province, }; dgvListSupplier.DataSource = customers.ToList(); dgvListSupplier.ClearSelection(); db.SaveChanges(); dgvListSupplier.MouseClick += new MouseEventHandler(mouse_click); }
private void button1_Click(object sender, EventArgs e) { string phrase = txtOrderNo.Text; double number; bool isNumeric = double.TryParse(phrase, out number); if ((phrase.Length < 9) && (isNumeric == true)) { if (Convert.ToInt32(txtOrderNo.Text) > -1) { int id = Convert.ToInt32(txtOrderNo.Text); DeliveryTable orderD = db.DeliveryTables.FirstOrDefault(c => c.OrderId == id); if (orderD == null) { MessageBox.Show("Order not found"); return; } Payment pay = new Payment(); Payment_Type type = db.Payment_Type.FirstOrDefault(c => c.Payment_Description == "Cash"); pay.Payment_Amount = Convert.ToDouble(Globals.AmountDue); pay.Payment_Date = DateTime.Today; db.Payments.Add(pay); db.SaveChanges(); Globals.SalesPaymentID = pay.Payment_ID; Customer_Order order = new Customer_Order(); string name = orderD.customerName; dynamic num = orderD.customerContact; int contact = num; Customer custom = db.Customers.FirstOrDefault(c => (c.Customer_Name == name) && (c.Customer_Contact_Number == contact)); //Object Declaration---------------------------------// try { Company_Information inf = db.Company_Information.FirstOrDefault(c => c.Company_Info_ID == 1); //-----------------------------------------------------// //Order Details insert------------------------------------// order.Order_Status = "D"; order.Order_Date = DateTime.Now; order.Payment_ID = 2;// db.Payments.LastOrDefault().Payment_ID; order.Delivery_Status_ID = 1; order.OrderNotes = orderD.orderNotesf; order.OrderTotal = orderD.orderTotal; order.TotalItems = orderD.totalItemsf; order.Sale_Vat_Amount = Globals.vatAmountDelivery; order.Customer_ID = custom.Customer_ID; //---------------------------------------------------------// db.Customer_Order.Add(order); db.SaveChanges(); } catch (Exception i) { MessageBox.Show(Convert.ToString(i)); } int orderNo = orderD.OrderId; var combos = from obj in db.DeliveryLines where (obj.orderId == orderNo) && (obj.comboItemId != null) select new { itemId = obj.comboItemId, itemQuantity = obj.comboItemQuantity }; foreach (var item in combos) { //MessageBox.Show(Convert.ToString(order.Order_ID)+ " " + Convert.ToString(order.Order_ID)); Customer_Order_Line orderLine = new Customer_Order_Line(); orderLine.Customer_Order_ID = order.Order_ID; orderLine.Combo_Quantity = item.itemQuantity; orderLine.Combo_ID = item.itemId; db.Customer_Order_Line.Add(orderLine); } var menus = from obj2 in db.DeliveryLines where (obj2.orderId == orderNo) && (obj2.menuItemId != null) select new { itemId = obj2.menuItemId, itemQuantity = obj2.menuItemQuantity }; foreach (var item2 in menus) { //MessageBox.Show(Convert.ToString( item.itemQuantity) + Convert.ToString(item.itemId)); Customer_Order_Line orderLine = new Customer_Order_Line(); orderLine.Customer_Order_ID = order.Order_ID; orderLine.Menu_Item_Quantity = item2.itemQuantity; orderLine.Menu_Item_ID = item2.itemId; db.Customer_Order_Line.Add(orderLine); } var stocks = from obj3 in db.DeliveryLines where (obj3.orderId == orderNo) && (obj3.stockItemId != null) select new { itemId = obj3.stockItemId, itemQuantity = obj3.stockItemQuantity }; foreach (var item3 in stocks) { Customer_Order_Line orderLine = new Customer_Order_Line(); orderLine.Customer_Order_ID = order.Order_ID; orderLine.Menu_Item_Quantity = item3.itemQuantity; orderLine.Menu_Item_ID = item3.itemId; db.Customer_Order_Line.Add(orderLine); } db.SaveChanges(); Globals.ComboItems.Clear(); Globals.MenuItems.Clear(); Globals.StockItems.Clear(); Globals.refresher = true; Globals.AmountDue = 0; this.Close(); int id2 = Globals.LogedUser; Employee emp = db.Employees.FirstOrDefault(c => c.Employee_ID == id2); Audit ad = new Audit(); ad.Audit_Name = emp.Employee_Name; ad.Audit_Table = "Customer_Order"; ad.Audit_Description = "Order Processing"; ad.User_ID = Globals.LogedUser; ad.transactionNumber = order.Order_ID; ad.auditDate = DateTime.Now; db.Audits.Add(ad); db.SaveChanges(); MessageBox.Show("Order created successfully"); } else { MessageBox.Show("Error: Order number can't be less than one"); } } else { MessageBox.Show("Error: Order number should be numerical"); } }
private void btnSaveCombo_Click(object sender, EventArgs e) { User NewU = new User(); Employee NewE = new Employee(); string ges = cmbGender.Text; Employee_Gender_ gend = db.Employee_Gender_.FirstOrDefault(c => c.Gender_Description == ges); int gender = cmbGender.SelectedIndex; NewE.Employee_Name = txtName.Text; NewE.Employee_Surname = txtSurname.Text; NewE.Employee_Identity_Number = txtIdNumber.Text; NewE.Gender_ID = gend.Gender_ID; NewE.Adress = txtAddress.Text; NewE.Contact_Number = txtEmpContact.Text; NewE.Email_Adress = txtEmail.Text; NewE.Next_Of_Kin_Name = txtNextOfKin.Text; NewE.Next_Of_Kin_Contact_Number = txtNKC.Text; NewE.User_ID = NewU.User_ID; //Generate Login Details if (txtName.Text.Length >= 3) { string userprif = txtName.Text.Substring(0, 3); Random rd = new Random(); int number = rd.Next(100, 999); string username = userprif + number.ToString(); NewU.UserName = username; int password = rd.Next(10000, 99999); NewU.User_Password = password.ToString(); string r = cmbRole.Text; User_Role role = db.User_Role.FirstOrDefault(c => c.User_Role_Description == r); NewU.User_Role_ID = role.User_Role_ID; //send email to user address with username and password SendEmail(txtEmail.Text, txtName.Text, username, password.ToString()); } else { MessageBox.Show("Error: Name too short"); return; } db.Employees.Add(NewE); db.Users.Add(NewU); db.SaveChanges(); Globals.imageIdEmployee = NewE.Employee_ID; Globals.emNameImage = NewE.Employee_Name; MessageBox.Show("Employee added successfully,employee Login details has been sent to their email address,Press ok and add picture"); btnPictureAdd.Visible = true; btnPictureAdd.Enabled = true; }
private void btnSaveCombo_Click(object sender, EventArgs e) { if (pbxCombo.Image != null) { string phrase = txtComboPrice.Text; double number; bool isNumeric = double.TryParse(phrase, out number); if (isNumeric == true) { if ((Convert.ToDouble(txtComboPrice.Text) > 0) && (txtComboName.Text != "")) { if ((listBox1.Items.Count > 0) /*&& (listBox1.Text != "")*/) { int id = Globals.Combopassing; Combo_Price price = db.Combo_Price.FirstOrDefault(c => c.Combo_Price_ID == id); price.Combo_Price1 = Convert.ToDouble(txtComboPrice.Text); price.Combo_Price_Date = DateTime.Today; //db.Combo_Price.Add(price); int num = listBox1.Items.Count; string str = ""; for (int i = 0; i < num; i++) { str = str + listBox1.Items[i].ToString(); } Combo_Type type = db.Combo_Type.FirstOrDefault(c => c.Combo_Description == cmbComboType.Text); Combo item = db.Comboes.FirstOrDefault(c => c.Combo_Price_ID == id); item.Combo_Name = txtComboName.Text; item.Combo_Price = Convert.ToDouble(txtComboPrice.Text); item.Combo_Description = str; item.Combo_Type_ID = type.Combo_Type_ID; item.Combo_Price_ID = price.Combo_Price_ID; //MessageBox.Show(item.Combo_Description); // db.Comboes.Add(item); ItemsPicture itempic = db.ItemsPictures.FirstOrDefault(c => c.Combo_Item_ID == id); { if (Globals.browse == true) { itempic.ItemName = Globals.fileName; itempic.imageVar = Globals.ConvertImageToBinary(pbxCombo.Image); // itempic.ImageID = item.Combo_ID; // Globals.browse = false; } } db.SaveChanges(); MessageBox.Show("Combo item updated successfully"); Globals.refresher = true; this.Close(); } else { MessageBox.Show("Error:No items added"); } } else { MessageBox.Show("Error:Price value too large OR less thatn zero/Combo name field is empty"); } } else { MessageBox.Show("Error: Price not in correct format"); } } else { MessageBox.Show("Upload a picture"); } }
private void button7_Click(object sender, EventArgs e) { if (ValidateChildren(ValidationConstraints.Enabled)) { try { Supplier newSupplier = new Supplier(); Supplier_Contact_Details supplierContact = new Supplier_Contact_Details(); Address supplierAddress = new Address(); City supplierCity = new City(); Suburb supplierSuburb = new Suburb(); Banking_Details bank = new Banking_Details(); Adress_Type addressType = new Adress_Type(); Supplier_Type sp = new Supplier_Type(); newSupplier.Supplier_Name = txtSupplierName.Text; supplierContact.Supplier_Email_Adress = txtSupplierEmail.Text; supplierContact.Supplier_Contact_Number = Convert.ToInt32(txtSupplierPhone.Text); supplierContact.Supplier_Contact_Name = txtSupplierContactName.Text; supplierAddress.City_Name = txtCity.Text; supplierAddress.Street_Name = txtStreetName.Text; supplierAddress.Province = txtProvince.Text; supplierSuburb.Suburb_Name = txtSuburb.Text; supplierSuburb.Zip_Code = txtCode.Text; bank.Bank_Name = txtBankName.Text; bank.Bank_Acc_No = Convert.ToInt32(txtAccNumber.Text); bank.Branch_Code = Convert.ToInt32(txtBranchCode.Text); // newSupplier.Supplier_Type_ID = cbxSupplierType.SelectedIndex; supplierAddress.Supplier_ID = newSupplier.Supplier_ID; supplierContact.Supplier_ID = newSupplier.Supplier_ID; supplierAddress.Suburb_ID = supplierSuburb.Suburb_ID; // supplierSuburb.City_ID = supplierCity.City_ID; bank.Supplier_ID = newSupplier.Supplier_ID; newSupplier.Supplier_Type_ID = sp.Supplier_Type_ID; //db.Cities.Add(supplierCity); db.Suburbs.Add(supplierSuburb); db.Suppliers.Add(newSupplier); db.Addresses.Add(supplierAddress); db.Supplier_Contact_Details.Add(supplierContact); db.Banking_Details.Add(bank); db.SaveChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } f.loadSuppliers(); MessageBox.Show("Supplier details successfully added"); txtAccNumber.Text = ""; txtBankName.Text = ""; txtBranchCode.Text = ""; txtCity.Text = ""; txtProvince.Text = ""; txtSuburb.Text = ""; txtSupplierEmail.Text = ""; txtSupplierPhone.Text = ""; txtSupplierContactName.Text = ""; txtSupplierContactP.Text = ""; txtSuburb.Text = ""; txtSupplierName.Text = ""; txtCode.Text = ""; txtStreetName.Text = ""; //cbxSupplierType.Text = ""; // Globals.refresher = true; }
private void button1_Click(object sender, EventArgs e) { string phrase = txtStockItemPrice.Text; double number; bool isNumeric = double.TryParse(phrase, out number); if ((phrase.Length < 9) && isNumeric == true) { if (cmbStockItemType.Text == "Ingredient") { Stock_Price newPrice = new Stock_Price(); newPrice.Stock_Price1 = Convert.ToDouble(txtStockItemPrice.Text); db.Stock_Price.Add(newPrice); //newPrice.Stock_Price1 = Convert.ToDouble(txtStockItemPrice.Text); //db.Stock_Price.Add(newPrice); Stock_Item newItem = new Stock_Item(); Stock_Type idTracker = db.Stock_Type.FirstOrDefault(c => c.Stock_Type_Description == "Ingredient"); newItem.Stock_Item_Name = txtStockItemnName.Text; newItem.Stock_Item_Description = txtStockItemDescription.Text; newItem.Stock_Item_Quantity = 0; newItem.Stock_Type_ID = idTracker.Stock_Type_ID; newItem.Stock_Price_ID = newPrice.Stock_Price_ID; db.Stock_Item.Add(newItem); db.SaveChanges(); MessageBox.Show("Stock item added successfully"); Globals.refresher = true; txtStockItemnName.Text = ""; txtStockItemDescription.Text = ""; txtStockItemPrice.Text = ""; cmbStockItemType.Text = ""; } if ((phrase.Length < 9) && cmbStockItemType.Text == "Product") { Stock_Price newPrice = new Stock_Price(); newPrice.Stock_Price1 = Convert.ToDouble(txtStockItemPrice.Text); db.Stock_Price.Add(newPrice); newPrice.Stock_Price1 = Convert.ToDouble(txtStockItemPrice.Text); db.Stock_Price.Add(newPrice); Stock_Item newItem = new Stock_Item(); Stock_Type idTracker = db.Stock_Type.FirstOrDefault(c => c.Stock_Type_Description == "Product"); newItem.Stock_Item_Name = txtStockItemnName.Text; newItem.Stock_Item_Description = txtStockItemDescription.Text; newItem.Stock_Item_Quantity = 0; newItem.Stock_Type_ID = cmbStockItemType.SelectedIndex; newItem.Stock_Price_ID = newPrice.Stock_Price_ID; db.Stock_Item.Add(newItem); db.SaveChanges(); MessageBox.Show("Stock item added successfully"); Globals.refresher = true; txtStockItemnName.Text = ""; txtStockItemDescription.Text = ""; txtStockItemPrice.Text = ""; cmbStockItemType.Text = ""; } } else { MessageBox.Show("Error: Price value entered is not in correct format or too large"); } }
private void button7_Click(object sender, EventArgs e) { //string phrase = txtCash.Text; //double number; //bool isNumeric = double.TryParse(phrase, out number); //if ((phrase.Length < 9) && (isNumeric == true)) //{ // if (Convert.ToInt32(txtCash.Text) > -1) // { //int contact = Convert.ToInt32(txtContact.Text); Customer_Order order = new Customer_Order(); //Object Declaration---------------------------------// try { Company_Information inf = db.Company_Information.FirstOrDefault(c => c.Company_Info_ID == 1); double VatAmount = 0; if (Globals.ComboItems.Count != 0) { foreach (var item in Globals.ComboItems) { VatAmount = VatAmount + item.OrderItemPrice * inf.VAT_Percentage; } } if (Globals.ComboItems.Count != 0) { foreach (var item in Globals.MenuItems) { VatAmount = VatAmount + item.OrderItemPrice * inf.VAT_Percentage; } } if (Globals.StockItems.Count != 0) { foreach (var item in Globals.StockItems) { VatAmount = VatAmount + item.OrderItemPrice * inf.VAT_Percentage; } } //-----------------------------------------------------// VatAmount = Math.Round(VatAmount, 2); //Order Details insert------------------------------------// order.Order_Status = "N"; order.Order_Date = DateTime.Now; order.Sale_Vat_Amount = VatAmount; order.Payment_ID = Globals.SalesPaymentID; order.Delivery_Status_ID = 2; order.OrderNotes = richTextBox1.Text; order.OrderTotal = Globals.AmountDue; order.TotalItems = Globals.ComboItems.Count + Globals.MenuItems.Count + Globals.StockItems.Count; order.Cash = Convert.ToDouble(txtCash.Text); order.Change = Convert.ToDouble(txtCash.Text) - Globals.AmountDue; //order.Customer_ID = cust.Customer_ID; //---------------------------------------------------------// db.Customer_Order.Add(order); db.SaveChanges(); } catch (Exception i) { MessageBox.Show(Convert.ToString(i)); } for (int i = 0; i < Globals.ComboItems.Count; i++) { Customer_Order_Line orderLine = new Customer_Order_Line(); orderLine.Customer_Order_ID = order.Order_ID; orderLine.Combo_Quantity = Globals.ComboItems[i].OrderQuantity; orderLine.Combo_ID = Globals.ComboItems[i].OrderItemId; db.Customer_Order_Line.Add(orderLine); db.SaveChanges(); } for (int i = 0; i < Globals.StockItems.Count; i++) { Customer_Order_Line orderLine = new Customer_Order_Line(); orderLine.Customer_Order_ID = order.Order_ID; orderLine.Stock_Item_Quantity = Globals.StockItems[i].OrderQuantity; orderLine.Stock_ID = Globals.StockItems[i].OrderItemId; int id = Globals.StockItems[i].OrderItemId; Stock_Item stc = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id); stc.Stock_Item_Quantity = stc.Stock_Item_Quantity - Globals.StockItems[i].OrderQuantity; db.Customer_Order_Line.Add(orderLine); db.SaveChanges(); } for (int i = 0; i < Globals.MenuItems.Count; i++) { Customer_Order_Line orderLine = new Customer_Order_Line(); orderLine.Customer_Order_ID = order.Order_ID; orderLine.Menu_Item_Quantity = Globals.MenuItems[i].OrderQuantity; orderLine.Menu_Item_ID = Globals.MenuItems[i].OrderItemId; db.Customer_Order_Line.Add(orderLine); db.SaveChanges(); } Globals.ComboItems.Clear(); Globals.MenuItems.Clear(); Globals.StockItems.Clear(); Globals.refresher = true; Globals.AmountDue = 0; this.Close(); int id2 = Globals.LogedUser; Employee emp = db.Employees.FirstOrDefault(c => c.Employee_ID == id2); Audit ad = new Audit(); ad.Audit_Name = emp.Employee_Name; ad.Audit_Table = "Customer_Order"; ad.Audit_Description = "Order Processing"; ad.User_ID = Globals.LogedUser; ad.transactionNumber = order.Order_ID; ad.auditDate = DateTime.Now; db.Audits.Add(ad); db.SaveChanges(); MessageBox.Show("Order created successfully with order number: " + order.Order_ID.ToString()); btnEatIn.Visible = false; }