//Удаление выбранного уведомления private void delNoticeBtn_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Подтвердите удаление.", "Удаление", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); //диалоговое окно if (result == DialogResult.OK) { DBConnection.DeleteNotification(notificationsTable.Rows[notification_row].Cells[4].Value.ToString()); DBConnection.GetNotifications(Form1.requestNum); notificationsTable.DataSource = DBConnection.dtNotifications; notification_row = 0; Form1.form.UpdateNoticesQty(); } }
//Добавление нового уведомления к услуге в БД private void addNotice_Click(object sender, EventArgs e) { try { if (daysBefore.Text == "" || text.Text == "") { MessageBox.Show("Заполните все поля!"); return; } DBConnection.NewNotification(saleID, daysBefore.Text, text.Text); DBConnection.GetNotifications(Form1.requestNum); Notifications.form.notificationsTable.DataSource = DBConnection.dtNotifications; Notifications.notification_row = 0; Form1.form.UpdateNoticesQty(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
//Выполняется при загрузке формы, заполнение таблиц данными из БД, настройка элементов управления private void Notifications_Load(object sender, EventArgs e) { form = this; label1.Text = email; label4.Text = contractNum; DBConnection.GetServicesInContract(Form1.requestNum); servicesTable.DataSource = DBConnection.dtServicesInContract; servicesTable.Columns[0].Visible = false; servicesTable.Columns[1].Visible = false; DataGridViewButtonColumn btn = new DataGridViewButtonColumn(); //объект кнопки в колонке таблицы btn.HeaderText = "Создать"; btn.Text = "Уведомление"; btn.UseColumnTextForButtonValue = true; servicesTable.Columns.Add(btn); //saleID = servicesTable.Rows[0].Cells[0].Value.ToString(); DBConnection.GetNotifications(Form1.requestNum); notificationsTable.DataSource = DBConnection.dtNotifications; notificationsTable.Columns[4].Visible = false; notification_row = 0; //notificationID = notificationsTable.Rows[0].Cells[4].Value.ToString(); //days_before = notificationsTable.Rows[0].Cells[1].Value.ToString(); //text = notificationsTable.Rows[0].Cells[2].Value.ToString(); }