public static void UpdateCompletedTransView()
        {
            int             iIndex;
            string          sQuery;
            OleDbCommand    dbCmd;
            OleDbDataReader drRecordSet;

            /* SqlCommand dbCmd;
             * SqlDataReader drRecordSet;*/
            DB.TransStruct myTransStruct;



            Debug.WriteLine("UPDATE COMPLETE TRANSACTIONS VIEW");

            SQL_SERVER.Set_Sql_Server_Conn();
            SQL_SERVER.Open_Sql_Server_Conn();


            //sQuery = "SELECT COMPLETED_TIME, PIC, PUMP, DEPOSIT, PURCHASE, PRICE, CHANGE, GRADE, VOLUME, SHOW_TIME, TRAN_ID FROM TRANSACTIONS ORDER BY COMPLETED_TIME DESC";

            sQuery = "SELECT COMPLETED_TIME, PIC, PUMP, DEPOSIT, PURCHASE, PRICE, GRADE, VOLUME, SHOW_TIME, TRAN_ID,CHANGE FROM TRANSACTIONS ORDER BY COMPLETED_TIME DESC;";
            dbCmd  = SQL_SERVER.Set_Sql_Server_Cmd(sQuery);

            drRecordSet = dbCmd.ExecuteReader();

            Debug.WriteLine(sQuery);
            Debug.WriteLine(drRecordSet.HasRows);

            iCount = 0;
            DB.lCompletedTrans.Clear();
            while (drRecordSet.Read())
            {
                myTransStruct.sPIC      = drRecordSet["PIC"].ToString();
                myTransStruct.sPump     = drRecordSet["PUMP"].ToString();
                myTransStruct.sDeposit  = drRecordSet["DEPOSIT"].ToString();
                myTransStruct.sPurchase = drRecordSet["PURCHASE"].ToString();
                myTransStruct.sPrice    = drRecordSet["PRICE"].ToString();
                myTransStruct.sChange   = drRecordSet["CHANGE"].ToString();
                myTransStruct.sGrade    = drRecordSet["GRADE"].ToString();
                myTransStruct.sVolume   = drRecordSet["VOLUME"].ToString();
                myTransStruct.sShowTime = drRecordSet["SHOW_TIME"].ToString();
                myTransStruct.sTranId   = drRecordSet["TRAN_ID"].ToString();

                DB.lCompletedTrans.Add(myTransStruct);
                iCount++;
            }

            for (iIndex = 0; iIndex < 6; iIndex++)
            {
                if (iIndex < iCount)
                {
                    tv.pump_no.Text = DB.lCompletedTrans[iIndex].sPump.ToString();
                    Transactions_View.Update_Transactions_ButtonText(iIndex + 1, "PUMP: " + DB.lCompletedTrans[iIndex].sPump + " @ " + DB.lCompletedTrans[iIndex].sShowTime + " PAID: $" + DB.lCompletedTrans[iIndex].sDeposit + "  \nCHANGE: $" + DB.lCompletedTrans[iIndex].sChange);
                }
            }
            dbCmd.Dispose();
            drRecordSet.Dispose();
            SQL_SERVER.Close_Sql_Sever_Conn();
        }
        public void Auto_check_CheckedChanged(object sender, EventArgs e)
        {
            //Auto_check.Checked = true;
            if (Auto_check.Checked)
            {
                Auto_check.Text      = "set";
                Auto_check.ForeColor = Color.Green;



                new SetDataTime().Show(); // open the Set date time form
            }
            else
            {
                Auto_check.Text      = "unset";
                Auto_check.ForeColor = Color.Red;

                DB.IsGenerateEOD_report = false;  // auto generate report off

                /* try {
                 *
                 *   string UpdatesConfig = File.ReadAllText("E:/config.txt");
                 *
                 *   string replaceStr = UpdatesConfig.Replace("ENABLE", "DISABLE");
                 *
                 *   File.WriteAllText("E:/config.txt", replaceStr);
                 * }
                 * catch (Exception ex)
                 * {
                 *   Debug.WriteLine("File can't write :" + ex);
                 *
                 * }*/

                String       QueryStr;
                OleDbCommand cmd;


                try
                {
                    SQL_SERVER.Set_Sql_Server_Conn();
                    SQL_SERVER.Open_Sql_Server_Conn();
                    QueryStr = "UPDATE [Auto_EOD_Config] SET [AUTOEOD]='DISABLE' where [ID]=1";
                    SQL_SERVER.ExecuteNonQuery(QueryStr);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Not Update data from Auto_EOD_Config table :" + ex);
                }



                //UpdatesConfig.Replace(UpdatesConfig.Substring(UpdatesConfig.IndexOf("<AUTOEOD>") + 9, (UpdatesConfig.IndexOf("</AUTOEOD>") - UpdatesConfig.IndexOf("<AUTOEOD>") - 9)),""

                Display.ShowMessageBox("Off Automatic Day Close", 4);
            }
        }
Exemple #3
0
        private void create_Click(object sender, EventArgs e)
        {
            SQL_SERVER.Open_Sql_Server_Conn();
            sPassId      = DateTime.Now.ToString("yyMMddHHmmss") + new Random().Next(0, 10);
            sPassTime    = DateTime.Now.ToString("yyMMddHHmmss");
            iPassPumpNum = new Random().Next(1, 8);
            iPassPicNum  = new Random().Next(1, 8);

            DB.CreateTransaction(sPassId, sPassTime, iPassPicNum, iPassPumpNum);

            MessageBox.Show("Success Create transaction");
        }
Exemple #4
0
        private void SetTransactionsDetails(string transac_id)
        {
            IsPrintable = true;
            OleDbCommand    dbCmd;
            OleDbDataReader drRecordSet;


            SQL_SERVER.Set_Sql_Server_Conn();
            SQL_SERVER.Open_Sql_Server_Conn();


            //sQuery = "SELECT COMPLETED_TIME, PIC, PUMP, DEPOSIT, PURCHASE, PRICE, CHANGE, GRADE, VOLUME, SHOW_TIME, TRAN_ID FROM TRANSACTIONS ORDER BY COMPLETED_TIME DESC";

            string sQuery = "SELECT  PUMP, DEPOSIT,PURCHASE, VOLUME, SHOW_TIME, TRAN_ID,CHANGE FROM TRANSACTIONS WHERE TRAN_ID LIKE '%" + transac_id + "%' ORDER BY COMPLETED_TIME DESC;";

            dbCmd = SQL_SERVER.Set_Sql_Server_Cmd(sQuery);

            drRecordSet = dbCmd.ExecuteReader();

            Debug.WriteLine(sQuery);
            Debug.WriteLine(drRecordSet.HasRows);


            if (drRecordSet.HasRows)
            {
                while (drRecordSet.Read())
                {
                    pump_no.Text = drRecordSet["PUMP"].ToString();
                    deposit.Text = drRecordSet["DEPOSIT"].ToString() + "$";

                    change.Text = drRecordSet["CHANGE"].ToString() + "$";

                    gal.Text       = drRecordSet["VOLUME"].ToString() + " gal";
                    date_time.Text = drRecordSet["SHOW_TIME"].ToString();
                    var    cultureInfo = new System.Globalization.CultureInfo("en-US");
                    double purchage    = Convert.ToDouble(drRecordSet["PURCHASE"].ToString(), cultureInfo);
                    double deposite    = Convert.ToDouble(drRecordSet["DEPOSIT"].ToString(), cultureInfo);
                    total.Text = (deposite - purchage).ToString();
                }


                dbCmd.Dispose();
                drRecordSet.Dispose();
                SQL_SERVER.Close_Sql_Sever_Conn();
            }
        }
Exemple #5
0
        private void on_off_Click(object sender, EventArgs e)
        {
            if (on_off.Text == "OFF")
            {
                on_off.Text = "ON";
            }
            else if (on_off.Text == "ON")
            {
                on_off.Text = "OFF";
            }

            if (on_off.Text == "ON")
            {
                on_off.ForeColor = Color.Green;

                new SetDataTime().Show();
            }
            else if (on_off.Text == "OFF")
            {
                on_off.ForeColor = Color.Red;

                DB.IsGenerateEOD_report = false;
                SQL_SERVER.Open_Sql_Server_Conn();
                String QueryStr;



                try
                {
                    QueryStr = "UPDATE [Auto_EOD_Config] SET [AUTOEOD]='DISABLE' where [ID]=1";
                    SQL_SERVER.ExecuteNonQuery(QueryStr);
                    //SQL_SERVER.ExecuteNonQuery(QueryStr);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Not Update data from Auto_EOD_Config table :" + ex);
                }

                SQL_SERVER.Close_Sql_Sever_Conn();

                //UpdatesConfig.Replace(UpdatesConfig.Substring(UpdatesConfig.IndexOf("<AUTOEOD>") + 9, (UpdatesConfig.IndexOf("</AUTOEOD>") - UpdatesConfig.IndexOf("<AUTOEOD>") - 9)),""

                Display.ShowMessageBox("Off Automatic Day Close", 4);
            }
        }
        private void GetChooseTransations(string datetimeformate)
        {
            int             iIndex;
            string          sQuery;
            OleDbCommand    dbCmd;
            OleDbDataReader drRecordSet;

            /* SqlCommand dbCmd;
             * SqlDataReader drRecordSet;*/
            DB.TransStruct myTransStruct;



            Debug.WriteLine("UPDATE COMPLETE TRANSACTIONS VIEW");

            SQL_SERVER.Set_Sql_Server_Conn();
            SQL_SERVER.Open_Sql_Server_Conn();


            //sQuery = "SELECT COMPLETED_TIME, PIC, PUMP, DEPOSIT, PURCHASE, PRICE, CHANGE, GRADE, VOLUME, SHOW_TIME, TRAN_ID FROM TRANSACTIONS ORDER BY COMPLETED_TIME DESC";

            sQuery = "SELECT COMPLETED_TIME, PIC, PUMP, DEPOSIT, PURCHASE, PRICE, GRADE, VOLUME, SHOW_TIME, TRAN_ID,CHANGE FROM TRANSACTIONS WHERE SHOW_TIME LIKE '%" + datetimeformate + "%' ORDER BY COMPLETED_TIME DESC;";
            dbCmd  = SQL_SERVER.Set_Sql_Server_Cmd(sQuery);

            drRecordSet = dbCmd.ExecuteReader();

            Debug.WriteLine(sQuery);
            Debug.WriteLine(drRecordSet.HasRows);


            if (drRecordSet.HasRows)
            {
                iCount = 0;
                DB.lCompletedTrans.Clear();
                ClearButtonTexts();
                ClearSelection();
                ClearTransactionsDetails();

                while (drRecordSet.Read())
                {
                    myTransStruct.sPIC      = drRecordSet["PIC"].ToString();
                    myTransStruct.sPump     = drRecordSet["PUMP"].ToString();
                    myTransStruct.sDeposit  = drRecordSet["DEPOSIT"].ToString();
                    myTransStruct.sPurchase = drRecordSet["PURCHASE"].ToString();
                    myTransStruct.sPrice    = drRecordSet["PRICE"].ToString();
                    myTransStruct.sChange   = drRecordSet["CHANGE"].ToString();
                    myTransStruct.sGrade    = drRecordSet["GRADE"].ToString();
                    myTransStruct.sVolume   = drRecordSet["VOLUME"].ToString();
                    myTransStruct.sShowTime = drRecordSet["SHOW_TIME"].ToString();
                    myTransStruct.sTranId   = drRecordSet["TRAN_ID"].ToString();

                    DB.lCompletedTrans.Add(myTransStruct);
                    iCount++;
                }

                for (iIndex = 0; iIndex < 6; iIndex++)
                {
                    if (iIndex < iCount)
                    {
                        Update_Transactions_ButtonText(iIndex + 1, "PUMP: " + DB.lCompletedTrans[iIndex].sPump + " @ " + DB.lCompletedTrans[iIndex].sShowTime + " PAID: $" + DB.lCompletedTrans[iIndex].sDeposit + "\nCHANGE: $" + DB.lCompletedTrans[iIndex].sChange);
                    }
                }


                iPage = 1;

                if (DB.lCompletedTrans.Count <= 6 * iPage)
                {
                    ButtonVisibility(next_btn, false);
                }
                if (DB.lCompletedTrans.Count >= 6 * iPage)
                {
                    ButtonVisibility(next_btn, true);
                }
            }
            else
            {
                Display.ShowMessageBox("Not Available Selected date Transations \n Showing All Available Transactions", 6);
            }
            dbCmd.Dispose();
            drRecordSet.Dispose();
            SQL_SERVER.Close_Sql_Sever_Conn();
        }
Exemple #7
0
        private void Config_AutoEOD()
        {
            //throw new NotImplementedException();

            //FileAccess.ReadSettings();
            String          QueryStr;
            OleDbCommand    cmd;
            OleDbDataReader dbr;


            try
            {
                QueryStr = "select *from Auto_EOD_Config";
                SQL_SERVER.Set_Sql_Server_Conn();
                SQL_SERVER.Open_Sql_Server_Conn();

                cmd = SQL_SERVER.Set_Sql_Server_Cmd(QueryStr);
                dbr = cmd.ExecuteReader();

                if (dbr.HasRows)
                {
                    while (dbr.Read())
                    {
                        EODStatus = dbr["AUTOEOD"].ToString();
                        HOURS     = dbr["HOURS"].ToString();
                        MINUTES   = dbr["MINUTES"].ToString();
                        INTERVAL  = dbr["INTERVAL"].ToString();
                    }
                    cmd.Dispose();
                    dbr.Dispose();

                    SetDataTime.hours    = HOURS;
                    SetDataTime.minutes  = MINUTES;
                    SetDataTime.interval = INTERVAL;
                }
                else
                {
                    Debug.WriteLine("Don't read data from Auto_EOD_Config table");
                }
            }
            catch (Exception ex) {
                Debug.WriteLine("Don't read data from Auto_EOD_Config table :" + ex);
            }



            /* sConfig = File.ReadAllText("E:/config.txt");
             * EODStatus = sConfig.Substring(sConfig.IndexOf("<AUTOEOD>") + 9, (sConfig.IndexOf("</AUTOEOD>") - sConfig.IndexOf("<AUTOEOD>") - 9));
             * HOURS = sConfig.Substring(sConfig.IndexOf("<HOURS>") + 7, (sConfig.IndexOf("</HOURS>") - sConfig.IndexOf("<HOURS>") - 7));
             * MINUTES = sConfig.Substring(sConfig.IndexOf("<MINUTES>") + 9, (sConfig.IndexOf("</MINUTES>") - sConfig.IndexOf("<MINUTES>") - 9));
             * INTERVAL = sConfig.Substring(sConfig.IndexOf("<INTERVAL>") + 10, (sConfig.IndexOf("</INTERVAL>") - sConfig.IndexOf("<INTERVAL>") - 10)) ;*/



            // MessageBox.Show(EODStatus + "");


            if (EODStatus == "ENABLE" && HOURS != "" && MINUTES != "" && INTERVAL != "")
            {
                //Auto_check.Checked = true;
                on_off.Text      = "ON";
                on_off.ForeColor = Color.Green;

                //this.Show();
            }
        }
Exemple #8
0
        private void PrintReceipt(string trnasc_id)
        {
            Debug.WriteLine("TRYING TO PRINT... STATUS + " + Printer.iStatus);

            if (Printer.iStatus == 1)
            {
                string sPIC      = "";
                string sPump     = "";
                string sGrade    = "";
                string sVolume   = "";
                string sPurchase = "";
                string sPrice    = "";
                string sDeposit  = "";
                string sChange   = "";
                string sShowTime = "";
                string sTranId   = "";
                string sReceipt  = "";

                OleDbCommand    dbCmd;
                OleDbDataReader drRecordSet;


                SQL_SERVER.Set_Sql_Server_Conn();
                SQL_SERVER.Open_Sql_Server_Conn();


                //sQuery = "SELECT COMPLETED_TIME, PIC, PUMP, DEPOSIT, PURCHASE, PRICE, CHANGE, GRADE, VOLUME, SHOW_TIME, TRAN_ID FROM TRANSACTIONS ORDER BY COMPLETED_TIME DESC";

                string sQuery = "SELECT COMPLETED_TIME, PIC, PUMP, DEPOSIT, PURCHASE, PRICE, GRADE, VOLUME, SHOW_TIME, TRAN_ID,CHANGE FROM TRANSACTIONS WHERE TRAN_ID LIKE '%" + trnasc_id + "%' ORDER BY COMPLETED_TIME DESC;";
                dbCmd = SQL_SERVER.Set_Sql_Server_Cmd(sQuery);

                drRecordSet = dbCmd.ExecuteReader();

                Debug.WriteLine(sQuery);
                Debug.WriteLine(drRecordSet.HasRows);


                if (drRecordSet.HasRows)
                {
                    while (drRecordSet.Read())
                    {
                        sPIC      = drRecordSet["PIC"].ToString();
                        sPump     = drRecordSet["PUMP"].ToString();
                        sGrade    = drRecordSet["GRADE"].ToString();
                        sVolume   = drRecordSet["VOLUME"].ToString();
                        sPurchase = drRecordSet["PURCHASE"].ToString();
                        sPrice    = drRecordSet["PRICE"].ToString();
                        sDeposit  = drRecordSet["DEPOSIT"].ToString();
                        sChange   = drRecordSet["CHANGE"].ToString();
                        sShowTime = drRecordSet["SHOW_TIME"].ToString();
                        sTranId   = drRecordSet["TRAN_ID"].ToString();
                    }



                    sReceipt = sReceipt + Printer.sHeader;
                    sReceipt = sReceipt + "\n\n\n";

                    sReceipt = sReceipt + "Pump: " + sPump + "\n";
                    sReceipt = sReceipt + "Terminal: " + sPIC + "\n\n";

                    sReceipt = sReceipt + "Descr.           qty               amount" + "\n";
                    sReceipt = sReceipt + "------           ---               ------" + "\n";
                    sReceipt = sReceipt + sGrade + "               " + sVolume + "               " + sPurchase + "\n";
                    sReceipt = sReceipt + "                @ " + sPrice + "/G" + "\n";
                    sReceipt = sReceipt + "                Prepay Fuel        -" + sDeposit + ".00" + "\n";
                    sReceipt = sReceipt + "                                 --------" + "\n";
                    sReceipt = sReceipt + "                    Subtotal        -" + sChange + "\n";
                    sReceipt = sReceipt + "                         Tax         0.00" + "\n";
                    sReceipt = sReceipt + "                       TOTAL        -" + sChange + "\n";
                    sReceipt = sReceipt + "                        CASH        -" + sChange + "\n\n";

                    sReceipt = sReceipt + "TRAN# " + sTranId + "\n";
                    sReceipt = sReceipt + sShowTime + "\n\n";
                    sReceipt = sReceipt + Printer.sFooter + "\n\n\n\n\n\n\n\n\n\n\n\n\n";

                    Printer.sReceipt     = sReceipt;
                    CenCom.bPrintRequest = true;

                    Debug.WriteLine(sReceipt);

                    //MessageBox.Show(sReceipt + "");

                    dbCmd.Dispose();
                    drRecordSet.Dispose();
                    SQL_SERVER.Close_Sql_Sever_Conn();
                }
            }
            else
            {
                Display.ShowMessageBox("Printer Offline", 3);
            }
        }
        private void Ok_btn_Click(object sender, EventArgs e)
        {
            hours   = hours_txt_box.Text.ToString().Trim();
            minutes = minutes_txt_box.Text.ToString().Trim();

            if ((hours != null && hours != "") && (minutes != null && minutes != "") && (IsselectedAm || IsselectedPm))
            {
                if (hours.Length == 1)
                {
                    hours = "0" + hours;
                }

                if (minutes.Length == 1)
                {
                    minutes = "0" + minutes;
                }


                /*  try
                 * {
                 *
                 *    UpdatesConfig = File.ReadAllText("E:/config.txt");
                 *
                 *    UpdatesConfig = UpdatesConfig.Replace("DISABLE", "ENABLE");
                 *    UpdatesConfig = UpdatesConfig.Replace((UpdatesConfig.Substring(UpdatesConfig.IndexOf("<HOURS>") + 7, (UpdatesConfig.IndexOf("</HOURS>") - UpdatesConfig.IndexOf("<HOURS>") - 7))), hours + "");
                 *    UpdatesConfig = UpdatesConfig.Replace((UpdatesConfig.Substring(UpdatesConfig.IndexOf("<MINUTES>") + 9, (UpdatesConfig.IndexOf("</MINUTES>") - UpdatesConfig.IndexOf("<MINUTES>") - 9))), minutes + "");
                 *    UpdatesConfig = UpdatesConfig.Replace((UpdatesConfig.Substring(UpdatesConfig.IndexOf("<INTERVAL>") + 10, (UpdatesConfig.IndexOf("</INTERVAL>") - UpdatesConfig.IndexOf("<INTERVAL>") - 10))), interval + "");
                 *
                 *    File.WriteAllText("E:/config.txt", UpdatesConfig);
                 * }
                 * catch (Exception ex) {
                 *    Debug.WriteLine("File can't write (Not set time in file) :" + ex);
                 *
                 * }*/

                String       QueryStr;
                OleDbCommand cmd;


                try
                {
                    SQL_SERVER.Set_Sql_Server_Conn();
                    SQL_SERVER.Open_Sql_Server_Conn();
                    //QueryStr = @"UPDATE Auto_EOD_Config SET AUTOEOD='ENABLE', HOURS='" + hours + "', MINUTES='" + minutes + "', INTERVAL='"+interval+"' WHERE ID=1";
                    QueryStr = @"UPDATE [Auto_EOD_Config] Set [AUTOEOD] = 'ENABLE', [HOURS]='" + hours + "', [MINUTES]='" + minutes + "', [INTERVAL]='" + interval + "' WHERE [ID]=1;";
                    SQL_SERVER.ExecuteNonQuery(QueryStr);

                    /* cmd = SQL_SERVER.Set_Sql_Server_Cmd(QueryStr);
                     * cmd.Parameters.AddWithValue("@enable","ENABLE");
                     * cmd.Parameters.AddWithValue("@hours",hours.ToString());
                     * cmd.Parameters.AddWithValue("@minutes", minutes.ToString());
                     * cmd.Parameters.AddWithValue("interval", interval.ToString());
                     * cmd.Parameters.AddWithValue("@id",1);
                     *
                     * cmd.ExecuteNonQuery();*/
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Not Update data from Auto_EOD_Config table :" + ex);
                }



                this.Hide();
                //DB.IsGenerateEOD_report = false;
                //DB.IsGeneratePIC_Cash_report = false;
                //  MessageBox.Show(hours+":"+minutes+":01"+" "+interval+" "+DateTime.Now.ToString("hh:mm:ss tt"));

                Display.ShowMessageBox("your time seted " + hours + ":" + minutes + " " + interval, 5);
            }
            else
            {
                Display.ShowMessageBox("Please set all fields", 5);
            }

            // this.Hide();

            //form1.Auto_check.Checked = false;
            //form1.Auto_check.CheckedChanged += new EventHandler(CheckBox_Checked);

            //  form1.Auto_check_CheckedChanged(null,null);

            //CheckBox check = (CheckBox)this.form1.Controls["Auto_check"];
        }