示例#1
0
        private void bReschedule_Click(object sender, EventArgs e)
        {
            /* DataGridViewRow row = slots.CurrentRow;
             * dbAppointment app = new dbAppointment();
             * string date = row.Cells[1].Value.ToString();
             * string time = row.Cells[2].Value.ToString();
             *
             * int mrn = Convert.ToInt16(row.Cells[0].Value.ToString());
             * app.editAppointment(mrn, date, time);
             *
             * slots.Hide();
             * bReschedule.Visible = false;
             * button2.Visible = false;
             */
            DataGridViewRow row = slots.CurrentRow;
            dbAppointment   app = new dbAppointment();

            try
            {
                string date = row.Cells[1].Value.ToString();
                string time = row.Cells[2].Value.ToString();

                int mrn = Convert.ToInt16(row.Cells[0].Value.ToString());
                app.editAppointment(mrn, date, time);

                slots.Hide();
                bReschedule.Visible = false;
                button3.Visible     = false;
                button2.Visible     = false;
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show("There are no busy slots");
            }
        }
        public void checkBusySlots(DataGridView slots, string date)
        {
            //MessageBox.Show(date);
            dbAppointment d  = new dbAppointment();
            DataSet       ds = d.getSlots(date);

            slots.DataSource = ds.Tables["appointment"].DefaultView;
            slots.Show();
        }
        public bool scheduleAppointment()
        {
            dbAppointment app = new dbAppointment();

            if (app.storeAppointment(mrn, date, time))
            {
                return(true);
            }
            return(false);
        }
        public bool validateAppointmentForm(f_ScheduleAppointment app, string mrntext, string daytext, string monthtext, string yeartext, string hourtext, string mintext, string amorpmtext)//appointment form validation
        {
            if (mrntext == "" || daytext == "DD" || monthtext == "MM" || yeartext == "YYYY" || hourtext == "Hr" || mintext == "Min")
            {
                return(false);
            }
            else
            {
                dbAppointment db   = new dbAppointment();
                bool          flag = db.checkMrn(mrntext);
                if (flag == true)
                {
                    app.Hide();
                    bAppointment appoint = new bAppointment(mrntext, daytext, monthtext, yeartext, hourtext, mintext, amorpmtext);
                    if (appoint.scheduleAppointment())
                    {
                        MessageBox.Show("Appointment fixed");
                        f_ReceptionHome rec = new f_ReceptionHome();
                        rec.Show();
                    }

                    else
                    {
                        MessageBox.Show("Time slot already booked! Try again!");
                        f_ReceptionHome rec = new f_ReceptionHome();
                        rec.Show();
                    }

                    return(true);
                }
                else
                {
                    MessageBox.Show("The MRN entered is not valid! Please enter a valid number");
                    return(true);
                }
            }
        }
        public void deleteAppointment(string m, string date, string time)
        {
            dbAppointment db = new dbAppointment();

            db.deleteAppointment(m, date, time);
        }