Esempio n. 1
0
        private void test_email_button_Click(object sender, EventArgs e)
        {
            //test_email_button.Enabled = false;
            if (email_pw_text.Text != email_repeat_pw_text.Text)
            {
                error_text.Visible = true;
            }
            else
            {
                string         query    = "select * from d_active where employeenumber = '" + this.current_employeenumber + "'";
                ExcoODBC       database = ExcoODBC.Instance;
                OdbcDataReader reader;
                database.Open(Database.DECADE_MARKHAM);
                reader = database.RunQuery(query);
                try
                {
                    reader.Read();
                    Encrypter   @str         = new Encrypter();
                    string      my_email     = @str.Decrypt(reader[3].ToString().Trim());
                    string      my_pw        = @str.Decrypt(reader[4].ToString().Trim());
                    string      my_smtp      = reader[5].ToString().Trim();
                    int         my_smtp_port = Convert.ToInt32(reader[7].ToString().Trim());
                    string      my_sig       = @str.Decrypt(reader[9].ToString().Trim());
                    MailMessage mailmsg      = new MailMessage();
                    mailmsg.To.Add(my_email);
                    MailAddress from = new MailAddress(my_email);
                    mailmsg.From    = from;
                    mailmsg.Subject = "Monitor test email message @ " + DateTime.Now.ToString();
                    mailmsg.Body    = "Test body. The following (if any) is your signature: " + "\r\n\r\n" + my_sig;
                    SmtpClient        client     = new SmtpClient(my_smtp, my_smtp_port);
                    NetworkCredential credential = new NetworkCredential(my_email, my_pw);
                    client.Credentials = credential;

                    bool hasSend = false;
                    while (!hasSend)
                    {
                        try
                        {
                            client.Send(mailmsg);
                            hasSend = true;
                        }
                        catch
                        {
                            hasSend = false;
                        }
                    }

                    AlertBox alert = new AlertBox("A test email has been sent to yourself", "");
                    alert.Show();
                    alert.HideButton();
                }
                catch
                {
                }
                reader.Close();
            }
        }
Esempio n. 2
0
 private void button5_Click(object sender, EventArgs e)
 {
     if (Aggregate_Report.Count() > 0)
     {
         Time_Graph graph = new Time_Graph(Aggregate_Report, last_button, from_date_text.Text, to_date_text.Text);
         graph.Show();
     }
     else
     {
         AlertBox alert = new AlertBox("Graph for current report invalid", "");
         alert.HideButton();
         alert.Show();
     }
 }
Esempio n. 3
0
        private void send_button_Click(object sender, EventArgs e)
        {
            if (nameBox.Text.Length > 5 && message_text.Text.Length > 0)
            {
                string important = "0";
                if (this.important.Checked)
                {
                    important = "1";
                }

                // Get first name/last name of from_employee
                string         query    = "select firstname, lastname from d_user where employeenumber = '" + this.employeenumber + "'";
                ExcoODBC       database = ExcoODBC.Instance;
                OdbcDataReader reader;
                database = ExcoODBC.Instance;
                database.Open(Database.DECADE_MARKHAM);
                reader = database.RunQuery(query);
                reader.Read();
                string from_first = reader[0].ToString().Trim();
                string from_last  = reader[1].ToString().Trim();
                reader.Close();

                // Get first name/last name of to_employee
                string to_employee_number = (nameBox.Text.Substring(nameBox.Text.Length - 6, 5));
                query    = "select firstname, lastname from d_user where employeenumber = '" + to_employee_number + "'";
                database = ExcoODBC.Instance;
                database.Open(Database.DECADE_MARKHAM);
                reader = database.RunQuery(query);
                reader.Read();
                string to_first = reader[0].ToString().Trim();
                string to_last  = reader[1].ToString().Trim();
                reader.Close();

                Console.WriteLine(to_employee_number);
                query = "insert into internalpaging_old (FromEmp, FromF, FromL, ToEmp, ToF, ToL, Msg, Pagingtime, Status, RepStatus, Important, ForceToReply) values" +
                        " (" + employeenumber + ", '" + from_first + "', '" + from_last + "', " + to_employee_number + ", '" + to_first + "', '" + to_last + "', '"
                        + parse_message(message_text.Text) + "', '" + DateTime.Now.ToString() + "', 1, 0, " + important + ", 0)";
                Console.WriteLine(query);
                database = ExcoODBC.Instance;
                database.Open(Database.DECADE_MARKHAM);
                reader = database.RunQuery(query);
                reader.Close();
            }
            AlertBox alert = new AlertBox("Page sent", "");

            alert.HideButton();
            alert.Show();
            close_button.PerformClick();
        }
Esempio n. 4
0
 private void between_button_Click(object sender, EventArgs e)
 {
     if (!(DateTime.ParseExact(from_date, "MM/dd/yyyy", null) > DateTime.ParseExact(to_date, "MM/dd/yyyy", null)))
     {
         last_button      = "between";
         Aggregate_Report = _parent.Get_Aggregate_Report(from_date, to_date);
         Create_Table();
     }
     else
     {
         AlertBox alert = new AlertBox("Invalid date entry", "");
         alert.HideButton();
         alert.Show();
     }
 }
Esempio n. 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool g = _parent.Delete_Report(delete_report_name_text.Text);

            if (!g)
            {
                AlertBox alert = new AlertBox("Report not found or cannot be deleted", "");
                alert.HideButton();
                alert.Show();
            }
            else
            {
                refresh_button.PerformClick();
            }
        }
Esempio n. 6
0
 private void admin_button_Click(object sender, EventArgs e)
 {
     if (!admin_task_box && (employee_box_name == "10577" || employee_box_name == "10403" || employee_box_name == "10178" || employee_box_name == "10100"))
     {
         admin_task_box = true;
         Administrative form = new Administrative(this);
         form.Show();
     }
     else
     {
         AlertBox alert = new AlertBox("ERROR: You are not an admin.", "");
         alert.HideButton();
         alert.Show();
     }
 }
Esempio n. 7
0
        // Validate login information and open messenger
        private void login_button_Click(object sender, EventArgs e)
        {
            int check_Value = check_directories();

            if (check_Value == 0)
            {
                if (checkPassword(employee_box.Text, password_box.Text) && !IsLoggedIn(employee_box.Text))
                {
                    // Try to check active, if not insert instead of update
                    string         query    = "select * from d_active where employeenumber = '" + employee_box.Text + "'";
                    ExcoODBC       database = ExcoODBC.Instance;
                    OdbcDataReader reader;
                    database.Open(Database.DECADE_MARKHAM);
                    reader = database.RunQuery(query);
                    reader.Read();
                    try
                    {
                        Console.WriteLine(reader[0].ToString());
                        reader.Close();
                        query = "update d_active set active = '1', lastactive = '" + DateTime.Now.ToString() + "' where employeenumber = '" + employee_box.Text + "'";
                        database.Open(Database.DECADE_MARKHAM);
                        reader = database.RunQuery(query);
                    }
                    catch
                    {
                        reader.Close();
                        query = "insert into d_active (employeenumber, active, lastactive) values ('" + employee_box.Text + "', '1', '" + DateTime.Now.ToString() + "')";
                        database.Open(Database.DECADE_MARKHAM);
                        reader = database.RunQuery(query);
                    }
                    reader.Close();
                    this.Visible = false;
                    // GRANT ACCESS
                    //messenger form = new messenger(employee_box.Text);
                    Main form = new Main(employee_box.Text);
                    form.Show();
                }
                else if (!checkPassword(employee_box.Text, password_box.Text))
                {
                    error_text.Visible = true;
                    password_box.Clear();
                }
                else
                {
                    logged_in_text.Visible = true;
                    //password_box.Clear();
                    //employee_box.Clear();
                    //System.Threading.Thread.Sleep(6500);
                    System.Threading.Thread.Sleep(500);
                    login_button.PerformClick();
                }
            }
            else
            {
                if (check_Value == 1)
                {
                    AlertBox alert = new AlertBox("Missing S: Drive. Please map 10.0.0.8\\SHOPDATA to S: to continue", "");
                    alert.HideButton();
                    alert.Show();
                }
                else if (check_Value == 2)
                {
                    AlertBox alert = new AlertBox("Missing T: Drive. Please map 10.0.0.8\\SHOPDATA to T: to continue", "");
                    alert.HideButton();
                    alert.Show();
                }
                else if (check_Value == 3)
                {
                    AlertBox alert = new AlertBox("Missing Z: Drive. Please map FILESRV\\sdrive to Z: to continue", "");
                    alert.HideButton();
                    alert.Show();
                }
            }
        }
Esempio n. 8
0
        private void Process_Files()
        {
            foreach (string file_path in File_Array)
            {
                bool Process = true;
                // REPORT REMOVAL //_parent.Main_Update_Transition_Data("PROCESSOR_BOLSTER_AUTOLATHE", (_parent.Get_Transition_Data_Value("PROCESSOR_BOLSTER_AUTOLATHE") + 1).ToString(), true);
                running_count++;
                try
                {
                    buffer_text.AppendText("Processing file: " + file_path.Substring(file_path.Length - 10, 10) + "\r\n");
                    var      text          = File.ReadAllText(file_path);
                    string[] lines         = text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                    string   bolster_type  = lines[0].Trim();
                    string   customer_code = lines[1].Trim();
                    string   hollow_dia    = "0;";

                    try
                    {
                        hollow_dia = lines[3].Trim();
                    }
                    catch { }
                    if (customer_code.Length == 4)
                    {
                        customer_code = "0" + customer_code;
                    }
                    string bolster_size = "";
                    foreach (char c in lines[2])
                    {
                        if (!(c.ToString() == " "))
                        {
                            bolster_size = bolster_size + c.ToString();
                        }
                    }
                    string query              = "";
                    string SO_number          = Path.GetFileName(file_path).Substring(0, 6);
                    string target_path        = "\\\\10.0.0.8\\shopdata\\LDATA\\" + SO_number + "LDCRV.txt";
                    string log_path           = "\\\\10.0.0.8\\shopdata\\TURN\\BOL\\LOG\\" + SO_number + ".log";
                    string log_path2          = "\\\\10.0.0.8\\shopdata\\TURN\\BOL\\BOL_MODEL\\" + SO_number + ".txt";
                    string COL_log_path       = "V:\\TURN\\BOL\\BOL_MODEL\\" + SO_number + ".txt";
                    string BR_log_path        = "W:\\TURN\\BOL\\BOL_MODEL\\" + SO_number + ".txt";
                    string error_path         = "\\\\10.0.0.8\\shopdata\\TURN\\BOL\\BOL_ERROR\\" + SO_number + ".txt";
                    bool   valid_chamfer_size = true;
                    try
                    {
                        if (bolster_type.Contains("HOLDER"))
                        {
                            Process = false;
                        }
                        else if (bolsters.Contains(bolster_type)) // If bolster
                        {
                            buffer_text.AppendText("     -> Bolster found\r\n");
                            query = "select * from d_autolathebo where customercode = '" + customer_code + "' and bolsize = '" + bolster_size + "'";
                        }
                        else if (sub_Bolster.Contains(bolster_type))
                        {
                            buffer_text.AppendText("     -> Sub Bolster found\r\n");
                            query = "select * from d_autolathebo_sub where customercode = '" + customer_code + "' and bolsize = '" + bolster_size + "'";
                        }

                        /*
                         * else if (hollow_dia == "0" || hollow_dia == "0.0")
                         * {
                         *  buffer_text.AppendText("     -> (Sub)-Bolster found\r\n");
                         *  buffer_text.AppendText("     -> Error: Not turned because hollow value = 0\r\n");
                         *  //buffer_text.AppendText("     -> since 4/16/2015 \r\n");
                         * }*/
                        if (Process)
                        {
                            ExcoODBC       database = ExcoODBC.Instance;
                            OdbcDataReader reader;
                            database.Open(Database.DECADE_MARKHAM);
                            reader = database.RunQuery(query);
                            reader.Read();
                            if (reader["std"].ToString() == "1")
                            {
                                string[] dimension = new string[5];
                                if (bolsters.Contains(bolster_type)) // If bolster
                                {
                                    dimension = calculate_dimensions(
                                        reader[2].ToString().Trim(),
                                        reader[3].ToString().Trim(),
                                        reader[6].ToString().Trim(),
                                        reader[7].ToString().Trim(),
                                        reader[8].ToString().Trim(),
                                        reader[9].ToString().Trim(),
                                        hollow_dia                     //"0" // No hollow dia
                                        );
                                }
                                else if (sub_Bolster.Contains(bolster_type))
                                {
                                    dimension = calculate_dimensions(
                                        reader[2].ToString().Trim(),
                                        reader[3].ToString().Trim(),
                                        reader[6].ToString().Trim(),
                                        reader[7].ToString().Trim(),
                                        reader[8].ToString().Trim(),
                                        reader[9].ToString().Trim(),
                                        hollow_dia                     //reader[10].ToString().Trim()
                                        );
                                }

                                // Gidda 9/30 do not process chamfers with size greater than 5mm
                                if (Convert.ToDouble(reader[6]) > 5 || Convert.ToDouble(reader[7]) > 5)
                                {
                                    // Gidda 11/09 do not process if chamfer > 5 and diameter less than 400
                                    // Gidda 11/26/2015 Do not process if chamfer angle greater than 30 deg
                                    if (Convert.ToDouble(reader[2].ToString().Trim()) < 399 && Convert.ToDouble(reader[8].ToString().Trim()) > 30)
                                    {
                                        valid_chamfer_size = false;
                                    }
                                }


                                // If dia > 400mm and thk > 160, automark BIG LATHE // Gidda 10/16/2015
                                if ((Convert.ToDouble(reader[2].ToString()) > 392 && (Convert.ToDouble(reader[3].ToString()) > 160)))
                                {
                                    _AUTO_BIG_LATHE = true;
                                }
                                else
                                {
                                    _AUTO_BIG_LATHE = false;
                                }

                                reader.Close();
                                buffer_text.AppendText("     -> Processing...\r\n");
                                buffer_text.AppendText("     -> Customer: " + customer_code + "   Bolster: " + bolster_size + "\r\n");
                                buffer_text.AppendText("     -> Bolster Hollow Diameter: " + hollow_dia + "\r\n");
                                if (!File.Exists(target_path) && (valid_chamfer_size))
                                {
                                    string processor = process_to_output(SO_number, dimension);
                                    using (StreamWriter sw = File.CreateText(target_path)) // Create LDATA file
                                    {
                                        sw.Write(processor);
                                        sw.Close();
                                    }
                                    using (StreamWriter sw = File.CreateText(log_path)) // Create LOG file
                                    {
                                        sw.Write(bolster_type + "\r\n" + customer_code + "\r\n" + bolster_size + "\r\n" + "Hollow Diameter: " + hollow_dia + "\r\n\r\n" + processor);
                                        sw.Close();
                                    }
                                    using (StreamWriter sw = File.CreateText(log_path2)) // Create LOG file
                                    {
                                        sw.Write(bolster_type + "\r\n" + customer_code + "\r\n" + bolster_size + "\r\n" + hollow_dia + "\r\n\r\n" + processor);
                                        sw.Close();
                                    }
                                    // TRANSFER TO BRZ/COL
                                    try
                                    {
                                        using (StreamWriter sw = File.CreateText(COL_log_path)) // Create LOG file
                                        {
                                            sw.Write(bolster_type + "\r\n" + customer_code + "\r\n" + bolster_size + "\r\n" + "Hollow Diameter: " + hollow_dia + "\r\n\r\n" + processor);
                                            sw.Close();
                                        }

                                        using (StreamWriter sw = File.CreateText(BR_log_path)) // Create LOG file
                                        {
                                            sw.Write(bolster_type + "\r\n" + customer_code + "\r\n" + bolster_size + "\r\n" + "Hollow Diameter: " + hollow_dia + "\r\n\r\n" + processor);
                                            sw.Close();
                                        }
                                    }
                                    catch
                                    {
                                    }
                                }
                                else
                                {
                                    buffer_text.AppendText("      -> Does not fit Gidda's criteria for automation. Please manually program");
                                }
                            }
                            else
                            {
                                buffer_text.AppendText("     -> Invalid Chamfer dimension, file not processed!\r\n");
                            }
                            buffer_text.AppendText("     -> Finished!\r\n");
                        }
                        else
                        {
                            File.Move(file_path, log_path2);
                        }
                    }
                    catch
                    {
                        try
                        {
                            File.Delete(error_path);
                            File.Copy(file_path, error_path);
                            buffer_text.AppendText("     -> *** Error on file, invalid information ***\r\n");
                            buffer_text.AppendText("     -> Customer: " + customer_code + "   Bolster: " + bolster_size + "\r\n");
                            AlertBox alert = new AlertBox("Invalid bolster error on file: " + file_path, "");
                            alert.HideButton();
                            alert.Show();
                        }
                        catch { }
                    }
                    buffer_text.SelectionStart = buffer_text.Text.Length;
                    buffer_text.ScrollToCaret();
                    File.Delete(file_path);
                    count_text.Text = "Files processed: " + running_count.ToString();
                    count_text.Refresh();


                    // TRANSFER TO BRZ/COL
                    try
                    {
                        using (StreamWriter sw = File.CreateText(COL_log_path)) // Create LOG file
                        {
                            sw.Write(bolster_type + "\r\n" + customer_code + "\r\n" + bolster_size + "\r\n" + "Hollow Diameter: " + hollow_dia);
                            sw.Close();
                        }

                        using (StreamWriter sw = File.CreateText(BR_log_path)) // Create LOG file
                        {
                            sw.Write(bolster_type + "\r\n" + customer_code + "\r\n" + bolster_size + "\r\n" + "Hollow Diameter: " + hollow_dia);
                            sw.Close();
                        }
                    }
                    catch
                    {
                    }
                }
                catch { }
            }
        }
Esempio n. 9
0
        private void send_button_Click(object sender, EventArgs e)
        {
            if (to_text.Text.Length > 3)
            {
                get_email_list(to_text.Text);
                if (Email_List.Count > 0)
                {
                    string         query    = "select * from d_active where employeenumber = '" + this.current_employeenumber + "'";
                    ExcoODBC       database = ExcoODBC.Instance;
                    OdbcDataReader reader;
                    database.Open(Database.DECADE_MARKHAM);
                    reader = database.RunQuery(query);
                    try
                    {
                        reader.Read();
                        Encrypter @str         = new Encrypter();
                        string    my_email     = @str.Decrypt(reader[3].ToString().Trim());
                        string    my_pw        = @str.Decrypt(reader[4].ToString().Trim());
                        string    my_smtp      = reader[5].ToString().Trim();
                        int       my_smtp_port = Convert.ToInt32(reader[7].ToString().Trim());
                        string    my_sig       = @str.Decrypt(reader[9].ToString().Trim());
                        foreach (string email in Email_List)
                        {
                            if (email.Contains("@") && email.Contains("."))
                            {
                                mailmsg.To.Add(email);
                            }
                        }
                        reader.Close();
                        MailAddress from = new MailAddress(my_email);
                        mailmsg.From    = from;
                        mailmsg.Subject = subject_text.Text;
                        mailmsg.Body    = message_text.Text + "\r\n\r\n" + my_sig;
                        SmtpClient        client     = new SmtpClient(my_smtp, my_smtp_port);
                        NetworkCredential credential = new NetworkCredential(my_email, my_pw);
                        client.Credentials = credential;

                        bool hasSend = false;
                        while (!hasSend)
                        {
                            try
                            {
                                client.Send(mailmsg);
                                hasSend = true;
                            }
                            catch
                            {
                                hasSend = false;
                            }
                        }
                        AlertBox alert = new AlertBox("Message sent.", "");
                        alert.Show();
                        alert.HideButton();
                        Visible = false;
                        Dispose();
                        Close();
                    }
                    catch
                    {
                        reader.Close();
                    }
                }
            }
        }
Esempio n. 10
0
        // Update each progress bar with the number of files (progressive; each file = 5x value)
        internal void UpdateProgress(int progress)
        {
            if (InvokeRequired)
            {
                Invoke(new Action <int>(UpdateProgress), new object[] { progress });
                return;
            }

            ticks++;

            if (ticks < 30)
            {
                /*string g = "select partno, unit_price, unit, date, plant, C.JRDES1 as DESCRIPTION, C.JRVND# from " +
                 * "(select a.KBVPT# as PartNO, a.KBUPRC as UNIT_Price, a.KBPUNT as UNIT, a.KBRDAT as " +
                 * "DATE, a.KBPLNT as PLANT from cmsdat.poi as a) as A, cmsdat.poptvn as c where partno=c.jrvpt# and partno <> '' and " + "upper(c.jrdes1) like upper('%" + "" + "%')  and plant = '" + "001" + "' " +
                 * "and date between " + "'2011-04-04'" + " and " + "'2016-04-04'" + " order by plant asc";*/
                //Console.WriteLine(g);
            }

            if (ticks % 239 == 0)
            {
                // REPORT REMOVAL //report.Log_update();
                if (Convert.ToInt32(DateTime.Now.Hour) == 23 && Convert.ToInt32(DateTime.Now.Minute) > 55)
                {
                    Console.WriteLine("###Clearing###");
                    // REPORT REMOVAL //report.Clear_Report_Entries();
                }
            }

            if (ticks % 500 == 0)
            {
                Retrieve_Files("\\\\10.0.0.8\\shopdata\\sonum\\");
                execute_prevso();
                Console.WriteLine("Tick tick");
                last_ldata_check = 0;
            }

            if (ticks % 10000 == 0)
            {
                last_checked = 0;
            }

            if (ticks > last_checked && p2 > 40)
            {
                string date_string = "";
                if (DateTime.Now.Minute.ToString().Length == 1)
                {
                    date_string = "[" + DateTime.Now.Hour.ToString() + ":0" + DateTime.Now.Minute.ToString() + "]";
                }
                else
                {
                    date_string = "[" + DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + "]";
                }
                // REPORT REMOVAL //Main_Update_Transition_Data("LDATA_QUEUE_ERROR", date_string, false);
                last_checked = last_checked + 3600;
            }

            /*
             * if (ticks % 5 == 0 || ticks == 21)
             * {
             *
             *  p1 = count_files("\\\\10.0.0.8\\shopdata\\ACCT\\CMDS\\");
             * */
            p2 = count_files("\\\\10.0.0.8\\shopdata\\LDATA\\");
            if (ticks % 40 == 0 && p2 > 30 && last_ldata_check == 0)
            //if (p2 > 30)
            {
                ExcoODBC       database = ExcoODBC.Instance;
                OdbcDataReader reader;
                database.Open(Database.DECADE_MARKHAM);
                last_ldata_check = 1;
                string query = "insert into internalpaging_old (FromEmp, FromF, FromL, ToEmp, ToF, ToL, Msg, Pagingtime, Status, RepStatus, Important, ForceToReply) values" +
                               " (" + "'10403'" + ", '" + "PAGER" + "', '" + ",''" + "', " + "10577" + ", '" + "Robin" + "', '" + "" + "', '"
                               + "LDATA QUEUE ERROR. CHECK SANGKOO MACHINE TO SEE IF IT STILL PROCESSING" + "', '" + DateTime.Now.ToString() + "', 1, 0, " + "0" + ", 0)";

                reader = database.RunQuery(query);
                reader.Close();

                database.Open(Database.DECADE_MARKHAM);
                last_ldata_check = 1;
                query            = "insert into internalpaging_old (FromEmp, FromF, FromL, ToEmp, ToF, ToL, Msg, Pagingtime, Status, RepStatus, Important, ForceToReply) values" +
                                   " (" + "'10403'" + ", '" + "PAGER" + "', '" + ",''" + "', " + "10403" + ", '" + "Gary" + "', '" + "" + "', '"
                                   + "LDATA QUEUE ERROR. CHECK SANGKOO MACHINE TO SEE IF IT STILL PROCESSING" + "', '" + DateTime.Now.ToString() + "', 1, 0, " + "0" + ", 0)";

                reader = database.RunQuery(query);
                reader.Close();
            }

            if (false)//(ticks % 2000 == 0 || ticks == 22) //20 seconds
            {
                // Alert for unread messages
                if (has_unread_messages(this.employee_box_name))
                {
                    //FlashWindowEx(this);
                }

                // Check if still active remotely
                string         query    = "select * from d_active where employeenumber = '" + employee_box_name + "' and active = '0'";
                ExcoODBC       database = ExcoODBC.Instance;
                OdbcDataReader reader;
                database.Open(Database.DECADE_MARKHAM);
                reader = database.RunQuery(query);
                reader.Read();
                try
                {
                    Console.WriteLine(reader[0].ToString());
                    AlertBox LA = new AlertBox("Logged in at another location. Logging off", "");
                    LA.HideButton();
                    LA.Show();
                    reader.Close();
                    close_button.PerformClick();
                    //return true;
                }
                catch
                {
                    reader.Close();
                    //return false;
                }



                // Check if threads are active or not
                query = "select * from d_active where BLS_AL_active = '1'";
                database.Open(Database.DECADE_MARKHAM);
                reader = database.RunQuery(query);
                reader.Read();
                try
                {
                    Console.WriteLine(reader[0].ToString().Trim());
                    BLS_AL_active_text.Text      = "Active";
                    BLS_AL_active_text.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(10)))), ((int)(((byte)(200)))), ((int)(((byte)(10)))));
                    BLS_AL_active_text.Visible   = true;
                }
                catch
                {
                    BLS_AL_active_text.Text      = "Inactive";
                    BLS_AL_active_text.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(200)))), ((int)(((byte)(10)))), ((int)(((byte)(10)))));
                    BLS_AL_active_text.Visible   = true;
                }
                reader.Close();

                // Check if threads are active or not
                query = "select * from d_active where CAD_print_processor_active = '1'";
                database.Open(Database.DECADE_MARKHAM);
                reader = database.RunQuery(query);
                reader.Read();
                try
                {
                    Console.WriteLine(reader[0].ToString().Trim());
                    cad_print_active_text.Text      = "Active";
                    cad_print_active_text.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(10)))), ((int)(((byte)(200)))), ((int)(((byte)(10)))));
                    cad_print_active_text.Visible   = true;
                }
                catch
                {
                    cad_print_active_text.Text      = "Inactive";
                    cad_print_active_text.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(200)))), ((int)(((byte)(10)))), ((int)(((byte)(10)))));
                    cad_print_active_text.Visible   = true;
                }
                reader.Close();

                // Check if threads are active or not
                query = "select * from d_active where turn_checker_active = '1'";
                database.Open(Database.DECADE_MARKHAM);
                reader = database.RunQuery(query);
                reader.Read();
                try
                {
                    Console.WriteLine(reader[0].ToString().Trim());
                    turn_check_active.Text      = "Active";
                    turn_check_active.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(10)))), ((int)(((byte)(200)))), ((int)(((byte)(10)))));
                    turn_check_active.Visible   = true;
                }
                catch
                {
                    turn_check_active.Text      = "Inactive";
                    turn_check_active.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(200)))), ((int)(((byte)(10)))), ((int)(((byte)(10)))));
                    turn_check_active.Visible   = true;
                }
                reader.Close();

                // Check if threads are active or not
                query = "select * from d_active where task_tracker_active = '1'";
                database.Open(Database.DECADE_MARKHAM);
                reader = database.RunQuery(query);
                reader.Read();
                try
                {
                    Console.WriteLine(reader[0].ToString().Trim());
                    task_tracker_active.Text      = "Active";
                    task_tracker_active.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(10)))), ((int)(((byte)(200)))), ((int)(((byte)(10)))));
                    task_tracker_active.Visible   = true;
                }
                catch
                {
                    task_tracker_active.Text      = "Inactive";
                    task_tracker_active.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(200)))), ((int)(((byte)(10)))), ((int)(((byte)(10)))));
                    task_tracker_active.Visible   = true;
                }
                reader.Close();


                // Check if threads are active or not
                query = "select * from d_active where on_hold_active = '1'";
                database.Open(Database.DECADE_MARKHAM);
                reader = database.RunQuery(query);
                reader.Read();
                try
                {
                    Console.WriteLine(reader[0].ToString().Trim());
                    on_hold_active.Text      = "Active";
                    on_hold_active.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(10)))), ((int)(((byte)(200)))), ((int)(((byte)(10)))));
                    on_hold_active.Visible   = true;
                }
                catch
                {
                    on_hold_active.Text      = "Inactive";
                    on_hold_active.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(200)))), ((int)(((byte)(10)))), ((int)(((byte)(10)))));
                    on_hold_active.Visible   = true;
                }
                reader.Close();
            }


            if (false)//ticks > 21)
            {
                //if (ticks % 10 == 0) ping_average = 0;


                cpuCounter = new PerformanceCounter();
                cpuCounter.CategoryName = "Processor";
                cpuCounter.CounterName  = "% Processor Time";
                cpuCounter.InstanceName = "_Total";

                Ping      ping    = new Ping();
                IPAddress address = IPAddress.Loopback;
                PingReply reply   = ping.Send("10.0.0.24");
                double    pingz   = 1;
                if (reply.Status == IPStatus.Success)
                {
                    ping1_text.Text = "Ping: " + reply.RoundtripTime.ToString() + "ms";
                    pingz           = pingz + Convert.ToDouble(reply.RoundtripTime.ToString());
                    if (pingz > 9)
                    {
                        pingz = 9;
                    }
                    else if (pingz - 1 > ping_tolerance)
                    {
                        string date_string = "";
                        if (DateTime.Now.Minute.ToString().Length == 1)
                        {
                            date_string = "[" + DateTime.Now.Hour.ToString() + ":0" + DateTime.Now.Minute.ToString() + "]";
                        }
                        else
                        {
                            date_string = "[" + DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString() + "]";
                        }
                        // REPORT REMOVAL //Main_Update_Transition_Data("PING_SPIKE", date_string, false);
                    }
                    else if (pingz - 1 > 0)
                    {
                        non_zero_ticks++;
                        non_zero_ping_average = non_zero_ping_average + pingz;
                    }
                }
                else
                {
                    pingz = 9;
                }
                avg_ping.Text = "Avg Ping (Non-zero): " + Math.Round((non_zero_ping_average / ((non_zero_ticks))), 2) + "ms";
                cpuCounter.NextValue();
                double gs = Convert.ToDouble(cpuCounter.NextValue()) / 18;
                chart1.Series["Series2"].Points.AddXY(ticks, gs + 1.5);
                chart1.Series["Series3"].Points.AddXY(ticks, rnd.Next(1, 90) / 10);
                cpu_text.Text = "CPU Usage: " + Math.Round(gs * 3, 2) + "%";

                chart1.Series["Series1"].Points.AddXY(ticks, pingz);
                if (chart1.ChartAreas[0].AxisX.Maximum > chart1.ChartAreas[0].AxisX.ScaleView.Size)
                {
                    chart1.ChartAreas[0].AxisX.ScaleView.Scroll(chart1.ChartAreas[0].AxisX.Maximum);
                }
            }
        }