public void Insert(string table, employee hire = new employee(), reciept order = new reciept(), product item = new product()) { string query = "INSERT INTO " + table; // if it is an employee if (table == "employees") { query += "(name, age, id_num, pay, sex, birthday) VALUES('" + hire.name + "', '" + hire.age + "', '" + hire.id + "', '" + hire.pay_rate + "', '" + hire.sex + "', '" + hire.birthday + "')"; } else if (table == "Reciepts") { query += "(contents, item_amount, price, tax_amount, full_price) VALUES('" + order.order + "', '" + order.item_amount + "', '" + (order.price) + "', '" + order.tax_amount + "', '" + order.total_price + "')"; } else if (table == "Products") { query += "(Name, Price, Type, Stock) VALUES('" + item.name + "', " + item.price + ", '" + item.category + "', " + 10 + ")"; } else { return; } //else it must be for the menu or something if (this.Connect() == true) // Open connection { MySqlCommand command = new MySqlCommand(query, connection); command.ExecuteNonQuery(); this.Disconnect(); // Close connection } }
private void SendStay_Click(object sender, RoutedEventArgs e) { UpdateInventory(); reciept data = GetData(); server.Insert("Reciepts", new employee(), data); using StreamWriter outputOrder = new StreamWriter("../../../Orders/order.txt"); outputOrder.WriteLine(o.ToString()); }
private void SendQuit_Click(object sender, RoutedEventArgs e) { reciept data = GetData(); server.Insert("Reciepts", new employee(), data); using StreamWriter outputOrder = new StreamWriter("../../../Orders/order.txt"); outputOrder.WriteLine(o.ToString()); MainWindow loginWindow = new MainWindow(); loginWindow.Show(); this.Close(); MessageBox.Show("Reciept Content: " + encryption.Decrypt(data.order, encryption.getKey()) + " has been added to data base.\nItem Amount: " + encryption.Decrypt(data.item_amount, encryption.getKey()) + "\nTax: " + encryption.Decrypt(data.tax_amount, encryption.getKey()) + "\n"); }
private reciept GetData() { reciept data = new reciept(); data.order = o.ToString(); char[] delim = { '\n', '\t' }; string[] words = data.order.Split(delim); string temp = ""; foreach (var word in words) { temp += word + ' '; } data.order = encryption.Encrypt(temp, encryption.getKey()); data.item_amount = encryption.Encrypt(o.GetItemAmount().ToString(), encryption.getKey()); data.price = encryption.Encrypt(o.GetSubtotal(), encryption.getKey()); data.tax_amount = encryption.Encrypt(o.GetTax(), encryption.getKey()); data.total_price = encryption.Encrypt(o.GetTotalPrice(), encryption.getKey()); return(data); }
public void Delete(string table, employee hire = new employee(), reciept order = new reciept(), product item = new product()) { string query = "DELETE FROM " + table + " WHERE `Name` = "; if (table == "Products") { query += "'" + item.name + "'"; } else { return; } if (this.Connect() == true) // Open connection { MySqlCommand command = new MySqlCommand(query, connection); command.ExecuteNonQuery(); this.Disconnect(); // Close connection } }