public void loadcategory() { CourierDataDataContext courdatacontext = new CourierDataDataContext(Program.ConnStr); var q = from category in courdatacontext.Category_Masters select category; cmbcomplex.DataSource = q; cmbcomplex.DisplayMember = "CategoryName"; cmbcomplex.ValueMember = "CategoryIID"; } public void LoadAtcnum() { CourierDataDataContext couriercontext = new CourierDataDataContext(Program.ConnStr); var q = from cust in couriercontext.Atc_masters select cust; AtcNO.DataSource = q; AtcNO.DisplayMember = "AtcNum"; AtcNO.ValueMember = "Atc_id"; } private void tbl_bookdata_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { try { if (tbl_bookdata.CurrentCell.ColumnIndex == 10 && e.Control is ComboBox) { ComboBox comboBox = e.Control as ComboBox; comboBox.SelectionChangeCommitted -= new EventHandler(cmb_SelectionChangeCommitted); comboBox.SelectionChangeCommitted += new EventHandler(cmb_SelectionChangeCommitted); comboBox.SelectedIndexChanged += LastColumnComboSelectionChanged; } } catch (Exception) { MessageBox.Show("bl_bookdata_EditingControlShowingd"); } } void cmb_SelectionChangeCommitted(object sender, EventArgs e) { try { tbl_bookdata.Rows[tbl_bookdata.CurrentRow.Index].Cells[10].Value = ((DataGridViewComboBoxEditingControl)sender).EditingControlFormattedValue; } catch (Exception) { MessageBox.Show("Error in cmb_SelectionChangeCommitted"); } } private void LastColumnComboSelectionChanged(object sender, EventArgs e) { // ((ComboBox)sender) if (tbl_bookdata.CurrentCell.ColumnIndex != 16) { var currentcell = tbl_bookdata.CurrentCellAddress; var sendingCB = sender as DataGridViewComboBoxEditingControl; DataGridViewTextBoxCell cel = (DataGridViewTextBoxCell)tbl_bookdata.Rows[currentcell.Y].Cells[11]; DataGridViewTextBoxCell cel1 = (DataGridViewTextBoxCell)tbl_bookdata.Rows[currentcell.Y].Cells[18]; int rownumber = tbl_bookdata.CurrentRow.Index; try { int factid = int.Parse(tbl_bookdata.Rows[rownumber].Cells[1].Value.ToString()); int catgid = 0; try { catgid = int.Parse(tbl_bookdata.Rows[rownumber].Cells[10].Value.ToString()); } catch (Exception) { string catgid12 = ((ComboBox)sender).SelectedValue.ToString(); catgid = int.Parse(catgid12); } int orderqty = int.Parse(tbl_bookdata.Rows[rownumber].Cells[7].Value.ToString()); int consumptionvalue = qtycal.calculatedata(catgid, factid, orderqty); cel.Value = consumptionvalue.ToString(); cel1.Value = consumptionvalue.ToString(); } catch (Exception) { cel.Value = 0; MessageBox.Show("LastColumnComboSelectionChanged"); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)