Exemple #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         string date = monthCalendar1.SelectionStart.ToShortDateString();
         if (MessageBox.Show("Are you sure you want to add this message?", "Insert to DataBase", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
         {
             read = db.Select("*", "NewSchedule", "Date", date);
             while (read.Read())
             {
                 if (Int32.Parse(read["StartHour"].ToString().Trim()) == (Int32.Parse(StartHours.Text.Substring(0, 2))) && Int32.Parse(read["EndHour"].ToString().Trim()) == Int32.Parse(EndHours.Text.Substring(0, 2)))
                 {
                     if (read["LecturerName"].ToString().Trim().Equals(GlobalVariables.Full_Name) && read["Name"].ToString().Trim().Equals(Course.Text))
                     {
                         LectureID = read["LectureID"].ToString().Trim();
                         break;
                     }
                 }
             }
             read.Close();
             if (LectureID == null)
             {
                 MessageBox.Show("There is no lecture in this date");
                 return;
             }
             db.InsertChanges(LectureID, Notes.Text, Notes.Text, StartHours.Text.Substring(0, 2), EndHours.Text.Substring(0, 2), date.Substring(0, 2), date.Substring(3, 2), date.Substring(6, 4));
             db.InsertContstraints(GlobalVariables.User_ID, Days.Text, StartHours.Text, EndHours.Text, Notes.Text, date, Semester.Text, Course.Text);
             this.Hide();
         }
     }
     catch (Exception exp)
     {
         MessageBox.Show("Colud not connect to sql");
     }
     finally
     {
         if (db.isconnected == true)
         {
             db.CloseConnection();
         }
     }
 }