private void RefreshOrders_Click(object sender, RoutedEventArgs e) { OrdersTable.ItemsSource = null; ZP_Orders.allOrders.Clear(); ZP_Orders.allOrders = SQL_Calls.Select_OrderInfo(); OrdersTable.ItemsSource = ZP_Orders.allOrders; }
public MainWindow() { InitializeComponent(); SQL_Calls.Initialize(); ZP_Inventory.InvAtLoc.Clear(); Inventory.ItemsSource = ZP_Inventory.InvAtLoc; }
private void RefreshCust_Click(object sender, RoutedEventArgs e) { CustomerSelect.ItemsSource = null; ZP_Customers.CustList = null; ZP_Customers.CustList = SQL_Calls.Select_Customers(); CustomerSelect.ItemsSource = ZP_Customers.CustList; }
private void Confirm_Click(object sender, RoutedEventArgs e) { if (selectedAdd == true) { if (order.customer.custID != null && (order.listOfItems.Count != 0)) { selectedCust = false; SQL_Calls.AddNewOrder(SQL_Calls.OrderID.ToString(), "2019-12-20", order.customer.custID, "PAID", "000" + Loc.ToString()); foreach (InventoryEntry c in order.listOfItems) { SQL_Calls.AddNewProductToOrder(SQL_Calls.OrderID.ToString(), c.SKU, c.quantity); } foreach (InventoryEntry c in LocInventory.Items) { SQL_Calls.UpdateInventory(c.quantity, c.branchID, c.SKU); } Reciept orderReciept = new Reciept(order, Loc); orderReciept.ShowDialog(); this.Close(); } } else { MessageBox.Show("Must Add a Select Item First!\n(Click On An Item,\n Select a Quantity From The Dropdown,\n And Click 'Add Selected')"); } }
public NewCustomer() { InitializeComponent(); CustomersView.ItemsSource = null; ZP_Customers.CustList.Clear(); ZP_Customers.CustList = SQL_Calls.Select_Customers(); CustomersView.ItemsSource = ZP_Customers.CustList; }
private void LocationPicker_SelectionChanged(object sender, SelectionChangedEventArgs e) { Location = LocationPicker.SelectedIndex + 1; ZP_Inventory.InvAtLoc.Clear(); ZP_Inventory.InvAtLoc = SQL_Calls.Select_Inventory(Location); Inventory.ItemsSource = null; Inventory.ItemsSource = ZP_Inventory.InvAtLoc; }
private void OrdersTable_SelectionChanged(object sender, SelectionChangedEventArgs e) { foreach (Order temp in OrdersTable.SelectedItems) { ZP_Orders.contains = SQL_Calls.Select_Product_Order(temp.orderID); } ContentTable.ItemsSource = null; ContentTable.ItemsSource = ZP_Orders.contains; }
public static void UpdateInventory(int Quantity, string BranchID, string SKU) { string query = "UPDATE Inventory SET Quantity = " + Quantity.ToString() + " WHERE BranchID = '" + BranchID + "' and SKU = '" + SKU + "';"; if (SQL_Calls.OpenConnection() == true) { MySqlCommand cmd = new MySqlCommand(query, connection); var r = cmd.ExecuteNonQuery(); } SQL_Calls.CloseConnection(); }
public static void AddNewOrder(string OrderID, string Order_Date, string CustomerID, string Order_Status, string BranchID) { string query = "INSERT INTO Orders (OrderID, OrderDate, CustomerID, OrderStatus, BranchID) VALUES('" + OrderID + "','" + Order_Date + "','" + CustomerID + "','" + Order_Status + "','" + BranchID + "');"; if (SQL_Calls.OpenConnection() == true) { MySqlCommand cmd = new MySqlCommand(query, connection); var r = cmd.ExecuteNonQuery(); } SQL_Calls.CloseConnection(); }
public static void UpdateProductOrder(int Quantity, string OrderID) { string query = "UPDATE ProductOrder SET Quantity = '" + Quantity + "' WHERE OrderID = '" + OrderID + "';"; if (SQL_Calls.OpenConnection() == true) { //create command and assign the query and connection from the constructor MySqlCommand cmd = new MySqlCommand(query, connection); //Execute command var r = cmd.ExecuteNonQuery(); } //close Connection SQL_Calls.CloseConnection(); }
public static void MaxOrderID() { string query = "SELECT OrderID FROM Orders WHERE OrderID = (SELECT MAX(OrderID) from Orders);"; if (SQL_Calls.OpenConnection() == true) { MySqlCommand cmd = new MySqlCommand(query, connection); MySqlDataReader dataReader = cmd.ExecuteReader(); dataReader.Read(); OrderID = dataReader.GetInt32(0); OrderID++; dataReader.Close(); } SQL_Calls.CloseConnection(); }
public static void UpdateReturnInventory(int Quantity, string BranchID, string SKU) { string query = "UPDATE Inventory SET Quantity = Quantity +" + Quantity.ToString() + " WHERE BranchID = '" + BranchID + "' and SKU = '" + SKU + "';"; if (SQL_Calls.OpenConnection() == true) { //create command and assign the query and connection from the constructor MySqlCommand cmd = new MySqlCommand(query, connection); //Execute command var r = cmd.ExecuteNonQuery(); } //close Connection SQL_Calls.CloseConnection(); }
public static void UpdateRefundStatus(string OrderID) { string query = "UPDATE Orders SET OrderStatus = 'RFND' WHERE OrderID = '" + OrderID + "';"; if (SQL_Calls.OpenConnection() == true) { //create command and assign the query and connection from the constructor MySqlCommand cmd = new MySqlCommand(query, connection); //Execute command var r = cmd.ExecuteNonQuery(); } //close Connection SQL_Calls.CloseConnection(); }
private void AddCust_Click(object sender, RoutedEventArgs e) { name = NAME.Text; lname = LNAME.Text; phone = PHONE.Text; SQL_Calls.AddNewCustomer(name, lname, phone); //clear the text NAME.Text = ""; LNAME.Text = ""; PHONE.Text = ""; //refresh the view CustomersView.ItemsSource = null; ZP_Customers.CustList.Clear(); ZP_Customers.CustList = SQL_Calls.Select_Customers(); CustomersView.ItemsSource = ZP_Customers.CustList; }
public OrderWindow(int Location) { InitializeComponent(); Loc = Location; //populate the cust select CustomerSelect.ItemsSource = null; ZP_Customers.CustList = null; ZP_Customers.CustList = SQL_Calls.Select_Customers(); CustomerSelect.ItemsSource = ZP_Customers.CustList; //populate inventory by branch/loc ZP_Inventory.InvAtLoc = null; ZP_Inventory.InvAtLoc = SQL_Calls.Select_Inventory(Loc); LocInventory.ItemsSource = null; LocInventory.ItemsSource = ZP_Inventory.InvAtLoc; //get new orderID and set to SQL_Calls class for calling the number later SQL_Calls.MaxOrderID(); }
public static void AddNewCustomer(string fname, string lname, string phone) { int tempCustID = CustomerID + 1; string query = "INSERT INTO Customer (CustomerID, FirstName, LastName, Telephone) VALUES('" + tempCustID + "','" + fname + "','" + lname + "','" + phone + "');"; //create command and assign the query and connection from the constructor if (SQL_Calls.OpenConnection() == true) { MySqlCommand cmd = new MySqlCommand(query, connection); //Execute command var r = cmd.ExecuteNonQuery(); } //close Connection SQL_Calls.CloseConnection(); }
public static void AddNewProductToOrder(string OrderID, string SKU, int Quantity) { string query = "INSERT INTO ProductOrder (OrderID, SKU, Quantity) VALUES(" + OrderID + "," + SKU + "," + Quantity + ");"; if (SQL_Calls.OpenConnection() == true) { //create command and assign the query and connection from the constructor MySqlCommand cmd = new MySqlCommand(query, connection); //Execute command var r = cmd.ExecuteNonQuery(); } //close Connection SQL_Calls.CloseConnection(); }
private void Refund_Click(object sender, RoutedEventArgs e) { foreach (Order temp in OrdersTable.SelectedItems) { foreach (OrderItems temp2 in ZP_Orders.contains) { SQL_Calls.UpdateReturnInventory(temp2.quantity, temp.branchID, temp2.SKU); } SQL_Calls.UpdateProductOrder(0, temp.orderID); SQL_Calls.UpdateRefundStatus(temp.orderID); } ZP_Orders.contains.Clear(); ContentTable.ItemsSource = null; ContentTable.ItemsSource = ZP_Orders.contains; OrdersTable.ItemsSource = null; ZP_Orders.allOrders.Clear(); ZP_Orders.allOrders = SQL_Calls.Select_OrderInfo(); OrdersTable.ItemsSource = ZP_Orders.allOrders; }
public static List <Order> Select_OrderInfo() { string query = "SELECT * FROM Orders;"; //Create a list to store the result List <Order> list = new List <Order>(); //Open connection if (SQL_Calls.OpenConnection() == true) { //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { Order temp = new Order(); temp.orderID = dataReader["OrderID"] + ""; temp.date = dataReader["OrderDate"] + ""; temp.custID = dataReader["CustomerID"] + ""; temp.status = dataReader["OrderStatus"] + ""; temp.branchID = dataReader["BranchID"] + ""; list.Add(temp); } //close Data Reader dataReader.Close(); //close Connection SQL_Calls.CloseConnection(); //return list to be displayed return(list); } else { return(list); } }
public static List <InventoryEntry> Select_Inventory(int choice) { string query = "SELECT Inventory.BranchID, Inventory.SKU, Inventory.Quantity, Product.WholesalePrice, Product.ProductName FROM Inventory LEFT JOIN Product ON Inventory.SKU = Product.SKU HAVING BranchID =" + choice + ";"; //Create a list to store the result List <InventoryEntry> list = new List <InventoryEntry>(); //Open connection if (SQL_Calls.OpenConnection() == true) { //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { InventoryEntry temp = new InventoryEntry(); temp.branchID = dataReader["BranchID"] + ""; temp.SKU = dataReader["SKU"] + ""; temp.quantity = int.Parse(dataReader["Quantity"] + ""); temp.price = double.Parse(dataReader["WholesalePrice"] + ""); temp.pName = dataReader["ProductName"] + ""; list.Add(temp); } //close Data Reader dataReader.Close(); //close Connection SQL_Calls.CloseConnection(); //return list to be displayed return(list); } else { return(list); } }
public static List <CustomerEntry> Select_Customers() { string query = "SELECT * FROM Customer;"; //Create a list to store the result List <CustomerEntry> list = new List <CustomerEntry>(); //Open connection if (SQL_Calls.OpenConnection() == true) { //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { CustomerEntry temp = new CustomerEntry(); temp.custID = dataReader["CustomerID"] + ""; temp.fName = dataReader["FirstName"] + ""; temp.lName = dataReader["LastName"] + ""; temp.tNumber = dataReader["Telephone"] + ""; CustomerID = int.Parse(temp.custID); list.Add(temp); } //close Data Reader dataReader.Close(); //close Connection SQL_Calls.CloseConnection(); //return list to be displayed return(list); } else { return(list); } }
public static List <OrderItems> Select_Product_Order(string choice) { string query = "SELECT * FROM ProductOrder WHERE OrderID = '" + choice + "';"; //Create a list to store the result List <OrderItems> list = new List <OrderItems>(); //Open connection if (SQL_Calls.OpenConnection() == true) { //Create Command MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { OrderItems temp = new OrderItems(); temp.orderID = dataReader["OrderID"] + ""; temp.SKU = dataReader["SKU"] + ""; temp.quantity = int.Parse(dataReader["Quantity"] + ""); list.Add(temp); } //close Data Reader dataReader.Close(); //close Connection SQL_Calls.CloseConnection(); //return list to be displayed return(list); } else { return(list); } }