private void wizardFromGRNToolStripButton_Click(object sender, EventArgs e) { IList addedPI = new ArrayList(); for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { GoodReceiveNoteItem pi = (GoodReceiveNoteItem)itemsDataGrid[GRNNoColumn.Index, i].Tag; if (pi == null) { continue; } addedPI.Add(pi.ID); } using (SearchGRNForSuppInvoiceForm frm = new SearchGRNForSuppInvoiceForm( ((Supplier)supplierkryptonComboBox.SelectedItem), addedPI, m_mainForm.CurrentUser, dateKryptonDateTimePicker.Value)) { frm.ShowDialog(); IList result = frm.RESULT; foreach (GoodReceiveNoteItem item in result) { if (item.PO_ITEM.ID > 0) { item.PO_ITEM = r_po.FindPurchaseOrderItem(item.PO_ITEM.ID); } Part p = item.PART; int row = itemsDataGrid.Rows.Add(); itemsDataGrid[codeColumn.Index, row].Tag = p; itemsDataGrid[GRNNoColumn.Index, row].Tag = item; itemsDataGrid[scanColumn.Index, row].Value = p.BARCODE; itemsDataGrid[GRNNoColumn.Index, row].Value = item.EVENT.CODE; itemsDataGrid[codeColumn.Index, row].Value = p.CODE; itemsDataGrid[nameColumn.Index, row].Value = p.NAME; itemsDataGrid[QtyColumn.Index, row].Value = item.OUTSTANDING_AMOUNT_TO_PR; p.UNIT = (Unit)r_unit.GetById(item.UNIT); itemsDataGrid[unitColumn.Index, row].Value = p.UNIT.ToString(); //itemsDataGrid[unitColumn.Index, row].Value = item.UNIT.ToString(); // if (item.UNIT.ID == item.PO_ITEM.UNIT.ID) //{ //itemsDataGrid[priceColumn.Index, row].Value = item.PO_ITEM != null ? item.PO_ITEM.PRICE : 0d; itemsDataGrid[priceColumn.Index, row].Value = item.PO_ITEM != null ? item.PO_ITEM.PRICE_IN_SMALLEST_UNIT : 0d; itemsDataGrid[discpercentColumn.Index, row].Value = item.PO_ITEM != null ? item.PO_ITEM.DISC_PERCENT : 0; itemsDataGrid[discAmountColumn.Index, row].Value = item.PO_ITEM != null ? item.PO_ITEM.DISC_AMOUNT : 0d; itemsDataGrid[totalDiscColumn.Index, row].Value = item.PO_ITEM != null ? item.PO_ITEM.TOTAL_DISCOUNT : 0d; itemsDataGrid[notesColumn.Index, row].Value = item.PO_ITEM != null ? item.PO_ITEM.NOTES : ""; itemsDataGrid[discabcColumn.Index, row].Value = item.PO_ITEM != null ? item.PO_ITEM.DISC_ABC : ""; itemsDataGrid[totalAmountColumn.Index, row].Value = item.PO_ITEM != null ? item.PO_ITEM.SUBTOTAL : 0d; itemsDataGrid[warehouseColumn.Index, row].Value = r_warehouse.GetById(item.WAREHOUSE).ToString(); // } updateSubtotal(row); } } }
private void AddResult() { for (int i = 0; i < gridData.Rows.Count; i++) { bool check = Convert.ToBoolean(gridData[checkColumn.Index, i].Value); if (!check) { continue; } GoodReceiveNoteItem pi = (GoodReceiveNoteItem)gridData.Rows[i].Tag; RESULT.Add(pi); } }
private IList getItems() { IList items = new ArrayList(); for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { Part p = (Part)itemsDataGrid[codeColumn.Index, i].Tag; if (itemsDataGrid[unitColumn.Index, i].Value == null) { continue; } Unit u = (Unit)Utils.FindEntityInList(itemsDataGrid[unitColumn.Index, i].Value.ToString(), m_units); if ((p == null) || (u == null)) { continue; } SupplierInvoiceItem st = (SupplierInvoiceItem)itemsDataGrid.Rows[i].Tag; if (st == null) { st = new SupplierInvoiceItem(); } itemsDataGrid.Rows[i].Tag = st; st.EVENT = m_si; st.PART = p; st.WAREHOUSE = (Warehouse)Utils.FindEntityInList(itemsDataGrid[warehouseColumn.Index, i].Value.ToString(), m_warehouses); st.QYTAMOUNT = Convert.ToDouble(itemsDataGrid[QtyColumn.Index, i].Value); st.UNIT = u; st.PRICE = Convert.ToDouble(itemsDataGrid[priceColumn.Index, i].Value); st.DISC_PERCENT = Convert.ToDouble(itemsDataGrid[discpercentColumn.Index, i].Value); st.DISC_AMOUNT = Convert.ToDouble(itemsDataGrid[discAmountColumn.Index, i].Value); st.TOTAL_DISCOUNT = Convert.ToDouble(itemsDataGrid[totalDiscColumn.Index, i].Value); st.NOTES = itemsDataGrid[notesColumn.Index, i].Value == null ? "" : itemsDataGrid[notesColumn.Index, i].Value.ToString(); st.DISC_ABC = itemsDataGrid[discabcColumn.Index, i].Value == null ? "" : itemsDataGrid[discabcColumn.Index, i].Value.ToString(); st.DISC_A = splitDiscString(st.DISC_ABC, 0); st.DISC_B = splitDiscString(st.DISC_ABC, 1); st.DISC_C = splitDiscString(st.DISC_ABC, 2); st.SUBTOTAL = Convert.ToDouble(itemsDataGrid[totalAmountColumn.Index, i].Value); GoodReceiveNoteItem grn = (GoodReceiveNoteItem)itemsDataGrid[GRNNoColumn.Index, i].Tag; st.GRN_ITEM = grn; if (st.QYTAMOUNT == 0) { continue; } items.Add(st); } return(items); }
private void updateReturned() { for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { GoodReceiveNoteItem st = (GoodReceiveNoteItem)itemsDataGrid.Rows[i].Tag; if (st == null) { continue; } Part p = (Part)itemsDataGrid[codeColumn.Index, i].Tag; if (itemsDataGrid[unitColumn.Index, i].Value == null) { continue; } p.UNIT = (Unit)r_unit.GetById(p.UNIT); itemsDataGrid[returnedColumn.Index, i].Value = r_grn.GetReturned(st.ID); itemsDataGrid[returnedunitColumn.Index, i].Value = p.UNIT.ToString(); } }
private void TestCreate() { PurchaseOrder po = (PurchaseOrder)m_poRep.Get(5); GoodReceiveNote grn = new GoodReceiveNote(); grn.CODE = "GRN001"; grn.EMPLOYEE = new Employee(1); grn.EVENT_STATUS = EventStatus.Entry; grn.NOTES = "TEST IN GRN"; grn.NOTICE_DATE = DateTime.Today; grn.STOCK_CARD_ENTRY_TYPE = StockCardEntryType.GoodReceiveNote; grn.TRANSACTION_DATE = DateTime.Today; GoodReceiveNoteItem grni1 = new GoodReceiveNoteItem(); grni1.EVENT = grn; grni1.NOTES = "TEST GRN ITEM 1"; grni1.PART = new Part(9070); grni1.PO_ITEM = (PurchaseOrderItem)po.EVENT_ITEMS[0]; grni1.QYTAMOUNT = 13000; grni1.RETURNED_AMOUNT = 0; grni1.STOCK_CARD_ENTRY_TYPE = StockCardEntryType.GoodReceiveNote; grni1.UNIT = new Unit(1); grni1.WAREHOUSE = new Warehouse(1); GoodReceiveNoteItem grni2 = new GoodReceiveNoteItem(); grni2.EVENT = grn; grni2.NOTES = "TEST GRN ITEM 1"; grni2.PART = new Part(9071); grni2.PO_ITEM = (PurchaseOrderItem)po.EVENT_ITEMS[1]; grni2.QYTAMOUNT = 1254; grni2.RETURNED_AMOUNT = 0; grni2.STOCK_CARD_ENTRY_TYPE = StockCardEntryType.GoodReceiveNote; grni2.UNIT = new Unit(1); grni2.WAREHOUSE = new Warehouse(1); grn.EVENT_ITEMS.Add(grni1); grn.EVENT_ITEMS.Add(grni2); m_grnRep.Save(grn); }
private IList getItems() { IList items = new ArrayList(); for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { GoodReceiveNoteItem poi = (GoodReceiveNoteItem)itemsDataGrid[scanColumn.Index, i].Tag; if (poi == null) { continue; } Part p = (Part)itemsDataGrid[codeColumn.Index, i].Tag; if (itemsDataGrid[unitColumn.Index, i].Value == null) { continue; } Unit u = (Unit)Utils.FindEntityInList(itemsDataGrid[unitColumn.Index, i].Value.ToString(), m_units); if ((p == null) || (u == null)) { continue; } PurchaseReturnItem st = (PurchaseReturnItem)itemsDataGrid.Rows[i].Tag; if (st == null) { st = new PurchaseReturnItem(); } itemsDataGrid.Rows[i].Tag = st; st.EVENT = m_prn; st.PART = p; st.WAREHOUSE = (Warehouse)Utils.FindEntityInList(itemsDataGrid[warehouseColumn.Index, i].Value.ToString(), m_warehouses); st.QYTAMOUNT = Convert.ToDouble(itemsDataGrid[QtyColumn.Index, i].Value); st.UNIT = u; st.GRN_ITEM = poi; st.NOTES = itemsDataGrid[notesColumn.Index, i].Value == null ? "" : itemsDataGrid[notesColumn.Index, i].Value.ToString(); if (st.QYTAMOUNT == 0) { continue; } items.Add(st); } return(items); }
void Post(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (m_prn.POSTED) { r_prn.Revise(m_prn.ID); m_prn.POSTED = false; KryptonMessageBox.Show("Transaction has been UNPOSTED", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { r_prn.Confirm(m_prn.ID); m_prn.POSTED = true; KryptonMessageBox.Show("Transaction has been POSTED", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } setEnableForm(false); setEditMode(EditMode.View); for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { GoodReceiveNoteItem poi = (GoodReceiveNoteItem)itemsDataGrid[scanColumn.Index, i].Tag; if (poi == null) { continue; } itemsDataGrid[OutstandingPOColumn.Index, i].Value = r_grn.GetReturned(poi.ID); } } catch (Exception x) { KryptonMessageBox.Show(x.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } finally { this.Cursor = Cursors.Default; } }
private void loadMovement() { movemntkryptonDataGridView.Rows.Clear(); if (m_part.ID == 0) { return; } IList movs = r_part.GetAllEvents(m_part.ID); foreach (EventItem itm in movs) { int r = movemntkryptonDataGridView.Rows.Add(); movemntkryptonDataGridView[dateMovementColumn.Index, r].Value = itm.EVENT.TRANSACTION_DATE; movemntkryptonDataGridView[eventCodeMovementColumn.Index, r].Value = itm.EVENT.CODE; movemntkryptonDataGridView[eventTypeMovementColumn.Index, r].Value = itm.STOCK_CARD_ENTRY_TYPE.ToString(); movemntkryptonDataGridView[QtyMovementColumn.Index, r].Value = itm.GetAmountInSmallestUnit(); movemntkryptonDataGridView[unitMovementColumn.Index, r].Value = m_part.UNIT.CODE; movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = "-"; switch (itm.STOCK_CARD_ENTRY_TYPE) { case StockCardEntryType.PurchaseOrder: PurchaseOrderItem pi = (PurchaseOrderItem)itm; PurchaseOrder p = (PurchaseOrder)pi.EVENT; p.SUPPLIER = (Supplier)r_sup.GetById(p.SUPPLIER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = p.SUPPLIER.NAME; break; case StockCardEntryType.SalesOrder: SalesOrderItem soi = (SalesOrderItem)itm; SalesOrder so = (SalesOrder)soi.EVENT; so.CUSTOMER = (Customer)r_cus.GetById(so.CUSTOMER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = so.CUSTOMER.NAME; break; case StockCardEntryType.GoodReceiveNote: GoodReceiveNoteItem grni = (GoodReceiveNoteItem)itm; GoodReceiveNote grn = (GoodReceiveNote)grni.EVENT; grn.SUPPLIER = (Supplier)r_sup.GetById(grn.SUPPLIER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = grn.SUPPLIER.NAME; break; case StockCardEntryType.DeliveryOrder: DeliveryOrderItem doi = (DeliveryOrderItem)itm; DeliveryOrder dor = (DeliveryOrder)doi.EVENT; dor.CUSTOMER = (Customer)r_cus.GetById(dor.CUSTOMER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = dor.CUSTOMER.NAME; break; case StockCardEntryType.SupplierInvoice: SupplierInvoiceItem sii = (SupplierInvoiceItem)itm; SupplierInvoice si = (SupplierInvoice)sii.EVENT; si.SUPPLIER = (Supplier)r_sup.GetById(si.SUPPLIER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = si.SUPPLIER.NAME; break; case StockCardEntryType.CustomerInvoice: CustomerInvoiceItem cii = (CustomerInvoiceItem)itm; CustomerInvoice ci = (CustomerInvoice)cii.EVENT; ci.CUSTOMER = (Customer)r_cus.GetById(ci.CUSTOMER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = ci.CUSTOMER.NAME; break; case StockCardEntryType.PurchaseReturn: PurchaseReturnItem pri = (PurchaseReturnItem)itm; PurchaseReturn pr = (PurchaseReturn)pri.EVENT; pr.SUPPLIER = (Supplier)r_sup.GetById(pr.SUPPLIER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = pr.SUPPLIER.NAME; break; case StockCardEntryType.SalesReturn: SalesReturnItem sri = (SalesReturnItem)itm; SalesReturn sr = (SalesReturn)sri.EVENT; sr.CUSTOMER = (Customer)r_cus.GetById(sr.CUSTOMER); movemntkryptonDataGridView[vendorMovementColumn.Index, r].Value = sr.CUSTOMER.NAME; break; } movemntkryptonDataGridView[statusMovementColumn.Index, r].Value = itm.EVENT.POSTED.ToString(); } UserSetting.AddNumberToGrid(movemntkryptonDataGridView); }
public bool Valid() { errorProvider1.Clear(); bool a = textBoxCode.Text == "" && !r_prn.IsAutoNumber(); bool b = employeeKryptonComboBox.SelectedItem == null; bool k = supplierkryptonComboBox.SelectedItem == null; bool e = false; bool f = m_prn.ID > 0 ? false : r_prn.IsCodeExist(textBoxCode.Text); if (a) { errorProvider1.SetError(textBoxCode, "Code Can not Empty"); } if (b) { errorProvider1.SetError(employeeKryptonComboBox, "Employee Can not Empty"); } if (k) { errorProvider1.SetError(supplierkryptonComboBox, "Supplier Can not Empty"); } if (f) { errorProvider1.SetError(textBoxCode, a ? "Code Can not Empty & Code already used" : "Code already used"); } int j = 0; for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { GoodReceiveNoteItem pi = (GoodReceiveNoteItem)itemsDataGrid[scanColumn.Index, i].Tag; if (pi == null) { continue; } Part p = (Part)itemsDataGrid[codeColumn.Index, i].Tag; if (p == null) { continue; } if (itemsDataGrid[unitColumn.Index, i].Value == null) { itemsDataGrid.Rows[i].ErrorText = "Please choose unit."; e = true; } //if (itemsDataGrid[warehouseColumn.Index, i].Value == null) //{ // itemsDataGrid.Rows[i].ErrorText = "Please choose warehouse."; // e = true; //} double qty = Convert.ToDouble(itemsDataGrid[QtyColumn.Index, i].Value); if (qty == 0) { itemsDataGrid.Rows[i].ErrorText = itemsDataGrid.Rows[i].ErrorText + " Quantity must not 0(zero)"; e = true; } j++; } bool g = j == 0; if (g) { errorProvider1.SetError(itemsDataGrid, "Items must at least 1(one)"); } return(!a && !b && !e && !f && !g); }
void dataItemskryptonDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (m_editMode == EditMode.View) { return; } itemsDataGrid.Rows[e.RowIndex].ErrorText = ""; if (!itemsDataGrid[e.ColumnIndex, e.RowIndex].IsInEditMode) { return; } if (e.ColumnIndex == scanColumn.Index) { if (e.FormattedValue.ToString() == "") { return; } IList addedPI = new ArrayList(); for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { if (i == e.RowIndex) { continue; } GoodReceiveNoteItem pi = (GoodReceiveNoteItem)itemsDataGrid[scanColumn.Index, i].Tag; if (pi == null) { continue; } addedPI.Add(pi.ID); } IList res = r_grn.FindPObyPartAndGRNNo(e.FormattedValue.ToString(), addedPI, ((Supplier)supplierkryptonComboBox.SelectedItem).ID, dateKryptonDateTimePicker.Value); if (res.Count == 0) { using (SearchGRNForPRForm fr = new SearchGRNForPRForm(e.FormattedValue.ToString(), (Supplier)supplierkryptonComboBox.SelectedItem, addedPI, m_mainForm.CurrentUser, dateKryptonDateTimePicker.Value)) { fr.ShowDialog(); IList result = fr.RESULT; m_poItems = result; } } else { m_poItems = res; } } if (QtyColumn.Index == e.ColumnIndex) { GoodReceiveNoteItem pi = (GoodReceiveNoteItem)itemsDataGrid[scanColumn.Index, e.RowIndex].Tag; if (pi == null) { return; } Part p = (Part)itemsDataGrid[codeColumn.Index, e.RowIndex].Tag; if (p == null) { return; } Unit u = (Unit)Utils.FindEntityInList(itemsDataGrid[unitColumn.Index, e.RowIndex].Value.ToString(), m_units); if (u == null) { return; } p.UNIT_CONVERSION_LIST = r_part.GetUnitConversions(p.ID); PurchaseReturnItem sample = new PurchaseReturnItem(); sample.PART = p; sample.UNIT = u; sample.QYTAMOUNT = Convert.ToDouble(e.FormattedValue); double qty = sample.GetAmountInSmallestUnit(); double rest = r_grn.GetOutstandingReturned(pi.ID) - qty; if (rest < 0) { e.Cancel = true; itemsDataGrid.Rows[e.RowIndex].ErrorText = "Quantity exceed outstanding quantity"; } // itemsDataGrid[OutstandingPOColumn.Index, e.RowIndex].Value = r_grn.GetOutstandingReturned(pi.ID); } if (unitColumn.Index == e.ColumnIndex) { GoodReceiveNoteItem pi = (GoodReceiveNoteItem)itemsDataGrid[scanColumn.Index, e.RowIndex].Tag; if (pi == null) { return; } Part p = (Part)itemsDataGrid[codeColumn.Index, e.RowIndex].Tag; if (p == null) { return; } Unit u = (Unit)Utils.FindEntityInList(e.FormattedValue.ToString(), m_units); if (u == null) { return; } p.UNIT_CONVERSION_LIST = r_part.GetUnitConversions(p.ID); GoodReceiveNoteItem sample = new GoodReceiveNoteItem(); sample.PART = p; sample.UNIT = u; sample.QYTAMOUNT = Convert.ToDouble(itemsDataGrid[QtyColumn.Index, e.RowIndex].Value); double qty = sample.GetAmountInSmallestUnit(); double rest = r_grn.GetOutstandingReturned(pi.ID) - qty; if (rest < 0) { e.Cancel = true; itemsDataGrid.Rows[e.RowIndex].ErrorText = "Quantity exceed outstanding quantity"; } //itemsDataGrid[OutstandingPOColumn.Index, e.RowIndex].Value = rest; } }
void dataItemskryptonDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (m_editMode == EditMode.View) { return; } itemsDataGrid.Rows[e.RowIndex].ErrorText = ""; if (!itemsDataGrid[e.ColumnIndex, e.RowIndex].IsInEditMode) { return; } if (e.ColumnIndex == scanColumn.Index) { if (!((DataGridViewTextBoxCell)itemsDataGrid[scanColumn.Index, e.RowIndex]).IsInEditMode) { return; } if (e.FormattedValue.ToString() == "") { return; } IList result = r_part.SearchActivePart(e.FormattedValue.ToString(), true); if (result.Count == 1) { Part p = (Part)result[0]; for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { if (i == e.RowIndex) { continue; } Part pi = (Part)itemsDataGrid[codeColumn.Index, i].Tag; if (pi == null) { continue; } if (pi.ID == p.ID) { itemsDataGrid.Rows[e.RowIndex].ErrorText = "Part : " + p.NAME + " already add."; e.Cancel = true; return; } } itemsDataGrid[codeColumn.Index, e.RowIndex].Tag = p; itemsDataGrid[GRNNoColumn.Index, e.RowIndex].Tag = null; itemsDataGrid[GRNNoColumn.Index, e.RowIndex].Value = ""; itemsDataGrid[scanColumn.Index, e.RowIndex].Value = p.BARCODE; itemsDataGrid[codeColumn.Index, e.RowIndex].Value = p.CODE; itemsDataGrid[nameColumn.Index, e.RowIndex].Value = p.NAME; //dataItemskryptonDataGridView[QtyColumn.Index, e.RowIndex].Value = 0; //unitColumn.Items.Clear(); // IList units = r_part.GetAllUnit(p.ID, p.UNIT.ID); //Utils.GetListCode(unitColumn.Items, units); p.UNIT = (Unit)r_unit.GetById(p.UNIT); itemsDataGrid[unitColumn.Index, e.RowIndex].Value = p.UNIT.ToString(); itemsDataGrid[priceColumn.Index, e.RowIndex].Value = r_si.GetTheLatestSIPrice(((Supplier)supplierkryptonComboBox.SelectedItem).ID, p.ID, p.UNIT.ID); //dataItemskryptonDataGridView[totalAmountColumn.Index, e.RowIndex].Value = 0; itemsDataGrid[warehouseColumn.Index, e.RowIndex].Value = m_warehouses[0].ToString(); } if ((result.Count == 0) || (result.Count > 1)) { using (SearchPartForm fr = new SearchPartForm(e.FormattedValue.ToString(), result)) { fr.ShowDialog(); Part p = fr.PART; if (p == null) { p = (Part)itemsDataGrid[codeColumn.Index, e.RowIndex].Tag; if (p == null) { e.Cancel = true; return; } } else { for (int i = 0; i < itemsDataGrid.Rows.Count; i++) { if (i == e.RowIndex) { continue; } Part pi = (Part)itemsDataGrid[codeColumn.Index, i].Tag; if (pi == null) { continue; } if (pi.ID == p.ID) { itemsDataGrid.Rows[e.RowIndex].ErrorText = "Part : " + p.NAME + " already add."; e.Cancel = true; return; } } itemsDataGrid[codeColumn.Index, e.RowIndex].Tag = p; itemsDataGrid[GRNNoColumn.Index, e.RowIndex].Tag = null; itemsDataGrid[GRNNoColumn.Index, e.RowIndex].Value = ""; itemsDataGrid[scanColumn.Index, e.RowIndex].Value = p.BARCODE; itemsDataGrid[codeColumn.Index, e.RowIndex].Value = p.CODE; itemsDataGrid[nameColumn.Index, e.RowIndex].Value = p.NAME; //dataItemskryptonDataGridView[QtyColumn.Index, e.RowIndex].Value = 0; //unitColumn.Items.Clear(); //IList units = r_part.GetAllUnit(p.ID, p.UNIT.ID); //Utils.GetListCode(unitColumn.Items, units); p.UNIT = (Unit)r_unit.GetById(p.UNIT); itemsDataGrid[unitColumn.Index, e.RowIndex].Value = p.UNIT.ToString(); itemsDataGrid[priceColumn.Index, e.RowIndex].Value = r_si.GetTheLatestSIPrice(((Supplier)supplierkryptonComboBox.SelectedItem).ID, p.ID, p.UNIT.ID); // dataItemskryptonDataGridView[totalAmountColumn.Index, e.RowIndex].Value = 0; itemsDataGrid[warehouseColumn.Index, e.RowIndex].Value = m_warehouses[0].ToString(); } } } } if (e.ColumnIndex == discabcColumn.Index) { if (e.FormattedValue.ToString() == "") { return; } else { try { splitDiscString(e.FormattedValue.ToString(), 0); splitDiscString(e.FormattedValue.ToString(), 1); splitDiscString(e.FormattedValue.ToString(), 2); } catch (Exception x) { itemsDataGrid.Rows[e.RowIndex].ErrorText = x.Message; e.Cancel = true; return; } } } if (e.ColumnIndex == QtyColumn.Index || e.ColumnIndex == unitColumn.Index) { GoodReceiveNoteItem item = (GoodReceiveNoteItem)itemsDataGrid[GRNNoColumn.Index, e.RowIndex].Tag; if (item != null) { if (item.ID == 0) { return; } e.Cancel = true; itemsDataGrid.Rows[e.RowIndex].ErrorText = "GRN Qty / Unit can not change"; } } }