Exemplo n.º 1
0
        private void staffIDcomboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            DBConnector dbCon = new DBConnector();

            dbCon.connect();

            if (staffIDcomboBox.SelectedIndex != 0)
            {
                StaffSchedulerHandler staffhnd = new StaffSchedulerHandler();
                Schedule newschedule           = new Schedule();
                newschedule           = staffhnd.getSpecificSchedule(dbCon.getConn(), staffIDcomboBox.SelectedItem.ToString());
                firstNameTextBox.Text = newschedule.FirstName.ToString();
                lastNameTextBox.Text  = newschedule.LastName.ToString();
                dateBox.Text          = newschedule.TodayDate.ToString();

                if (newschedule.DutyStatus == "On")
                {
                    dutyStatusBox.Text             = "On";
                    dataOnDutyGridView.DataSource  = staffhnd.getOnScheduleStatus(dbCon.getConn(), 0);
                    dataOffDutyGridView.DataSource = staffhnd.getOffScheduleStatus(dbCon.getConn(), 0);
                }
                else
                {
                    dutyStatusBox.Text = "Off";
                }
            }
        }
Exemplo n.º 2
0
        public StaffSchedule()
        {
            DBConnector dbConn = new DBConnector();

            dbConn.connect();
            InitializeComponent();
            StaffSchedulerHandler schedulerHandler = new StaffSchedulerHandler();

            dataOnDutyGridView.DataSource  = schedulerHandler.getOnScheduleStatus(dbConn.getConn(), 0);
            dataOffDutyGridView.DataSource = schedulerHandler.getOffScheduleStatus(dbConn.getConn(), 0);
            schedulerHandler.FetchStaffId(staffIDcomboBox);
            //PatientHandler patientHandler = new PatientHandler();
            //dataOffDutyGridView.DataSource = patientHandler.getAllPatient(dbConn.getConn());
        }
Exemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(staffIDcomboBox.Text))
            {
                MessageBox.Show("Please enter a valid staff id");
                return;
            }

            if (string.IsNullOrEmpty(firstNameTextBox.Text))
            {
                MessageBox.Show("Please enter a valid first name");
                return;
            }

            if (string.IsNullOrEmpty(lastNameTextBox.Text))
            {
                MessageBox.Show("Please enter a valid last name");
                return;
            }

            Schedule schedule = new Schedule();

            schedule.StaffId = staffIDcomboBox.SelectedItem.ToString();

            schedule.TodayDate  = dateBox.Value;
            schedule.DutyStatus = dutyStatusBox.Text;

            DBConnector dbCon = new DBConnector();

            dbCon.connect();
            StaffSchedulerHandler staffhnd = new StaffSchedulerHandler();
            int result = staffhnd.updateSchedule(dbCon.getConn(), schedule, staffIDcomboBox.SelectedItem.ToString());

            if (result == 1)
            {
                MessageBox.Show("Update Successfully");
                dataOnDutyGridView.DataSource  = staffhnd.getOnScheduleStatus(dbCon.getConn(), 0);
                dataOffDutyGridView.DataSource = staffhnd.getOffScheduleStatus(dbCon.getConn(), 0);
            }
            else
            {
                MessageBox.Show("Update Failed");
            }
        }