private void button1_Click(object sender, EventArgs e) { try { bool isvalidated = validatefields(); if (isvalidated) { NotAvailableTime notAvailableTime = new NotAvailableTime(); notAvailableTime.Lecturer = LectuercomboBox.SelectedItem.ToString(); notAvailableTime.GroupID = GroupcomboBox.SelectedItem.ToString(); notAvailableTime.SubGroupID = SubGroupcomboBox.SelectedItem.ToString(); notAvailableTime.SessionID = SessionIDtextBox.Text; notAvailableTime.Time = TimetextBox.Text; string message = NotAvailableTimeController.AddNotAvailableTime(notAvailableTime); MessageBox.Show(message); clear(); } else { MessageBox.Show("please fill in all fields!"); } } catch (NullReferenceException nre) { MessageBox.Show("please fill in all fields!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void dataGridView6_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { try { if (e.RowIndex >= 0) { DataGridViewRow row = dataGridView6.Rows[e.RowIndex]; int NotAvailableTimeID = Convert.ToInt32(row.Cells[0].Value.ToString()); NotAvailableTime notAvailableTime = NotAvailableTimeController.SelectedNotAvailableTime(NotAvailableTimeID); if (notAvailableTime != null) { Hidelabel55.Text = notAvailableTime.NotAvailableTimeID.ToString(); } else { Hidelabel55.Text = string.Empty; } } } catch (FormatException fe) { MessageBox.Show("no data selected"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void loadgrid() { try { dataGridView6.DataSource = NotAvailableTimeController.FilterNotAvailableTime(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button2_Click(object sender, EventArgs e) { try { int nid = Convert.ToInt32(Hidelabel55.Text); string message = NotAvailableTimeController.DeleteNotAvailableTime(nid); MessageBox.Show(message); } catch (FormatException fe) { MessageBox.Show("please select a specific record"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }