private void AddServicesGrid_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { string name = ""; if (e.ColumnIndex != -1 & e.RowIndex != -1) { name = AddServicesGrid.Rows[e.RowIndex].Cells[0].Value.ToString(); Data.CurrentService = Data.AddServices.FindByName(name); ServiceView serviceView = new ServiceView(); serviceView.Owner = this; serviceView.ShowDialog(); } }
private void ServiceEdit_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { this.Close(); try { ServiceView servView = this.Owner as ServiceView; AddServicesList servList = servView.Owner as AddServicesList; servView.Close(); servList.Close(); } catch { } } }
private void ServiceEdit_FormClosed(object sender, FormClosedEventArgs e)//изменение формы родителя { try { ServiceView serviceView = this.Owner as ServiceView; if (nameBox.Text == "" || priceBox.Text == "") { Data.AddServices.DelService(Data.CurrentService); serviceView.Close(); } serviceView.FillForm(Data.CurrentService); } catch { AddServicesList addServicesList = this.Owner as AddServicesList; addServicesList.FillGrid(); } }
private void saveButton_Click(object sender, EventArgs e)//сохранение услуги { if (nameBox.Text == "" || priceBox.Text == "") { MainForm.stStrip.Items.Clear(); MainForm.stStrip.Items.Add("Заполнены не все поля"); MessageBox.Show("Для сохранения заполните все поля формы.", "Упс!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { SaveThisForm(); Data.Status = false; MainForm.stStrip.Items.Clear(); MainForm.stStrip.Items.Add("Есть несохраненные данные"); MessageBox.Show("Данные успешно изменены.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); ServiceView serviceView = this.Owner as ServiceView; if (serviceView != null) { serviceView.Close(); } } }