private void AddRowSalesMain(object sender, EventArgs e) { int i = gridMain.Rows.Count; gridMain.Rows.Add(); gridMain.Rows[i].Visible = false; AddRowMain(i); gridMain.Rows[i].Cells[1].Value = sales.ContrID; gridMain.Rows[i].Cells[2].Value = sales.DealID; gridMain.Rows[i].Cells[3].Value = sales.VAT; gridMain.Rows[i].Cells[4].Value = sales.ContrName; gridMain.Rows[i].Cells[5].Value = sales.DealNumber; gridMain.Rows[i].Cells[6].Value = sales.DealDate; gridMain.Rows[i].Cells[7].Value = sales.SalesNum; gridMain.Rows[i].Cells[8].Value = sales.SalesDate; gridMain.Rows[i].Cells[9].Value = sales.SalesSum; gridMain.Rows[i].Cells[10].Value = sales.SalesBaseSum; gridMain.Rows[i].Cells[11].Value = sales.SalesTrialSum; salesInterrop.ButtonOkClicked -= new EventHandler(AddRowSalesMain); salesInterrop.Close(); gridMain.Rows[i].Visible = true; salesInterrop = null; sales = null; //указываем активную ячейку gridMain.CurrentCell = gridMain.Rows[i].Cells[4]; }
private void btnEditMain_Click(object sender, EventArgs e) { if (!(gridMain.Rows.Count == 0)) { //cоздаем объект и передаем всплывающей форме sales = new Sales(); int i = gridMain.CurrentCell.RowIndex; sales.SalesID = Convert.ToInt32(gridMain.Rows[i].Cells[0].Value); sales.ContrID = Convert.ToInt32(gridMain.Rows[i].Cells[1].Value); sales.DealID = Convert.ToInt32(gridMain.Rows[i].Cells[2].Value); sales.VAT = Convert.ToInt32(gridMain.Rows[i].Cells[3].Value); sales.ContrName = gridMain.Rows[i].Cells[4].Value.ToString(); sales.DealNumber = gridMain.Rows[i].Cells[5].Value.ToString(); sales.DealDate = Convert.ToDateTime(gridMain.Rows[i].Cells[6].Value); sales.SalesNum = gridMain.Rows[i].Cells[7].Value.ToString(); sales.SalesDate = Convert.ToDateTime(gridMain.Rows[i].Cells[8].Value); sales.SalesSum = Convert.ToDecimal(gridMain.Rows[i].Cells[9].Value); sales.SalesBaseSum = Convert.ToDecimal(gridMain.Rows[i].Cells[10].Value); sales.SalesTrialSum = Convert.ToDecimal(gridMain.Rows[i].Cells[11].Value); using (salesInterrop = new SalesMainInterrop(SalesWinType.MainEdit, sales)) { salesInterrop.ButtonOkClicked += new EventHandler(EditRowSalesMain); salesInterrop.ShowDialog(); } } }
private void btnAddMain_Click(object sender, EventArgs e) { sales = new Sales(); using (salesInterrop = new SalesMainInterrop(SalesWinType.Main, sales)) { salesInterrop.ButtonOkClicked += new EventHandler(AddRowSalesMain); salesInterrop.ShowDialog(); } }
/*Корректировочные акты, грид 2*/ private void btnAddDetail_Click(object sender, EventArgs e) { int i = gridMain.CurrentCell.RowIndex; sales = new Sales(); sales.NumDataParent = gridMain.Rows[i].Cells[7].Value.ToString() + " от " + gridMain.Rows[i].Cells[8].Value.ToString(); using (salesInterrop = new SalesMainInterrop(SalesWinType.Detail, sales)) { salesInterrop.ButtonOkClicked += new EventHandler(AddRowSalesDetail); salesInterrop.ShowDialog(); } }
private void EditRowSalesMain(object sender, EventArgs e) { int i = gridMain.CurrentCell.RowIndex; gridMain.Rows[i].Cells[3].Value = sales.VAT; gridMain.Rows[i].Cells[7].Value = sales.SalesNum; gridMain.Rows[i].Cells[8].Value = sales.SalesDate; gridMain.Rows[i].Cells[9].Value = sales.SalesSum; gridMain.Rows[i].Cells[10].Value = sales.SalesBaseSum; gridMain.Rows[i].Cells[11].Value = sales.SalesTrialSum; //обновление в бд UpdateRowMain(); salesInterrop.ButtonOkClicked -= new EventHandler(EditRowSalesMain); salesInterrop.Close(); salesInterrop = null; sales = null; }