public QueuingClient()
        {
            InitializeComponent();
            /* The Employee ID/Cubicle Number will be displayed on the lower left hand corner*/
            cubID.Text = Emp.empId.ToString();
            /* Get the last number of the cubicle (on startup) */
            using (MySqlConnection mysqlCon = new MySqlConnection(@"Server=" + ip + ";Database=osa_queuing;Uid=root;Pwd=;"))
            {
                try
                {
                    mysqlCon.Open();
                    currentNumber.Text = QueueDB.getLastServed(Emp.empId.ToString(), mysqlCon);
                }
                catch (MySqlException)
                {
                    MessageBox.Show("You have disconnected from the server.", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }
            }
            /* Check if there are recalled records as of today (on startup). See the method below. */
            FirstCheck();

            SecondCheck();

            ThirdCheck();
        }
示例#2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            MySqlConnection mysqlCon = new MySqlConnection(@"Server=" + ip + ";Database=osa_queuing;Uid=root;Pwd=;");

            try
            {
                mysqlCon.Open();
                l = QueueDB.gatherData(mysqlCon);
                string sr = DateTime.Now.ToString("h:mm tt yyyy-MM-dd");
                DateLabel.Text = sr;
                foreach (QueueStat c in l)
                {
                    x = c.getCubicleNumber();
                    y = c.getServingNumber().ToString();
                }
                checkLastNumbers();
                servingNumber.ForeColor = servingNumber.ForeColor == Color.White ? blinker : Color.White;
                cubicleNumber.Text      = "Cubicle " + x.ToString();
                servingNumber.Text      = y;
                mysqlCon.Close();
            }
            catch (Exception ex)
            {
                timer1.Stop();
                MessageBox.Show("The connection to the database server has either terminated abruptly or it doesn't exist.", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }
        }
 /* Previous Button Method. Type - "transfer" record from main table (queue_stat) to temporary table via SPs */
 private void PrevButton_Click(object sender, EventArgs e)
 {
     using (MySqlConnection mysqlCon = new MySqlConnection(@"Server=" + ip + ";Database=osa_queuing;Uid=root;Pwd=;"))
     {
         try
         {
             mysqlCon.Open();
             InsertToRecall(Emp.empId);
             currentNumber.Text = QueueDB.getLastServed(Emp.empId.ToString(), mysqlCon);
             FirstCheck();
             SecondCheck();
         }
         catch (Exception)
         {
             MessageBox.Show("You have disconnected from the server.", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             Application.Exit();
         }
     }
 }
        /* Main Buttons */
        /* Call a Student Method. Type - insert into DB */
        private async void callStudent_Click(object sender, EventArgs e)
        {
            using (MySqlConnection mysqlCon = new MySqlConnection(@"Server=" + ip + ";Database=osa_queuing;Uid=root;Pwd=;"))
            {
                string query = "SELECT * FROM osa_queuing.queue_stat WHERE date(timestamp) = date(now()) AND deact_flag = 0 UNION SELECT *, 0 FROM recalled_records WHERE date(timestamp) = date(now()) ORDER BY timestamp DESC Limit 1;";
                try
                {
                    callStudent.Enabled = false;
                    mysqlCon.Open();
                    l = QueueDB.gatherData(mysqlCon, query);
                    foreach (QueueStat cd in l)
                    {
                        currNumber = cd.getServingNumber() + 1;
                        if (currNumber == 71)
                        {
                            currNumber = 1;
                        }
                        //newNumber = currNumber.ToString();
                    }
                    //DateTime c = new DateTime(DateTimeOffset.Now.ToUnixTimeMilliseconds());
                    DateTime c = new DateTime(DateTime.Now.Ticks);

                    QueueStat qs = new QueueStat(Emp.empId, currNumber, c);
                    mysqlCon.Open();
                    QueueDB.addQueue(qs);
                    currentNumber.Text = QueueDB.getLastServed(Emp.empId.ToString(), mysqlCon);
                    FirstCheck();
                    await TaskEx.Delay(3000);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }
                finally
                {
                    callStudent.Enabled = true;
                }
            }
        }
 private void activateToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (MySqlConnection mysqlCon = new MySqlConnection(@"Server=" + ip + ";Database=osa_queuing;Uid=root;Pwd=;"))
     {
         try
         {
             mysqlCon.Open();
             ActivateCubicle(Emp.empId);
             DeleteFromMultRecall(Emp.empId);
             ThirdCheck();
             currentNumber.Text = QueueDB.getLastServed(Emp.empId.ToString(), mysqlCon);
         }
         catch (Exception)
         {
             MessageBox.Show("You have disconnected from the server.", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             Application.Exit();
         }
         finally
         {
             mysqlCon.Close();
         }
     }
 }
        private void timer1_Tick(object sender, EventArgs e)
        {
            MySqlConnection mysqlCon = new MySqlConnection(@"Server=" + ip + ";Database=osa_queuing;Uid=root;Pwd=;");

            try
            {
                mysqlCon.Open();
                l = QueueDB.gatherData(mysqlCon);
                foreach (QueueStat c in l)
                {
                    x = c.getCubicleNumber();
                    y = c.getServingNumber().ToString();
                }
                checkLastNumbers(x);

                servingNumber.Text = y;
                mysqlCon.Close();
            }catch (Exception ex)
            {
                timer1.Stop();
                MessageBox.Show("The connection to the database server has either terminated abruptly or it doesn't exist.", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
        }