private void gridInvoiceDetailView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e != null && e.Column.FieldName == "InvoiceCost") { DataRow drv = gridInvoiceDetailView.GetFocusedDataRow(); // receipt.SaveFOBForEachReceiveDoc(); if (drv["InvoiceCost"] != DBNull.Value) { using (PricePerPackPage pricePerPackPage = new PricePerPackPage(ReceiptID, Convert.ToInt32(drv["ItemID"]), Convert.ToInt32(drv["ItemUnitID"]), Convert.ToInt32(drv["ManufacturerID"]), Convert.ToInt32(drv["ActivityID"]), Convert.ToDouble(drv["InvoiceCost"]))) { pricePerPackPage.ShowDialog(this); } LoadSelectedGRVDetailForInvoiceEntry(ReceiptID); } } else if (e != null && e.Column.FieldName == "Margin") { DataRow drv = gridInvoiceDetailView.GetFocusedDataRow(); // receipt.SaveFOBForEachReceiveDoc(); if (drv["Margin"] != DBNull.Value) { using (MarginPage marginPage = new MarginPage(ReceiptID, Convert.ToInt32(drv["ItemID"]), Convert.ToInt32(drv["ItemUnitID"]), Convert.ToInt32(drv["ManufacturerID"]), Convert.ToInt32(drv["ActivityID"]), Convert.ToDouble(drv["Margin"]))) { marginPage.ShowDialog(this); } LoadSelectedGRVDetailForInvoiceEntry(ReceiptID); } } }
private void gridInvoiceDetailView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e != null && e.Column.FieldName == "InvoiceCost") { DataRow drv = gridInvoiceDetailView.GetFocusedDataRow(); // receipt.SaveFOBForEachReceiveDoc(); var receipt = new BLL.Receipt(Convert.ToInt32(drv["ReceiptID"])); var receiptInvoice = new ReceiptInvoice(receipt.ReceiptInvoiceID); var po = new BLL.PO(receiptInvoice.POID); if (po.IsElectronic) { var originalInvoiceCost = Convert.ToDecimal(drv["OriginalInvoiceCost"]); var newInvoiceCost = Convert.ToDecimal(drv["InvoiceCost"]); if (newInvoiceCost != originalInvoiceCost) { drv["InvoiceCost"] = originalInvoiceCost; XtraMessageBox.Show("You are trying to change the Invoice Cost set by Center. Please enter the correct cost!", "Invoice Cost Not Similar", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (drv["InvoiceCost"] != DBNull.Value) { PricePerPackPage PricingForm = new PricePerPackPage(ReceiptID, Convert.ToInt32(drv["ItemID"]), Convert.ToInt32(drv["ItemUnitID"]), Convert.ToInt32(drv["ManufacturerID"]), Convert.ToInt32(drv["ActivityID"]), Convert.ToDouble(drv["InvoiceCost"])); PricingForm.ShowDialog(this); LoadSelectedGRVDetailForInvoiceEntry(ReceiptID); } } else if (e != null && e.Column.FieldName == "Margin") { DataRow drv = gridInvoiceDetailView.GetFocusedDataRow(); // receipt.SaveFOBForEachReceiveDoc(); var receipt = new BLL.Receipt(Convert.ToInt32(drv["ReceiptID"])); var receiptInvoice = new ReceiptInvoice(receipt.ReceiptInvoiceID); var po = new BLL.PO(receiptInvoice.POID); var item = new Item(); item.LoadByPrimaryKey(Convert.ToInt32(drv["ItemID"])); if (po.IsElectronic && !item.IsVariableMargin) { var originalMargin = Convert.ToDecimal(drv["OriginalMargin"]); var newMargin = Convert.ToDecimal(drv["Margin"]); if (newMargin != originalMargin) { drv["Margin"] = originalMargin; XtraMessageBox.Show("You are trying to change the Margin set by Center. Please enter the correct Margin!", "Margin Not Similar", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (drv["Margin"] != DBNull.Value) { MarginPage MarginForm = new MarginPage(ReceiptID, Convert.ToInt32(drv["ItemID"]), Convert.ToInt32(drv["ItemUnitID"]), Convert.ToInt32(drv["ManufacturerID"]), Convert.ToInt32(drv["ActivityID"]), Convert.ToDouble(drv["Margin"])); MarginForm.ShowDialog(this); LoadSelectedGRVDetailForInvoiceEntry(ReceiptID); } } }