Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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 = "";
            }
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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();
        }
Esempio n. 6
0
        static private void ownerDepositWithdrawCalculator(TextBox textBox, string status, string date)
        {
            string humanDate = GlobalFunctions.epochToDateTime(long.Parse(date));

            double total    = 0;
            double deposit  = 0;
            double withdraw = 0;


            SQLiteDataReader reader;
            SQLiteCommand    sqlite_cmd;

            sqlite_cmd             = GlobalFunctions.Connect().CreateCommand();
            sqlite_cmd.CommandText = "Select (total) from ownerAmount";

            reader = sqlite_cmd.ExecuteReader();
            while (reader.Read())
            {
                total = reader.GetDouble(0);
            }


            if (status == "deposit")
            {
                deposit = double.Parse(textBox.Text);
            }
            else
            {
                withdraw = double.Parse(textBox.Text);
            }

            total = (total + deposit) - withdraw;

            sqlite_cmd             = GlobalFunctions.Connect().CreateCommand();
            sqlite_cmd.CommandText = "insert into ownerAmount (deposit,withdrawal,total,date,humanDate) values ('" + deposit + "','" + withdraw + "','" + total + "','" + date + "','" + humanDate + "')";
            sqlite_cmd.ExecuteNonQuery();
            GlobalFunctions.CloseConnection();
        }