//Used if the edit start date is successful private void Add_Edit_Class_Activated(object sender, EventArgs e) { if (Input_1.ReadOnly == false) { Class_Database.PopulatePatient_ClassDGV(Dropdown_1, PatientsClassDGV, PatientsClassWaitingDGV); } }
//If a time is changed then new finish times are generated private void Dropdown_1_SelectionChangeCommitted(object sender, EventArgs e) { DataTable finishTimes = Class_Database.GenerateFinishTimes(Global.newTimeDay, Dropdown_1); Dropdown_2.DataSource = finishTimes; Dropdown_2.ValueMember = "Time"; Dropdown_2.DisplayMember = "Display Time"; }
//Deletes patient from waiting list and adds patient to class private void Move_Click(object sender, EventArgs e) { bool moveSuccess = Class_Database.MoveWaitingPatient(PatientsClassWaitingDGV, Dropdown_1, Date_1); if (moveSuccess == true) { Class_Database.PopulatePatient_ClassDGV(Dropdown_1, PatientsClassDGV, PatientsClassWaitingDGV); } }
//Deletes patient from waiting list private void Remove_Waiting_Click(object sender, EventArgs e) { bool deleteSuccess = Class_Database.DeletePatient_ClassWaitingList(Dropdown_1, PatientsClassWaitingDGV); if (deleteSuccess == true) { Class_Database.PopulatePatient_ClassDGV(Dropdown_1, PatientsClassDGV, PatientsClassWaitingDGV); } }
//********************Non Event Methods******************** //Used to populate all the class times for each day private void PopulateClassTimes() { Class_Database.PopulateTimeDataGridView("Monday", MondayDGV); Class_Database.PopulateTimeDataGridView("Tuesday", TuesdayDGV); Class_Database.PopulateTimeDataGridView("Wednesday", WednesdayDGV); Class_Database.PopulateTimeDataGridView("Thursday", ThursdayDGV); Class_Database.PopulateTimeDataGridView("Friday", FridayDGV); Class_Database.PopulateTimeDataGridView("Saturday", SaturdayDGV); }
private void Delete_Saturday_Click(object sender, EventArgs e) { bool deleteSuccessful = Class_Database.DeleteTime(SaturdayDGV, Global.newTimeSaturday); if (deleteSuccessful == true) { PopulateClassTimes(); } }
//Saves start time private void Save_Click(object sender, EventArgs e) { bool editSuccessful = Class_Database.EditStartDate(Global.changeStartDatePatientID, Input_2, Date_1); if (editSuccessful == true) { this.Close(); } }
//Enables controls to add patients to class and populates existing class patients private void Dropdown_1_SelectionChangeCommitted(object sender, EventArgs e) { Global.editingExistingClass = true; Input_1.ReadOnly = false; Save.Enabled = true; Delete_Class.Enabled = true; Dropdown_2.Enabled = true; Input_1.Text = Dropdown_1.SelectedValue.ToString(); Class_Database.PopulatePatient_ClassDGV(Dropdown_1, PatientsClassDGV, PatientsClassWaitingDGV); }
//The following 6 event methods are used to add new times to the chosen day //All the events do the same thing but set a Global variable to the selected day private void Add_Monday_Time_Click(object sender, EventArgs e) { Global.editingExistingClassTime = false; Global.newTimedt = Class_Database.GenerateStartTimes("Monday"); Global.newTimeDay = Global.newTimeMonday; this.Hide(); Add_New_Time addTime = new Add_New_Time(); addTime.ShowDialog(); addTime.Focus(); }
//Creates new class or updates class name private void Save_Click(object sender, EventArgs e) { bool saveSuccess = Class_Database.SaveClass(Input_1, Dropdown_1); if (saveSuccess == true) { Input_1.ReadOnly = true; Dropdown_1.DataSource = null; Save.Enabled = false; Add_Class.Focus(); } }
//Adds patient to the waiting list of the selected class private void Add_Patient_Waiting_Click(object sender, EventArgs e) { bool saveSuccess = Class_Database.SavePatient_ClassWaitingList(Dropdown_1, Dropdown_2); if (saveSuccess == true) { Class_Database.PopulatePatient_ClassDGV(Dropdown_1, PatientsClassDGV, PatientsClassWaitingDGV); Dropdown_2.DataSource = null; Date_1.Enabled = false; Add_Patient.Enabled = false; Add_Patient_Waiting.Enabled = false; Dropdown_2.Focus(); } }
//Creates new Class Time and returns to Add_Edit_Class_Times private void Create_Time_Click(object sender, EventArgs e) { bool saveSuccess = Class_Database.SaveTime(Dropdown_1, Dropdown_2, Global.newTimeDay, Dropdown_3); if (saveSuccess == true) { Global.addNewTimeOpen = false; Global.editingExistingClassTime = false; this.Hide(); Add_Edit_Class_Times classes = new Add_Edit_Class_Times(); classes.ShowDialog(); classes.Focus(); } }
//If user clicks on a saved time in a DGV then Add_New_Time is open in an edit session private void EditTime(DataGridView dayDGV, string day) { //Checks if there are any class times for the patient if (dayDGV.Rows.Count == 0) { MessageBox.Show("There are no class times for " + day, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Checks if the user has selected a class time if (dayDGV.SelectedRows.Count == 0) { MessageBox.Show("Please select a class time from the " + day + " grid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Global.editingExistingClassTime = true; //Starts an edit session Global.newTimeDay = day; //Sets the day to a Global variable to be used in Add_New_Time //Getting the The start and finish time of selected row int cellIndex = dayDGV.SelectedCells[0].RowIndex; DataGridViewCell cellCollection = dayDGV.Rows[cellIndex].Cells[0]; Global.editClassTimeDGVSelect = cellCollection.Value.ToString(); //In string format hh:mm - hh:mm //Uesd to select the right row in the add new time forms datagridview string startTimeString = Global.editClassTimeDGVSelect.Remove(5); //Gets start time from string: Removes "hh:mm" from "hh:mm - hhmm" string hours = startTimeString.Remove(2); string minutes = startTimeString.Remove(0, 3); Global.startTimeSelectedDateTime = Global.CreateTime(Int32.Parse(hours), Int32.Parse(minutes)); //Creates a Datetime object based on hours and mins Global.editClassStartTimeSQLite = Global.getDateString(hours, minutes); //Creates a date string in sqlite format to be used in next form Global.newTimedt = Class_Database.GenerateStartTimes(day); //Generates start times and sets them to a datatable //Loads Add_New_Time form this.Hide(); Add_New_Time addTime = new Add_New_Time(); addTime.ShowDialog(); addTime.Focus(); }
//Deletes class. When a class is deleted it deletes the class, all Patient_Class records and CLass Time Records private void Delete_Class_Click(object sender, EventArgs e) { bool deleteSuccess = Class_Database.DeleteClass(Dropdown_1); //When delete has finished it disables all other controls and deselects everything if (deleteSuccess == true) { PatientsClassDGV.DataSource = null; PatientsClassWaitingDGV.DataSource = null; Input_1.ReadOnly = true; Input_1.Text = null; Dropdown_1.DataSource = null; Dropdown_2.DataSource = null; Dropdown_2.Enabled = false; Date_1.Enabled = false; Add_Patient.Enabled = false; Delete_Class.Enabled = false; Save.Enabled = false; Add_Patient_Waiting.Enabled = false; Dropdown_2.Focus(); } }
public Add_New_Time() { InitializeComponent(); UserLabel.Text = "Current User: "******" " + Global.userLastName; //Sets the current user to label Class_Database.PopulateTimeDataGridView(Global.newTimeDay, Existing_Times); //Populates datagridview with existing times //Setting start times datasource found from GenerateStartTimes Method in Add_Edit_Class_Times Dropdown_1.DataSource = Global.newTimedt; Dropdown_1.ValueMember = "Time"; Dropdown_1.DisplayMember = "Display Time"; //Setting startvtime dropdown selected index to the same as the one currently editing if in edit session if (Global.editingExistingClassTime == true) { int selectedIndex = 0; //Will hold the selected index int counter = 0; //Used as the counter for iteration //Loops through each of the start times found in dopdown1 and selects the edited start time foreach (DataRow row in Global.newTimedt.Rows) { if (row[1].ToString() == Global.startTimeSelectedDateTime.ToShortTimeString()) { selectedIndex = counter; break; } counter++; } Dropdown_1.SelectedIndex = selectedIndex; //If edit session changes the button to an edit button Create_Time.Visible = false; Edit_Time.Visible = true; } Class_Time_Groupbox.Text = Global.newTimeDay; //Sets label to which day is selected Dropdown_1_SelectionChangeCommitted(this, EventArgs.Empty); //runs event for selectionchangecommitted which generates finish times }
//Populates dropdown with list of classes private void Dropdown_1_DropDown(object sender, EventArgs e) { Class_Database.PopulateClassDropdown(Dropdown_1); }
//Populates datagridviews with patient details and times this class is on private void Dropdown_1_SelectionChangeCommitted(object sender, EventArgs e) { Class_Database.PopulatePatient_ClassDGV(Dropdown_1, PatientsClassDGV); Class_Database.PopulateClassTimeDetailsDGV(Dropdown_1, ClassDetailsDGV); }