private void button10_Click(object sender, EventArgs e) { if (label41.ForeColor == Color.Green && (comboBox7.SelectedItem).ToString() != "- SELECT -" && (comboBox8.SelectedItem).ToString() != "- SELECT -") { DbConnector dbConn = new DbConnector(); dbConn.connect(); OnShift oShift = new OnShift(); OnShiftHandler oShiftHnd = new OnShiftHandler(); oShift.StaffId = textBox21.Text; oShift.DateOnShift = (comboBox7.SelectedItem).ToString(); oShift.TimeOnShift = (comboBox8.SelectedItem).ToString(); oShift.DateAndTimeDeregistered = DateTime.Now.ToString(); bool deregistered = oShiftHnd.deregisterShift(dbConn.getConn(), oShift); if (deregistered == true) { MessageBox.Show("Shift date and time deregistered successfully !"); textBox21_TextChanged(null, e); dateTimePicker1_ValueChanged(null, e); } else { MessageBox.Show("Failed to register shift date and time..."); } } else { MessageBox.Show("Please insert valid information."); } }
public List <String> showTime(MySqlConnection conn, OnShift oShift) { List <String> listOfTime = new List <String>(); string sql = "SELECT timeOnShift FROM `onshift` WHERE staffId='" + oShift.StaffId + "' AND dateOnShift='" + oShift.DateOnShift + "' AND dateAndTimeDeregistered='-'"; MySqlCommand sqlComm = new MySqlCommand(sql, conn); using (MySqlDataReader sqlReader = sqlComm.ExecuteReader()) { listOfTime.Add("- SELECT -"); while (sqlReader.Read()) { OnShift ooShift = new OnShift(); ooShift.TimeOnShift = (string)sqlReader.GetValue(0); listOfTime.Add(ooShift.TimeOnShift); } } return(listOfTime); }
public List <OnShift> getOnCall(MySqlConnection conn, string getDate) { List <OnShift> listOfTimeSlots = new List <OnShift>(); string sql = "SELECT staffId, timeOnShift, dateAndTimeDeregistered FROM onshift WHERE dateOnShift='" + getDate + "'"; MySqlCommand sqlComm = new MySqlCommand(sql, conn); using (MySqlDataReader sqlReader = sqlComm.ExecuteReader()) { while (sqlReader.Read()) { OnShift mReadings = new OnShift(); mReadings.StaffId = (string)sqlReader.GetValue(0); mReadings.TimeOnShift = (string)sqlReader.GetValue(1); if ((string)sqlReader.GetValue(2) == "-") { mReadings.DateAndTimeDeregistered = "false"; } else { mReadings.DateAndTimeDeregistered = "True"; } listOfTimeSlots.Add(mReadings); } } return(listOfTimeSlots); }
public bool checkShift(MySqlConnection conn, OnShift oShift) { bool checkedTime = false; string sql = "SELECT staffId FROM onshift WHERE staffId='" + oShift.StaffId + "' AND dateOnShift='" + oShift.DateOnShift + "' AND " + "timeOnShift='" + oShift.TimeOnShift + "' AND dateAndTimeDeregistered='-'"; MySqlCommand sqlComm = new MySqlCommand(sql, conn); using (MySqlDataReader sqlReader = sqlComm.ExecuteReader()) { while (sqlReader.Read()) { if ((string)sqlReader.GetValue(0) != "") { checkedTime = true; } else { checkedTime = false; } } } return(checkedTime); }
public bool registerShift(MySqlConnection conn, OnShift oShift) { string sql = "INSERT INTO onshift (staffId, dateOnShift, timeOnShift, dateAndTimeRegistered, dateAndTimeDeregistered) " + "VALUES ('" + oShift.StaffId + "', '" + oShift.DateOnShift + "' ,'" + oShift.TimeOnShift + "' , '" + oShift.DateAndTimeRegistered + "', '" + oShift.DateAndTimeDeregistered + "')"; MySqlCommand sqlComm = new MySqlCommand(sql, conn); sqlComm.ExecuteNonQuery(); return(true); }
public bool deregisterShift(MySqlConnection conn, OnShift oShift) { Console.WriteLine(oShift.TimeOnShift); string sql = "UPDATE `onshift` SET `dateAndTimeDeregistered`='" + oShift.DateAndTimeDeregistered + "' WHERE `staffId`='" + oShift.StaffId + "' AND `dateOnShift` = '" + oShift.DateOnShift + "' AND" + "`timeOnShift` = '" + oShift.TimeOnShift + "'"; MySqlCommand sqlComm = new MySqlCommand(sql, conn); sqlComm.ExecuteNonQuery(); return(true); }
private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { CheckBox[] checkedList = new CheckBox[24] { checkBox1, checkBox2, checkBox3, checkBox4, checkBox5, checkBox6, checkBox12, checkBox11, checkBox10, checkBox9, checkBox8, checkBox7, checkBox24, checkBox23, checkBox22, checkBox21, checkBox20, checkBox19, checkBox18, checkBox17, checkBox16, checkBox15, checkBox14, checkBox13 }; if (textBox20.Text != "" && label36.ForeColor == Color.Green) { DbConnector dbConn = new DbConnector(); dbConn.connect(); OnShift oShift = new OnShift(); OnShiftHandler oShiftHnd = new OnShiftHandler(); for (int x = 0; x < checkedList.Count(); x++) { oShift.StaffId = textBox20.Text; oShift.DateOnShift = (dateTimePicker1.Value).ToString("dd/MM/yyyy"); oShift.TimeOnShift = checkedList[x].Text; bool registered = oShiftHnd.checkShift(dbConn.getConn(), oShift); if (registered == true) { checkedList[x].Checked = true; checkedList[x].Enabled = false; } else { checkedList[x].Checked = false; checkedList[x].Enabled = true; } } } else { for (int x = 0; x < checkedList.Count(); x++) { checkedList[x].Checked = false; checkedList[x].Enabled = false; } } }
private void textBox21_TextChanged(object sender, EventArgs e) { if (textBox21.Text == "") { label41.Text = "Validate Medical Staff ID"; label41.ForeColor = Color.Black; label41.Visible = false; comboBox7.Enabled = false; comboBox8.Enabled = false; } else { DbConnector dbConn = new DbConnector(); dbConn.connect(); MedicalStaffHandler mStaffHnd = new MedicalStaffHandler(); bool goCheckStaffId = mStaffHnd.checkStaffId(dbConn.getConn(), textBox21.Text); if (goCheckStaffId == true) { label41.Text = "Valid Staff ID"; label41.ForeColor = Color.Green; label41.Visible = true; comboBox7.Enabled = true; OnShift oShift = new OnShift(); OnShiftHandler oShiftHnd = new OnShiftHandler(); oShift.StaffId = textBox21.Text; comboBox7.DataSource = oShiftHnd.showDate(dbConn.getConn(), oShift); } else if (goCheckStaffId == false) { label41.Text = "Invalid Staff ID"; label41.ForeColor = Color.Red; label41.Visible = true; comboBox7.Enabled = false; comboBox8.Enabled = false; comboBox7.SelectedIndex = 0; comboBox8.SelectedIndex = 0; } } }
private void comboBox7_SelectedIndexChanged(object sender, EventArgs e) { if ((comboBox7.SelectedItem).ToString() != "- SELECT -") { comboBox8.Enabled = true; DbConnector dbConn = new DbConnector(); dbConn.connect(); OnShift oShift = new OnShift(); OnShiftHandler oShiftHnd = new OnShiftHandler(); oShift.StaffId = textBox21.Text; oShift.DateOnShift = (comboBox7.SelectedItem).ToString(); comboBox8.DataSource = oShiftHnd.showTime(dbConn.getConn(), oShift); } else { comboBox8.Enabled = false; comboBox8.SelectedIndex = 0; } }
private void button9_Click(object sender, EventArgs e) { CheckBox[] checkedList = new CheckBox[24] { checkBox1, checkBox2, checkBox3, checkBox4, checkBox5, checkBox6, checkBox12, checkBox11, checkBox10, checkBox9, checkBox8, checkBox7, checkBox24, checkBox23, checkBox22, checkBox21, checkBox20, checkBox19, checkBox18, checkBox17, checkBox16, checkBox15, checkBox14, checkBox13 }; bool isChecked = false; for (int x = 0; x < checkedList.Count(); x++) { if (checkedList[x].Checked == true) { isChecked = true; } } if (label36.ForeColor == Color.Green && isChecked == true) { DbConnector dbConn = new DbConnector(); dbConn.connect(); OnShift oShift = new OnShift(); OnShiftHandler oShiftHnd = new OnShiftHandler(); for (int x = 0; x < checkedList.Count(); x++) { if (checkedList[x].Checked == true && checkedList[x].Enabled == true) { oShift.StaffId = textBox20.Text; oShift.DateOnShift = (dateTimePicker1.Value).ToString("dd/MM/yyyy"); oShift.TimeOnShift = checkedList[x].Text; oShift.DateAndTimeRegistered = DateTime.Now.ToString(); oShift.DateAndTimeDeregistered = "-"; bool registered = oShiftHnd.registerShift(dbConn.getConn(), oShift); } } MessageBox.Show("Shift date and time registered successfully !"); for (int x = 0; x < checkedList.Count(); x++) { checkedList[x].Checked = false; } textBox21_TextChanged(null, e); dateTimePicker1_ValueChanged(null, e); } else { if (isChecked != true) { MessageBox.Show("Please select at least one time slot to continue."); } else { MessageBox.Show("Please insert valid staff's ID."); } } }