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(); }
/* 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(); } } }