static public void creditorUpdate(string table, string name, string amount, DatePicker datepicker) { DateTime dateTime = datepicker.SelectedDate.Value; string date = GlobalFunctions.epochTimeParam(dateTime); string humanDate = GlobalFunctions.epochToDateTime(long.Parse(date)); SQLiteCommand sqlite_cmd; sqlite_cmd = GlobalFunctions.Connect().CreateCommand(); sqlite_cmd.CommandText = "Update " + table + " set amount = '" + amount + "', date = '" + date + "', humanDate = '" + humanDate + "' where creditorName = '" + name + "'"; sqlite_cmd.ExecuteNonQuery(); GlobalFunctions.CloseConnection(); }
static public void creditorinsert(string table, string name, string amount, DatePicker datepicker) { DateTime dateTime = datepicker.SelectedDate.Value; string date = GlobalFunctions.epochTimeParam(dateTime); string humanDate = GlobalFunctions.epochToDateTime(long.Parse(date)); SqlDataAdapter adapter; string query; SQLiteCommand sqlite_cmd; sqlite_cmd = GlobalFunctions.Connect().CreateCommand(); sqlite_cmd.CommandText = "insert into " + table + " (creditorName,amount,date,humanDate) values ('" + name + "','" + amount + "','" + date + "','" + humanDate + "')"; sqlite_cmd.ExecuteNonQuery(); GlobalFunctions.CloseConnection(); }
static public void ownerDeposit(object sender, EventArgs e, TextBox depositbox, DatePicker datepicker) { DateTime dateTime = datepicker.SelectedDate.Value; string date = GlobalFunctions.epochTimeParam(dateTime); if (depositbox.Text.Length > 0) { ownerDepositWithdrawCalculator(depositbox, "deposit", date); depositbox.Text = ""; } else { depositbox.Background = Brushes.Red; } }
static public void saveExpenseData(object sender, EventArgs e, ArrayList list, DatePicker datepicker) { DateTime dateTime = datepicker.SelectedDate.Value; string date = GlobalFunctions.epochTimeParam(dateTime); string humanDate = GlobalFunctions.epochToDateTime(long.Parse(date)); if ((list[list.Count - 1] as TextBox).Text.Length < 1 || (list[list.Count - 1] as TextBox).Text == "0") { foreach (TextBox textbox in list) { textbox.Background = Brushes.Red; } return; } string query; string textboxesValues = ""; foreach (TextBox textBox in list) { double value = 0; if (textBox.Text.Length > 0) { value = double.Parse(textBox.Text); } textboxesValues = textboxesValues + "'" + value + "',"; } SQLiteCommand sqlite_cmd; sqlite_cmd = GlobalFunctions.Connect().CreateCommand(); sqlite_cmd.CommandText = "insert into expenses (salaries,electricity,maintenance,other,withdraw,total,date,humanDate) values (" + textboxesValues + "" + date + ",'" + humanDate + "')"; sqlite_cmd.ExecuteNonQuery(); GlobalFunctions.CloseConnection(); TextBox withdrawBox = (list[list.Count - 2] as TextBox); if (withdrawBox.Text.Length > 0) { ownerDepositWithdrawCalculator(withdrawBox, "withdraw", date); } foreach (TextBox textBox in list) { textBox.Text = ""; } }
static public int InsertEntry(object sender, EventArgs e, string table, Dictionary <string, double> dict, DatePicker datePicker) { DateTime dateTime = datePicker.SelectedDate.Value; string date = GlobalFunctions.epochTimeParam(dateTime); string humanDate = GlobalFunctions.epochToDateTime(long.Parse(date)); double dailyProfit = dict["totalPkrs"] - dict["usedFuelCost"]; SQLiteCommand sqlite_cmd; sqlite_cmd = GlobalFunctions.Connect().CreateCommand(); sqlite_cmd.CommandText = "insert into " + table + " (opening1,closing1,opening2,closing2,rate,testing,discount,totalPKR,totalLTR,totalcost,profit,date,humanDate) " + "values ('" + dict["n1opening"] + "','" + dict["n1closing"] + "','" + dict["n2opening"] + "','" + dict["n2closing"] + "'," + "'" + dict["rate"] + "','" + dict["testing"] + "','" + dict["discount"] + "','" + dict["totalPkrs"] + "','" + dict["totalLtrs"] + "','" + dict["usedFuelCost"] + "','" + dailyProfit + "','" + date + "','" + humanDate + "')"; int commandstatus = sqlite_cmd.ExecuteNonQuery(); GlobalFunctions.CloseConnection(); return(commandstatus); }
static public void FuelDemandDraftEntry(object sender, EventArgs e, ArrayList textBoxes, DatePicker datepicker, string table) { DateTime dateTime = datepicker.SelectedDate.Value; string date = GlobalFunctions.epochTimeParam(dateTime); string humanDate = GlobalFunctions.epochToDateTime(long.Parse(date)); foreach (TextBox textBox in textBoxes) { if (textBox.Text.Length < 1 || textBox.Text == "0") { textBox.Background = Brushes.Red; return; } } string Reference = (textBoxes[0] as TextBox).Text; double priceCalculated = 0; double totalPKR = double.Parse((textBoxes[1] as TextBox).Text); double totalLTR = double.Parse((textBoxes[2] as TextBox).Text); priceCalculated = totalPKR / totalLTR; priceCalculated = Math.Round(priceCalculated, 2, MidpointRounding.AwayFromZero); if (priceCalculated < 40) { (textBoxes[1] as TextBox).Background = Brushes.Red; (textBoxes[2] as TextBox).Background = Brushes.Red; return; } SQLiteCommand sqlite_cmd; sqlite_cmd = GlobalFunctions.Connect().CreateCommand(); sqlite_cmd.CommandText = "insert into " + table + " (Reference,TotalPKR,LTRUsable,TotalLTR,PerLTRPrice,date,humanDate) values ('" + Reference + "','" + totalPKR + "','" + totalLTR + "','" + totalLTR + "','" + priceCalculated + "','" + date + "','" + humanDate + "');"; sqlite_cmd.ExecuteNonQuery(); (textBoxes[0] as TextBox).Text = ""; (textBoxes[1] as TextBox).Text = ""; (textBoxes[2] as TextBox).Text = ""; GlobalFunctions.CloseConnection(); }
static public Boolean dateFound(DatePicker datePicker, string table) { DateTime dateTime = datePicker.SelectedDate.Value; string date = GlobalFunctions.epochTimeParam(dateTime); SQLiteDataReader reader; SQLiteCommand sqlite_cmd; sqlite_cmd = GlobalFunctions.Connect().CreateCommand(); sqlite_cmd.CommandText = "select date from " + table + " where date =" + date; reader = sqlite_cmd.ExecuteReader(); if (reader.HasRows) { GlobalFunctions.CloseConnection(); return(true); } GlobalFunctions.CloseConnection(); return(false); }