//private void button11_Click(object sender, EventArgs e) //{ //} //Maintain Stock Mouse Right Click //Maintain Stock Mouse Right Click-------------------------------------------------------------------// //Maintain Stock Mouse Right Click //Maintain Stock Mouse Right Click-------------------------------------------------------------------// //Stock Management Click Event Handlers // //-----------------------------------------------------------------------// private void button1_Click(object sender, EventArgs e) { if (navButton == quoteBtn) { SalesAndOrdering sales = new SalesAndOrdering(); sales.ShowDialog(); //navigate(quoteBtn); } if (navButton == btnSuppliers11) { SupplierForm supplier = new SupplierForm(); supplier.ShowDialog(); } if (navButton == clientBtn) { frmAddCustomer customer = new frmAddCustomer(); customer.ShowDialog(); } if (navButton == supplierBtn) { frmAddCombo combo = new frmAddCombo(); combo.ShowDialog(); } if (navButton == jobOBtn) { Menu_And_Combo menu = new Menu_And_Combo(); menu.ShowDialog(); } if (navButton == inventoryBtn) { frmAdd_New_Stock_Item addStock = new frmAdd_New_Stock_Item(); addStock.ShowDialog(); } if (navButton == empBtn) { Add_Employee employee = new Add_Employee(); employee.ShowDialog(); } }
private void btnDeliverySubmit_Click(object sender, EventArgs e) { Company_Information inf = db.Company_Information.FirstOrDefault(c => c.Company_Info_ID == 1); string phrase = txtContact.Text; double number; bool isNumeric = double.TryParse(phrase, out number); if ((phrase.Length == 10) && (isNumeric == true)) { if (Convert.ToInt32(txtContact.Text) > -1) { double VatAmount = 0; DeliveryTable order = new DeliveryTable(); order.ItemName = ""; order.orderTotal = Globals.AmountDue; int contact = Convert.ToInt32(txtContact.Text); 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.orderDatef = DateTime.Now; order.vatTot = VatAmount; order.orderNotesf = richTextBox1.Text; order.orderTotal = Globals.AmountDue; order.totalItemsf = Globals.ComboItems.Count + Globals.MenuItems.Count + Globals.StockItems.Count; Customer cust = db.Customers.FirstOrDefault(c => ((c.Customer_Name == txtCustName.Text) && (c.Customer_Contact_Number == contact))); if (cust == null) { MessageBox.Show("Customer does not exist,Add customer"); using (frmAddCustomer frm = new frmAddCustomer() { }) { if ((frm.ShowDialog() == DialogResult.OK) && (Globals.addCustomer == true)) { var some = db.Customers.ToList(); cust = some.LastOrDefault(); order.customerName = cust.Customer_Name; order.customerContact = cust.Customer_Contact_Number; } else { MessageBox.Show("Something went wrong"); return; } } } else { order.customerName = txtCustName.Text; order.customerContact = Convert.ToInt32(txtContact.Text); } db.DeliveryTables.Add(order); db.SaveChanges(); for (int i = 0; i < Globals.ComboItems.Count; i++) { DeliveryLine item = new DeliveryLine(); item.comboItemId = Globals.ComboItems[i].OrderItemId; item.orderId = order.OrderId; item.comboItemQuantity = Globals.ComboItems[i].OrderQuantity; db.DeliveryLines.Add(item); } for (int i = 0; i < Globals.StockItems.Count; i++) { DeliveryLine item = new DeliveryLine(); item.stockItemId = Globals.StockItems[i].OrderItemId; item.orderId = order.OrderId; item.stockItemQuantity = Globals.StockItems[i].OrderQuantity; db.DeliveryLines.Add(item); } for (int i = 0; i < Globals.MenuItems.Count; i++) { DeliveryLine item = new DeliveryLine(); item.menuItemId = Globals.MenuItems[i].OrderItemId; item.orderId = order.OrderId; item.menuItemQuantity = Globals.MenuItems[i].OrderQuantity; db.DeliveryLines.Add(item); } db.SaveChanges(); this.Close(); Globals.ComboItems.Clear(); Globals.MenuItems.Clear(); Globals.StockItems.Clear(); 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 = "DeliveryTable"; ad.Audit_Description = "Order Saving"; ad.User_ID = Globals.LogedUser; ad.transactionNumber = order.OrderId; ad.auditDate = DateTime.Now; db.Audits.Add(ad); db.SaveChanges(); MessageBox.Show("Order saved successfully with order number: " + order.OrderId.ToString() + ",customer Address: " + cust.Customer_Address.ToString()); string username = "******"; string password = "******"; string msgsender = "4700000000"; string destinationaddr = "27" + txtContact.Text.Substring(1, 9); string message = "Dear customer,thank you for ordering food with us,your order is being prepared for delivery,your order number is: " + order.OrderId.ToString(); // Create ViaNettSMS object with username and password ViaNettSMS s = new ViaNettSMS(username, password); // Declare Result object returned by the SendSMS function ViaNettSMS.Result result; try { // Send SMS through HTTP API result = s.sendSMS(msgsender, destinationaddr, message); // Show Send SMS response if (result.Success) { MessageBox.Show("Order confirmation message successfully sent to customer"); } else { MessageBox.Show("Error:Network connection not strong enough to send and receive messages:" + result.ErrorCode + " " + result.ErrorMessage); } } catch (System.Net.WebException ex) { //Catch error occurred while connecting to server. MessageBox.Show(ex.Message); } } else { MessageBox.Show("Error: Contact number can't be a negative number"); } } else { MessageBox.Show("Error: Contact number not numeric/valid,please anter a valid number(integer)"); } }