예제 #1
0
        private void view_timetable_table_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == view_timetable_table.Columns["download_btn"].Index)
            {
                string intake_val       = this.view_timetable_table.CurrentRow.Cells[3].Value.ToString();
                string degree_programme = this.view_timetable_table.CurrentRow.Cells[4].Value.ToString();
                string semester         = this.view_timetable_table.CurrentRow.Cells[5].Value.ToString();

                string validity_period_start = this.view_timetable_table.Rows[e.RowIndex].Cells[6].Value.ToString();

                string validity_period_end = this.view_timetable_table.Rows[e.RowIndex].Cells[7].Value.ToString();

                string week = this.view_timetable_table.Rows[e.RowIndex].Cells[8].Value.ToString();

                TimetableCrystalForm crfrm = new TimetableCrystalForm(intake_val, week, degree_programme, semester, validity_period_start, validity_period_end);
                crfrm.Show();
            }
        }
        private void view_timetable_table_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == view_timetable_table.Columns["download_btn"].Index)
            {
                string intake_val       = this.view_timetable_table.CurrentRow.Cells[3].Value.ToString();
                string degree_programme = this.view_timetable_table.CurrentRow.Cells[4].Value.ToString();
                string semester         = this.view_timetable_table.CurrentRow.Cells[5].Value.ToString();

                string validity_period_start = this.view_timetable_table.Rows[e.RowIndex].Cells[6].Value.ToString();

                string validity_period_end = this.view_timetable_table.Rows[e.RowIndex].Cells[7].Value.ToString();

                string week = this.view_timetable_table.Rows[e.RowIndex].Cells[8].Value.ToString();

                TimetableCrystalForm crfrm = new TimetableCrystalForm(intake_val, week, degree_programme, semester, validity_period_start, validity_period_end);
                crfrm.Show();
            }
            else if (e.ColumnIndex == view_timetable_table.Columns["delete_btn"].Index)
            {
                if (MessageBox.Show("Are you sure want to delete this timetable?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    databaseConnection.Open();
                    DataGridViewRow row = view_timetable_table.Rows[e.RowIndex];

                    MySqlCommand delete_mods = new MySqlCommand("Delete from ttms_lecture_module where timetable_id = '" + row.Cells[2].Value.ToString() + "'", databaseConnection);
                    delete_mods.ExecuteNonQuery();

                    MySqlCommand delete_tt = new MySqlCommand("Delete from ttms_timetable_main where timetable_id = '" + row.Cells[2].Value.ToString() + "'", databaseConnection);
                    delete_tt.ExecuteNonQuery();
                    MessageBox.Show("Delete Successful!");

                    //remove from datatable
                    view_timetable_table.Rows.Remove(view_timetable_table.CurrentRow);
                    databaseConnection.Close();

                    view_timetable_table.Update();
                    view_timetable_table.Refresh();
                }
            }
        }
예제 #3
0
        private void guna2Button1_Click(object sender, EventArgs e)
        {
            try
            {
                databaseConnection.Open();
                MySqlCommand getDegreeProgramme = new MySqlCommand("Select degree_programme_id from ttms_degree_programme where degree_programme ='" + select_degree_prog_combo.SelectedItem + "'", databaseConnection);
                Int32        degreeID           = Convert.ToInt32(getDegreeProgramme.ExecuteScalar());

                //SqlCommand reset_id = new SqlCommand("DBCC CHECKIDENT(ttms_timetable_initiate_table,reseed,1)", conn1);
                // reset_id.ExecuteNonQuery();

                MySqlCommand getIntakeId = new MySqlCommand("Select id from intakes where intake= '" + select_intake_combobox.SelectedItem + "'", databaseConnection);
                Int32        intakeId    = Convert.ToInt32(getIntakeId.ExecuteScalar());

                MySqlCommand inserttimetableInitiate = new MySqlCommand(@"INSERT INTO ttms_timetable_main(intake_id,degree_programme_id,semester,validity_period_start,validity_period_end,week) VALUES(@intake_id,@degree_programme_id,@semester,@validity_period_start,@validity_period_end,@week)", databaseConnection);
                inserttimetableInitiate.Parameters.AddWithValue("@intake_id", intakeId);
                inserttimetableInitiate.Parameters.AddWithValue("@degree_programme_id", degreeID);
                inserttimetableInitiate.Parameters.AddWithValue("@semester", select_sem_combo.SelectedItem);
                inserttimetableInitiate.Parameters.AddWithValue("@validity_period_start", validity_period_start.Value.ToString("yyyy-MM-dd"));
                inserttimetableInitiate.Parameters.AddWithValue("@validity_period_end", validity_period_end.Value.ToString("yyyy-MM-dd"));
                inserttimetableInitiate.Parameters.AddWithValue("@week", select_week_combo.SelectedItem);
                inserttimetableInitiate.ExecuteNonQuery();

                //Int32 modified = (Int32)inserttimetableInitiate.ExecuteScalar();

                //    if (conn1.State == ConnectionState.Open)
                //    {
                //    conn1.Close();
                //    }
                //    string vall = modified.ToString();


                //FOR GETTING MAX ID
                MySqlCommand cmmd = new MySqlCommand("SELECT MAX(timetable_id) FROM ttms_timetable_main", databaseConnection);
                string       vall = cmmd.ExecuteScalar().ToString();


                // SqlCommand cmmd = new SqlCommand("SELECT SCOPE_IDENTITY() FROM ttms_timetable_initiate_table", conn1);
                //    string vall = cmmd.ExecuteScalar().ToString();


                //FOR RESEEDING
                // SqlCommand reset_lecture_module_id = new SqlCommand("DBCC CHECKIDENT(ttms_lecture_module_table,reseed,1)", conn1);
                // reset_lecture_module_id.ExecuteNonQuery();
                //conn1.Close();

                //Monday Morning lectures
                int m_morning = checkModules(1, 2, 3, 0, 1, 2);
                if (m_morning == 10)
                {
                }
                else
                {
                    if (m_morning == 1)
                    {
                        executeLecture(vall, 1, 2, 3, "Monday", "0800 - 0900", 0);
                        executeLecture(vall, 1, 2, 3, "Monday", "0900 - 1000", 1);
                        executeLecture(vall, 1, 2, 3, "Monday", "1000 - 1100", 2);
                    }
                    else if (m_morning == 2)
                    {
                        executeLecture(vall, 1, 2, 3, "Monday", "0800 - 1000", 0);
                        executeLecture(vall, 1, 2, 3, "Monday", "1000 - 1100", 2);
                    }
                    else if (m_morning == 3)
                    {
                        executeLecture(vall, 1, 2, 3, "Monday", "0800 - 0900", 0);
                        executeLecture(vall, 1, 2, 3, "Monday", "0900 - 1100", 1);
                    }
                    else if (m_morning == 4)
                    {
                        executeLecture(vall, 1, 2, 3, "Monday", "0800 - 1100", 0);
                    }
                    else
                    {
                        MessageBox.Show("Invalid Format");
                    }
                }


                //Tuesday Morning lectures
                int t_morning = checkModules(4, 5, 6, 0, 1, 2);
                if (t_morning == 10)
                {
                }
                else
                {
                    if (t_morning == 1)
                    {
                        executeLecture(vall, 4, 5, 6, "Tuesday", "0800 - 0900", 0);
                        executeLecture(vall, 4, 5, 6, "Tuesday", "0900 - 1000", 1);
                        executeLecture(vall, 4, 5, 6, "Tuesday", "1000 - 1100", 2);
                    }
                    else if (t_morning == 2)
                    {
                        executeLecture(vall, 4, 5, 6, "Tuesday", "0800 - 1000", 0);
                        executeLecture(vall, 4, 5, 6, "Tuesday", "1000 - 1100", 2);
                    }
                    else if (t_morning == 3)
                    {
                        executeLecture(vall, 4, 5, 6, "Tuesday", "0800 - 0900", 0);
                        executeLecture(vall, 4, 5, 6, "Tuesday", "0900 - 1100", 1);
                    }
                    else if (t_morning == 4)
                    {
                        executeLecture(vall, 4, 5, 6, "Tuesday", "0800 - 1100", 0);
                    }
                    else
                    {
                        MessageBox.Show("Invalid Format");
                    }
                }


                //Wednesday Morning lectures
                int w_morning = checkModules(7, 8, 9, 0, 1, 2);
                if (w_morning == 10)
                {
                }
                else
                {
                    if (w_morning == 1)
                    {
                        executeLecture(vall, 7, 8, 9, "Wednesday", "0800 - 0900", 0);
                        executeLecture(vall, 7, 8, 9, "Wednesday", "0900 - 1000", 1);
                        executeLecture(vall, 7, 8, 9, "Wednesday", "1000 - 1100", 2);
                    }
                    else if (w_morning == 2)
                    {
                        executeLecture(vall, 7, 8, 9, "Wednesday", "0800 - 1000", 0);
                        executeLecture(vall, 7, 8, 9, "Wednesday", "1000 - 1100", 2);
                    }
                    else if (w_morning == 3)
                    {
                        executeLecture(vall, 7, 8, 9, "Wednesday", "0800 - 0900", 0);
                        executeLecture(vall, 7, 8, 9, "Wednesday", "0900 - 1100", 1);
                    }
                    else if (w_morning == 4)
                    {
                        executeLecture(vall, 7, 8, 9, "Wednesday", "0800 - 1100", 0);
                    }
                    else
                    {
                        MessageBox.Show("Invalid Format");
                    }
                }



                //Thursday Morning lectures
                int th_morning = checkModules(10, 11, 12, 0, 1, 2);

                if (th_morning == 10)
                {
                }
                else
                {
                    if (th_morning == 1)
                    {
                        executeLecture(vall, 10, 11, 12, "Thursday", "0800 - 0900", 0);
                        executeLecture(vall, 10, 11, 12, "Thursday", "0900 - 1000", 1);
                        executeLecture(vall, 10, 11, 12, "Thursday", "1000 - 1100", 2);
                    }
                    else if (th_morning == 2)
                    {
                        executeLecture(vall, 10, 11, 12, "Thursday", "0800 - 1000", 0);
                        executeLecture(vall, 10, 11, 12, "Thursday", "1000 - 1100", 2);
                    }
                    else if (th_morning == 3)
                    {
                        executeLecture(vall, 10, 11, 12, "Thursday", "0800 - 0900", 0);
                        executeLecture(vall, 10, 11, 12, "Thursday", "0900 - 1100", 1);
                    }
                    else if (th_morning == 4)
                    {
                        executeLecture(vall, 10, 11, 12, "Thursday", "0800 - 1100", 0);
                    }
                    else
                    {
                        MessageBox.Show("Invalid Format");
                    }
                }

                // Friday Morning lectures
                int fr_morning = checkModules(13, 14, 15, 0, 1, 2);

                if (fr_morning == 10)
                {
                }
                else
                {
                    if (fr_morning == 1)
                    {
                        executeLecture(vall, 13, 14, 15, "Friday", "0800 - 0900", 0);
                        executeLecture(vall, 13, 14, 15, "Friday", "0900 - 1000", 1);
                        executeLecture(vall, 13, 14, 15, "Friday", "1000 - 1100", 2);
                    }
                    else if (fr_morning == 2)
                    {
                        executeLecture(vall, 13, 14, 151, "Friday", "0800 - 1000", 0);
                        executeLecture(vall, 13, 14, 15, "Friday", "1000 - 1100", 2);
                    }
                    else if (fr_morning == 3)
                    {
                        executeLecture(vall, 13, 14, 15, "Friday", "0800 - 0900", 0);
                        executeLecture(vall, 13, 14, 15, "Friday", "0900 - 1100", 1);
                    }
                    else if (fr_morning == 4)
                    {
                        executeLecture(vall, 13, 14, 15, "Friday", "0800 - 1100", 0);
                    }
                    else
                    {
                        MessageBox.Show("Invalid Format");
                    }
                }

                // Monday Evening lectures
                int m_evening = checkModules(1, 2, 3, 4, 5, 6);

                if (m_evening == 10)
                {
                }
                else
                {
                    if (m_evening == 1)
                    {
                        executeLecture(vall, 1, 2, 3, "Monday", "1115 - 1215", 4);
                        executeLecture(vall, 1, 2, 3, "Monday", "1215 - 1315", 5);
                        executeLecture(vall, 1, 2, 3, "Monday", "1315 - 1415", 6);
                    }
                    else if (m_evening == 2)
                    {
                        executeLecture(vall, 1, 2, 3, "Monday", "1115 - 1315", 4);
                        executeLecture(vall, 1, 2, 3, "Monday", "1315 - 1415", 6);
                    }
                    else if (m_evening == 3)
                    {
                        executeLecture(vall, 1, 2, 3, "Monday", "1115 - 1215", 4);
                        executeLecture(vall, 1, 2, 3, "Monday", "1215 - 1415", 5);
                    }
                    else if (m_evening == 4)
                    {
                        executeLecture(vall, 1, 2, 3, "Monday", "1115 - 1415", 4);
                    }
                    else
                    {
                        MessageBox.Show("Invalid Format");
                    }
                }

                // Monday Evening lectures 2
                executeLecture(vall, 1, 2, 3, "Monday", "1430 - 1615", 8);

                // Tuesday Evening lectures
                int t_evening = checkModules(4, 5, 6, 4, 5, 6);

                if (t_evening == 10)
                {
                }
                else
                {
                    if (t_evening == 1)
                    {
                        executeLecture(vall, 4, 5, 6, "Tuesday", "1115 - 1215", 4);
                        executeLecture(vall, 4, 5, 6, "Tuesday", "1215 - 1315", 5);
                        executeLecture(vall, 4, 5, 6, "Tuesday", "1315 - 1415", 6);
                    }
                    else if (t_evening == 2)
                    {
                        executeLecture(vall, 4, 5, 6, "Tuesday", "1115 - 1315", 4);
                        executeLecture(vall, 4, 5, 6, "Tuesday", "1315 - 1415", 6);
                    }
                    else if (t_evening == 3)
                    {
                        executeLecture(vall, 4, 5, 6, "Tuesday", "1115 - 1215", 4);
                        executeLecture(vall, 4, 5, 6, "Tuesday", "1215 - 1415", 5);
                    }
                    else if (t_evening == 4)
                    {
                        executeLecture(vall, 4, 5, 6, "Tuesday", "1115 - 1415", 4);
                    }
                    else
                    {
                        MessageBox.Show("Invalid Format");
                    }
                }

                // Tuesday Evening lectures 2
                executeLecture(vall, 4, 5, 6, "Tuesday", "1430 - 1615", 8);


                // Wednesday Evening lectures
                int w_evening = checkModules(7, 8, 9, 4, 5, 6);

                if (w_evening == 10)
                {
                }
                else
                {
                    if (w_evening == 1)
                    {
                        executeLecture(vall, 7, 8, 9, "Wednesday", "1115 - 1215", 4);
                        executeLecture(vall, 7, 8, 9, "Wednesday", "1215 - 1315", 5);
                        executeLecture(vall, 7, 8, 9, "Wednesday", "1315 - 1415", 6);
                    }
                    else if (w_evening == 2)
                    {
                        executeLecture(vall, 7, 8, 9, "Wednesday", "1115 - 1315", 4);
                        executeLecture(vall, 7, 8, 9, "Wednesday", "1315 - 1415", 6);
                    }
                    else if (w_evening == 3)
                    {
                        executeLecture(vall, 7, 8, 9, "Wednesday", "1115 - 1215", 4);
                        executeLecture(vall, 7, 8, 9, "Wednesday", "1215 - 1415", 5);
                    }
                    else if (w_evening == 4)
                    {
                        executeLecture(vall, 7, 8, 9, "Wednesday", "1115 - 1415", 4);
                    }
                    else
                    {
                        MessageBox.Show("Invalid Format");
                    }
                }

                //Wednesday Evening lectures 2
                executeLecture(vall, 7, 8, 9, "Wednesday", "1430 - 1615", 8);


                // Thursday Evening lectures
                int th_evening = checkModules(10, 11, 12, 4, 5, 6);
                if (th_evening == 10)
                {
                }
                else
                {
                    if (th_evening == 1)
                    {
                        executeLecture(vall, 10, 11, 12, "Thursday", "1115 - 1215", 4);
                        executeLecture(vall, 10, 11, 12, "Thursday", "1215 - 1315", 5);
                        executeLecture(vall, 10, 11, 12, "Thursday", "1315 - 1415", 6);
                    }
                    else if (th_evening == 2)
                    {
                        executeLecture(vall, 10, 11, 12, "Thursday", "1115 - 1315", 4);
                        executeLecture(vall, 10, 11, 12, "Thursday", "1315 - 1415", 6);
                    }
                    else if (th_evening == 3)
                    {
                        executeLecture(vall, 10, 11, 12, "Thursday", "1115 - 1215", 4);
                        executeLecture(vall, 10, 11, 12, "Thursday", "1215 - 1415", 5);
                    }
                    else if (th_evening == 4)
                    {
                        executeLecture(vall, 10, 11, 12, "Thursday", "1115 - 1415", 4);
                    }
                    else
                    {
                        MessageBox.Show("Invalid Format");
                    }
                }

                // Thursday Evening lectures 2
                executeLecture(vall, 10, 11, 12, "Thursday", "1430 - 1615", 8);

                // Friday Evening lectures
                int fr_evening = checkModules(13, 14, 15, 4, 5, 6);

                if (fr_evening == 10)
                {
                }
                else
                {
                    if (fr_evening == 1)
                    {
                        executeLecture(vall, 13, 14, 15, "Friday", "1115 - 1215", 4);
                        executeLecture(vall, 13, 14, 15, "Friday", "1215 - 1315", 5);
                        executeLecture(vall, 13, 14, 15, "Friday", "1315 - 1415", 6);
                    }
                    else if (fr_evening == 2)
                    {
                        executeLecture(vall, 13, 14, 15, "Friday", "1115 - 1315", 4);
                        executeLecture(vall, 13, 14, 15, "Friday", "1315 - 1415", 6);
                    }
                    else if (fr_evening == 3)
                    {
                        executeLecture(vall, 13, 14, 15, "Friday", "1115 - 1215", 4);
                        executeLecture(vall, 13, 14, 15, "Friday", "1215 - 1415", 5);
                    }
                    else if (fr_evening == 4)
                    {
                        executeLecture(vall, 13, 14, 15, "Friday", "1115 - 1415", 4);
                    }
                    else
                    {
                        MessageBox.Show("Invalid Format");
                    }
                }
                // Friday Evening lectures 2
                executeLecture(vall, 13, 14, 15, "Friday", "1430 - 1615", 8);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                databaseConnection.Close();

                TimetableCrystalForm crfrm = new TimetableCrystalForm(select_intake_combobox.SelectedItem.ToString(), select_week_combo.SelectedItem.ToString(), select_degree_prog_combo.SelectedItem.ToString(), select_sem_combo.SelectedItem.ToString(), validity_period_start.Value.ToString("yyyy-MM-dd"), validity_period_end.Value.ToString("yyyy-MM-dd"));
                crfrm.Show();
            }
        }