Beispiel #1
0
        //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();
        }
Beispiel #2
0
        //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();
        }