private void AddRowCon(object sender, EventArgs e) { int i = gridMain.Rows.Count; gridMain.Rows.Add(); gridMain.Rows[i].Visible = false; AddRow(i); gridMain.Rows[i].Cells[1].Value = contractorAdd.CategoryFirstID; gridMain.Rows[i].Cells[2].Value = contractorAdd.CategorySecondID; gridMain.Rows[i].Cells[3].Value = contractorAdd.CategoryThirdID; gridMain.Rows[i].Cells[4].Value = contractorAdd.ContrTIN; gridMain.Rows[i].Cells[5].Value = contractorAdd.ContrName; gridMain.Rows[i].Cells[6].Value = contractorAdd.CategoryFirst; gridMain.Rows[i].Cells[7].Value = contractorAdd.CategorySecond; gridMain.Rows[i].Cells[8].Value = contractorAdd.CategoryThird; contractorAdd.ButtonOkClicked -= new EventHandler(AddRowCon); contractorAdd.Close(); gridMain.Rows[i].Visible = true; contractorAdd = null; //указываем активную ячейку gridMain.CurrentCell = gridMain.Rows[gridMain.Rows.Count - 1].Cells[5]; }
private void button1_Click(object sender, EventArgs e) { using (contractorAdd = new ContractorAdd()) { contractorAdd.ButtonOkClicked += new EventHandler(AddRowCon); LoadCategories(); contractorAdd.ActiveItemsCombobox(0, 0, 0); contractorAdd.ShowDialog(); } }
private void EditRowCon(object sender, EventArgs e) { gridMain.Rows[gridMain.CurrentCell.RowIndex].Cells[1].Value = contractorAdd.CategoryFirstID; gridMain.Rows[gridMain.CurrentCell.RowIndex].Cells[2].Value = contractorAdd.CategorySecondID; gridMain.Rows[gridMain.CurrentCell.RowIndex].Cells[3].Value = contractorAdd.CategoryThirdID; gridMain.Rows[gridMain.CurrentCell.RowIndex].Cells[4].Value = contractorAdd.ContrTIN; gridMain.Rows[gridMain.CurrentCell.RowIndex].Cells[5].Value = contractorAdd.ContrName; gridMain.Rows[gridMain.CurrentCell.RowIndex].Cells[6].Value = contractorAdd.CategoryFirst; gridMain.Rows[gridMain.CurrentCell.RowIndex].Cells[7].Value = contractorAdd.CategorySecond; gridMain.Rows[gridMain.CurrentCell.RowIndex].Cells[8].Value = contractorAdd.CategoryThird; //обновление в бд UpdateRow(); contractorAdd.ButtonOkClicked -= new EventHandler(EditRowCon); contractorAdd.Close(); contractorAdd = null; }
private void btnEdit_Click(object sender, EventArgs e) { if (!(gridMain.Rows.Count == 0)) { using (contractorAdd = new ContractorAdd()) { contractorAdd.ButtonOkClicked += new EventHandler(EditRowCon); contractorAdd.ContrTIN = gridMain.Rows[gridMain.CurrentCell.RowIndex].Cells[4].Value.ToString(); contractorAdd.ContrName = gridMain.Rows[gridMain.CurrentCell.RowIndex].Cells[5].Value.ToString(); LoadCategories(); contractorAdd.ActiveItemsCombobox(Convert.ToInt32(gridMain.Rows[gridMain.CurrentCell.RowIndex].Cells[1].Value.ToString()), Convert.ToInt32(gridMain.Rows[gridMain.CurrentCell.RowIndex].Cells[2].Value.ToString()), Convert.ToInt32(gridMain.Rows[gridMain.CurrentCell.RowIndex].Cells[3].Value.ToString())); contractorAdd.FormCaption = "Редактировать"; contractorAdd.ShowDialog(); } } }