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."); } }
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."); } } }