private void DeleteWineSortButton_Click(object sender, EventArgs e) { var selectedRows = WineSortTable.SelectedRows; foreach (DataGridViewRow row in selectedRows) { int id = Convert.ToInt32(row.Cells[0].Value); WineSortManager.DeleteData(id); WineSortCategory local = SortCategoryList.Find(x => x.Id == id); SortCategoryList.Remove(local); } UpdateWineSortTable(); }
private void AddWineSortButton_Click(object sender, EventArgs e) { try { WineSortCategory local = new WineSortCategory(Convert.ToInt32(IdTextBox.Text), WineSortTextBox.Text); MainForm main = Application.OpenForms["MainForm"] as MainForm; main.WineSortManager.LoadData(local); main.SortCategoryList.Add(local); main.UpdateWineSortTable(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButtons.OK); } }