private void btnDelete_Click(object sender, EventArgs e) { try { if (this.txtAppointmentID.Text == string.Empty) { throw new Exception("Select appointment you want to delete."); } int result = CancelledAppointmentsRepo.RemoveCancelledAppointment(Convert.ToInt32(this.txtAppointmentID.Text.ToString())); if (result == 1) { MessageBox.Show("Appointment Cancelled"); this.ClearAll(); this.PopulateCancelledTable(); } else { MessageBox.Show("Appointment not found", "Message"); } } catch (Exception exc) { MessageBox.Show("Erros: " + exc.Message); } }
private void btnCancelAllToday_Click(object sender, EventArgs e) { DataTable appointmentTable = AppointmentRepo.GetSpecificDoctorAppointments(Doctorid); if (appointmentTable.Rows.Count > 0) { var answer = MessageBox.Show("Cancel All Today's Appointment", "Cancel", MessageBoxButtons.YesNo); if (answer == DialogResult.Yes) { for (int ax = 0; ax < appointmentTable.Rows.Count; ax++) { AppointmentRepo.DeleteAllToday(Doctorid); CancelledAppointmentsRepo.CreateCancelledAppointment(appointmentTable.Rows[ax]["starttime"].ToString(), appointmentTable.Rows[ax]["date"].ToString(), Convert.ToInt32(appointmentTable.Rows[ax]["personid"].ToString()), Doctorid); } MessageBox.Show("All appointments cancelled successfully"); PopulateGridView(); ClearInfo(); } } else { MessageBox.Show("NO appointments to cancel today"); } }
private void btnCancel_Click_1(object sender, EventArgs e) { if (txtPersonID.Text != "") { var answer = MessageBox.Show("Cancel Appointment", "Cancel", MessageBoxButtons.YesNo); if (answer == DialogResult.Yes) { AppointmentRepo appointmentRepo = new AppointmentRepo(); DataGridViewRow dataRow = dgvAppointmentView.CurrentRow; //CancelledAppointmentsRepo.CreateCancelledAppointment(dataRow.Cells[8].Value.ToString(), dataRow.Cells[7].Value.ToString(), Convert.ToInt32(dataRow.Cells[1].Value.ToString()), Doctorid); //appointmentRepo.DeleteAppointment(Convert.ToInt32(dataRow.Cells[0].Value.ToString())); //MessageBox.Show(cmbAppointmentTime.Text); DateTime.Parse(dtpAppointmentDate.Text); //MessageBox.Show(DateTime.Parse(dtpAppointmentDate.Text).ToString("d")); CancelledAppointmentsRepo.CreateCancelledAppointment(cmbAppointmentTime.Text.ToString(), DateTime.Parse(dtpAppointmentDate.Text).ToString("d"), Convert.ToInt32(txtPersonID.Text), Doctorid); AppointmentRepo.DeleteByPatient(Convert.ToInt32(txtPersonID.Text), Doctorid); MessageBox.Show("Appointment cancelled successfully"); PopulateGridView(); ClearInfo(); } } else { MessageBox.Show("NO appointment is selected"); } }
private void btnDelete_Click(object sender, EventArgs e) { PersonRepo p1 = new PersonRepo(); p1.PersonID = Convert.ToInt32(this.txtPID.Text); DoctorRepo dr = new DoctorRepo(); if (this.txtDoctorId.Text != "" && this.txtDoctorId.Text != null) { dr.DoctorID = Convert.ToInt32(this.txtDoctorId.Text); } EmployeeRepo er = new EmployeeRepo(); er.EmpID = Convert.ToInt32(this.txtEmpId.Text); try { if (this.cmbDesignation.Text == "Doctor") { // IF DOCTOR -> Delete from all table that contains doctor's reference first CancelledAppointmentsRepo.RemoveParticularDoctorsAppointments(dr.DoctorID); AppointmentRepo.RemoveParticularDoctorsAppointments(dr.DoctorID); PatientDiseaseRepo.DeleteInfoBasedOnDoctor(dr.DoctorID); LoginVerification.DeleteLoginInfo(er.EmpID); // Afterwards delete from doctor table dr.DeleteDoctor(dr.DoctorID); } int empdelete = er.DeleteEmployee(er.EmpID); int persondeleted = p1.DeletePerson(p1.PersonID); this.PopulatePersonTable(); MessageBox.Show("Successfully deleted!"); this.ClearAll(); } catch (Exception exc) { MessageBox.Show("error!" + exc); } }
private void btnUpdate_Click(object sender, EventArgs e) { try { if (this.dtpAppointmentDate.Value.Date < DateTime.Today) { throw new Exception("Selected date must be of today or future"); } DoctorRepo doctorRepo = new DoctorRepo(); DataTable doctorData = doctorRepo.GetIndividualDoctorsInfo(Convert.ToInt32(this.txtDoctorID.Text)); doctorRepo.DoctorID = Convert.ToInt32(doctorData.Rows[0]["doctorid"].ToString()); doctorRepo.Specialty = doctorData.Rows[0]["specialty"].ToString(); doctorRepo.AvailableDays = doctorData.Rows[0]["availabledays"].ToString(); doctorRepo.EmployeeIdOfDoctor = Convert.ToInt32(doctorData.Rows[0]["empid"].ToString()); // Check if available day of doctor matches with appointment day string[] daysAvailabe = doctorRepo.AvailableDays.Split(' '); bool checkValidDay = false; string selectedDay = dtpAppointmentDate.Value.DayOfWeek.ToString().Substring(0, 3).ToLower(); foreach (string days in daysAvailabe) { if (days.Equals(selectedDay)) { checkValidDay = true; break; } else { checkValidDay = false; } } // If its a invalid day if (!checkValidDay) { throw new Exception("Doctor not available on this day. Check Available days"); } AppointmentRepo ap = new AppointmentRepo(); ap.AppointmentID = Convert.ToInt32(this.txtAppointmentID.Text); ap.Time = this.cmbAppointmentTime.Text.ToString(); ap.Date = this.dtpAppointmentDate.Value.ToString("MM/dd/yyyy"); ap.DoctorID = Convert.ToInt32(this.txtDoctorID.Text); ap.PatientID = Convert.ToInt32(this.txtPatientID.Text); // Check if clash appointment if (ap.RowExits(ap.Time, ap.Date, ap.DoctorID)) { throw new Exception("Clash Appointment"); } // If no clash appointment then proceed int appointmentCreated = ap.CreateAppointment(ap.Time, ap.Date, ap.PatientID, ap.DoctorID); if (appointmentCreated == 1) { // Must remove it from cancelled appointment now since reassigned CancelledAppointmentsRepo.RemoveCancelledAppointment(ap.AppointmentID); MessageBox.Show("Appointment reassigned"); // refresh the table this.PopulateCancelledTable(); this.ClearAll(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// string query = "select * from appointment" private void PopulateCancelledTable(string query = sql) { this.dgvCancelledAppointment.AutoGenerateColumns = false; this.dgvCancelledAppointment.DataSource = CancelledAppointmentsRepo.GetAllCancelledAppointmentInformation(query); }