private void lkReceiptInvoice_EditValueChanged(object sender, EventArgs e)
        {
            ResetFields();

            if (lkReceiptInvoice.EditValue != null)
            {
                if ((standardRecType == StandardReceiptType.iGRVOnline || deliveryNoteType == DeliveryNoteType.Automatic) && lkReceiptInvoice.EditValue.Equals(-1))
                {
                    HandleReceiptTypeChange(true);
                    return;
                }

                if (standardRecType == StandardReceiptType.iGRV && !lkReceiptInvoice.EditValue.Equals(-1))
                {
                    //This means, the hub has chosen an invoice other than "Not Found" from the list of invoices.  Therefore, we want to change the receipt type to be iGRV-Online.
                    HandleReceiptTypeChange();
                }

                BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice();
                rctInvoice.LoadByPrimaryKey(Convert.ToInt32(lkReceiptInvoice.EditValue));
                var po = new PO();
                po.LoadByPrimaryKey(rctInvoice.POID);

                if (po.IsElectronic == true)
                {
                    rdIsElectronic.Checked = true;
                    lblSyncDate.Text = rctInvoice.DateOfEntry.ToShortDateString();
                    txtPassCode.Enabled = true;
                    lcPassCode.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                }
                else
                {
                    rdIsElectronic.Checked = false;
                    lblSyncDate.Text = "-";
                    txtPassCode.Enabled = false;
                    lcPassCode.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                }

                lblOrderNo.Text = po.PONumber;
                lblOrderNum.Text = po.PONumber;

                if (!rctInvoice.IsColumnNull("DocumentTypeID"))
                {
                    var doctype = new BLL.DocumentType();
                    doctype.LoadByPrimaryKey(rctInvoice.DocumentTypeID);
                    lblDeliveryNote.Text = doctype.Name;
                    lblHeaderDoc.Text = doctype.Name;
                }
                else
                {
                    lblDeliveryNote.Text = "-";
                    lblHeaderDoc.Text = "-";
                }

                var mode = new Mode();
                mode.LoadByPrimaryKey(po.ModeID);
                lblMode.Text = mode.TypeName;
                lblAccount.Text = "-";
                lblSubAccount.Text = "-";
                lblActivity.Text = "-";
                lblReferenceNo.Text = po.RefNo;

                var payment = new PaymentType();
                payment.LoadByPrimaryKey(po.PaymentTypeID);
                lblPaymentType.Text = payment.Name;
                lblHeaderPayment.Text = payment.Name;

                //if (po.IsColumnNull("NBE"))
                //{
                //    lblNebService.Text = Convert.ToString(po.NBE);
                //}
                //else
                //{
                //    lblNebService.Text = "-";
                //}

                if (po.Remaining != -1)
                    lblRemainingValue.Text = po.Remaining.ToString();
                else
                    lblRemainingValue.Text = "-";

                if (po.TotalValue != -1)
                    lblTotalValue.Text = po.Remaining.ToString();
                else
                    lblTotalValue.Text = "-";

                if (po.Insurance != -1)
                    lblChargeInsurance.Text = po.Insurance.ToString();
                else
                    lblChargeInsurance.Text = "-";

                if (po.NBE != -1)
                    lblNebService.Text = po.NBE.ToString();
                else
                    lblNebService.Text = "-";

                lblOrderDate.Text = po.PODate.ToShortDateString();
                lblReceiptDate.Text = rctInvoice.DateOfEntry.ToShortDateString();

                var user = new User();
                user.LoadByPrimaryKey(po.SavedbyUserID);
                lblOrderBy.Text =  user.FullName;

                var sup = new Supplier();

                lkAccounts.EditValue = rctInvoice.ActivityID;
                var act = new Activity();
                act.LoadByPrimaryKey(rctInvoice.ActivityID);
                _supplierID = rctInvoice.GetSupplier();
                sup.LoadByPrimaryKey(_supplierID);

                lblSupplier.Text = sup.CompanyName;
                lblOrdSup.Text = sup.CompanyName;
                lblInvoiceNo.Text = rctInvoice.STVOrInvoiceNo;

                lblInvAccount.Text = act.AccountName ?? "-";
                lblInvActivity.Text = act.Name ?? "-";
                lblAct.Text = act.FullActivityName ?? "-";
                lblInvSubAccount.Text = act.SubAccountName ?? "-";
                lblInvMode.Text = act.ModeName ?? "-";
                lblInvTotalValue.Text = rctInvoice.TotalFOBValue.ToString("N");
                lblInsurancePolicy.Text = rctInvoice.InsurancePolicyNo == " "? rctInvoice.InsurancePolicyNo : "-";

                var poType = new POType();
                poType.LoadByPrimaryKey(po.PurchaseType);
                lblOrderType.Text = poType.Name ?? "-";
                lblPOType.Text = poType.Name ?? "-";

                var poStatus = new PurchaseOrderStatus();
                poStatus.LoadByPrimaryKey(po.PurchaseOrderStatusID);
                lblOrderStatus.Text = poStatus.Name ?? "-";

                var it = new InvoiceType();
                it.LoadByPrimaryKey(rctInvoice.InvoiceTypeID);
                lblInvType.Text = it.Name;
                lblInvDate.Text = rctInvoice.DateOfEntry.ToShortDateString();

                mode.LoadByPrimaryKey(rctInvoice.ActivityID);

                lblWayBillNo.Text = rctInvoice.WayBillNo;

                txtTransitTransferVoucherNo.Text = rctInvoice.TransitTransferNo;
                txtEditTransferNo.Text = rctInvoice.TransitTransferNo;

                lblInsurancePolicyNo.Text = rctInvoice.InsurancePolicyNo;
                BLL.PO order = new PO();
                order.LoadByPrimaryKey(rctInvoice.POID);
                lblRefNo.Text = order.RefNo;
                lblPoNo.Text = order.PONumber;

                DataTable relatedReceives = rctInvoice.GetRelatedReceives();

                hasPreviousReceive = false;

                if (relatedReceives.Rows.Count > 0)
                {
                    XtraMessageBox.Show(
                        "The Invoice you have selected has previous associated receives",
                        "Invoice Detail", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                        colSelectedManufactuerer.Visible = true;
                        colSelectedUnit.Visible = true;
                        colSelectionLineNo.Visible = true;
                        colSelectedReceiveQty.Visible = true;
                        colSelectedInvoiceQty.Visible = true;
                        hasPreviousReceive = true;
                        gridItemsChoice.Enabled = false;
                        colRemainingQty.VisibleIndex = 9;
                        lcItemChoiceGrid.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                        _dtSelectedTable = relatedReceives.Clone();
                        gridSelected.DataSource = _dtSelectedTable;

                        foreach (DataRow dr in relatedReceives.Rows)
                        {
                            SelectAnItem(dr);
                        }
                }
                else
                {
                    hasPreviousReceive = false;
                    colSelectedManufactuerer.Visible = false;
                    colSelectedUnit.Visible = false;
                    colSelectionLineNo.Visible = false;
                    colSelectedReceiveQty.Visible = false;
                    colSelectedInvoiceQty.Visible = false;
                    colRemainingQty.Visible = false;
                    gridItemsChoice.Enabled = true;
                    lcItemChoiceGrid.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                }

                if (lkAccounts.EditValue != null)
                {
                  //  lcInvoiceDetail.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                }

                if (standardRecType == StandardReceiptType.iGRVOnline || standardRecType == StandardReceiptType.GRV || deliveryNoteType == DeliveryNoteType.Automatic)
                {
                    if (!hasPreviousReceive) LoadItemsFromTransferredReceiptInvoiceDetail(rctInvoice.ID);
                    txtRefNo.Text = lkReceiptInvoice.Text;
                    colSelectedReceiveQty.Visible = true;
                    lcItemChoiceGrid.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    lkAccounts.Enabled = false;
                }
                else
                {
                    lkAccounts.Enabled = !BLL.Settings.IsCenter;
                }

                if(!BLL.Settings.IsCenter)
                {  //Passcode Textbox
                    var dataRowView = lkReceiptInvoice.GetSelectedDataRow() as DataRowView;
                    if (dataRowView != null)
                        _isElectronic = Convert.ToBoolean(dataRowView["IsElectronic"]);

                    lcPassCode.Visibility = (!_isNonElectronicReceiveOnly) && (_isElectronic) && (standardRecType == StandardReceiptType.iGRVOnline || deliveryNoteType == DeliveryNoteType.Automatic)
                                            ? LayoutVisibility.Always
                                            : LayoutVisibility.Never;
                    txtPassCode.Text = "HHMM";
                }

            }
        }
        private HCMIS.Desktop.Reports.ReceiptConfirmationPrintout PrintReceiptConfirmation(int ReceiptID, int? reprintOfReceiptConfirmationPrintoutID)
        {
            ReceiptConfirmationPrintout rc = new ReceiptConfirmationPrintout();

            HCMIS.Desktop.Reports.ReceiptConfirmationPrintout printout = new HCMIS.Desktop.Reports.ReceiptConfirmationPrintout(CurrentContext.LoggedInUserName);

            BLL.ReceiveDoc receiveDoc = new ReceiveDoc();
            //  receiveDoc.LoadByReferenceNo(reference);
            receiveDoc.LoadByReceiptID(ReceiptID);
            var activity = new Activity();
            activity.LoadByPrimaryKey(receiveDoc.StoreID);
            BLL.Supplier supplier = new Supplier();
            supplier.LoadByPrimaryKey(receiveDoc.SupplierID);
            BLL.Receipt receipt=new BLL.Receipt();
            receipt.LoadByPrimaryKey(receiveDoc.ReceiptID);
            BLL.ReceiptInvoice receiptInvoice= new ReceiptInvoice();
            receiptInvoice.LoadByPrimaryKey(receipt.ReceiptInvoiceID);
            BLL.PO po = new PO();
            po.LoadByPrimaryKey(receiptInvoice.POID);
            BLL.POType poType = new POType();
            poType.LoadByPrimaryKey(po.PurchaseType);

            int printedID = 0;
            string GRNFNo = FiscalYear.Current.GetCode(BLL.ReceiptConfirmationPrintout.GetGRNFNo(ReceiptID));
            if (currentMode == Modes.GRVPrinting) //The GRVConfirmation is for reprinting
            {
                printout.BranchName.Text = GeneralInfo.Current.HospitalName;
                PrepareGRVPrintout(printout);
                //  String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();

                if (poType.PurchaseOrderTypeCode == "LP") printout.xrGRVLabel.Text = "GRV No.";
                else printout.xrGRVLabel.Text = "iGRV No.";

                if (supplier.SupplierTypeID == SupplierType.CONSTANTS.HOME_OFFICE ||
                 supplier.SupplierTypeID == SupplierType.CONSTANTS.HUBS ||
                 supplier.SupplierTypeID == SupplierType.CONSTANTS.ACCOUNTS ||
                 supplier.SupplierTypeID == SupplierType.CONSTANTS.STORES)
                {
                    //printout.xrGRVLabel.Text =  "iGRV No.";
                    printout.xrAir.Visible = false;
                    printout.xrAirValue.Visible = false;
                    printout.xrTransit.Visible = false;
                    printout.xrTransitValue.Visible = false;
                    printout.xrInsurance.Visible = false;
                    printout.xrInsuranceValue.Visible = false;
                    printout.xrNumberOfCases.Visible = false;
                    printout.xrNumberOfCasesValue.Visible = false;
                    printout.xrInvoiceNo.Text = "STV No.";
                    printout.xrPurchaseOrderNo.Visible = false;
                    printout.xrPurchaseOrderNoValue.Visible = false;

                    printout.xrLabelGRNF.Text = GRNFNo;
                    printout.xrSTV.Visible = false;
                    printout.xrSTVNoValue.Visible = false;
                    printedID = rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 4,
                                                                    null,reprintOfReceiptConfirmationPrintoutID,FiscalYear.Current);
                    printout.DataSource = rc.DefaultView.ToTable();
                    CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx();
                    //dtDate.CustomFormat = "dd/MM/yyyy";
                    dtDate.Value = receiveDoc.EurDate;

                    printout.Date.Text = dtDate.Text;
                }
                else
                {
                   // printout.xrGRVLabel.Text = "GRV No.";
                    printout.xrSTV.Visible = false;
                    printout.xrSTVNoValue.Visible = false;
                    printedID = rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 2,
                                                                    null, reprintOfReceiptConfirmationPrintoutID,FiscalYear.Current);
                    printout.xrLabelGRNF.Text = GRNFNo;
                    printout.DataSource = rc.DefaultView.ToTable();

                    CalendarLib.DateTimePickerEx dtDate = new CalendarLib.DateTimePickerEx();
                    //dtDate.CustomFormat = "dd/MM/yyyy";
                    dtDate.Value = receiveDoc.EurDate;

                    printout.Date.Text = dtDate.Text;
                }
            }

            printout.xrLabelStoreName.Text = activity.FullActivityName;

            if (ReceiveDoc.IsThereShortageOrDamage(ReceiptID))
            {
                HCMIS.Desktop.Reports.ReceiptConfirmationShortagePrintout printoutShortage =
                    PrintReceiptConfirmationForShortage(ReceiptID, printedID);
                if (currentMode == Modes.GRVPrinting)
                    PrepareGRVPrintout(printoutShortage);
                printout.xrShortageReport.ReportSource = printoutShortage;

                printout.PrintingSystem.ContinuousPageNumbering = true;
            }
            else
            {
                printout.ReportFooter.Visible = false;
            }

            //Release Product
            CostCalculator GRV = new CostCalculator();
            GRV.LoadGRV(ReceiptID);

            String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();

            BLL.ReceiveDoc recDoc = new ReceiveDoc();
            recDoc.LoadByReceiptID(ReceiptID);
            recDoc.ConfirmGRVPrinted(CurrentContext.UserId);
            BLL.Receipt receiptStatus = new BLL.Receipt();
            receiptStatus.LoadByPrimaryKey(ReceiptID);
            receiptStatus.ChangeStatus(ReceiptConfirmationStatus.Constants.GRV_PRINTED, null, this.GetFormIdentifier(), CurrentContext.UserId, "GRV Printed");

            BindFormContents();
            // LOG Cost Analysis printout in PDF Log
            MemoryStream stream = new MemoryStream();
            printout.ExportToPdf(stream);
            HCMIS.Core.Distribution.Services.PrintLogService.SavePrintLogNoWait(stream, "GRV/IGRV", true, ReceiptID, CurrentContext.UserId, BLL.DateTimeHelper.ServerDateTime);
            return printout;
        }
        private void btnEditOrder_Click(object sender, EventArgs e)
        {
            if (BLL.Settings.UseNewUserManagement && !this.HasPermission("Edit-Order"))
            {
                return;
            }

            if (gridOrderView.GetFocusedDataRow() != null && !Convert.ToBoolean(gridOrderView.GetFocusedDataRow()["IsElectronic"]))
            {
                int OrderID = Convert.ToInt32(gridOrderView.GetFocusedDataRow()["ID"]);

                var po = new PO();
                po.LoadByPrimaryKey(OrderID);

                if (po.ReceiveStarted)
                {
                    MessageBox.Show("Editing is not allowed because this order has already been received.", "Edit Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                var dialog = new PODialog(OrderID);
                if (dialog.ShowDialog(this) == DialogResult.Yes)
                {
                    // Reload the PO Grid.
                    RefeshPOGrid();
                }
            }
        }
 /// <summary>
 /// Gets the store ID.
 /// </summary>
 /// <returns></returns>
 public int GetStoreID()
 {
     BLL.PO po = new PO();
     po.LoadByPrimaryKey(this.POID);
     return po.StoreID;
 }
 /// <summary>
 /// Gets the supplier.
 /// </summary>
 /// <returns></returns>
 public int GetSupplier()
 {
     BLL.PO po = new PO();
     po.LoadByPrimaryKey(this.POID);
     return po.SupplierID;
 }
 /// <summary>
 /// Gets the supplier.
 /// </summary>
 /// <returns></returns>
 public int GetSupplier()
 {
     BLL.PO po = new PO();
     po.LoadByPrimaryKey(this.POID);
     return(po.SupplierID);
 }
 /// <summary>
 /// Gets the store ID.
 /// </summary>
 /// <returns></returns>
 public int GetStoreID()
 {
     BLL.PO po = new PO();
     po.LoadByPrimaryKey(this.POID);
     return(po.StoreID);
 }
        private void btnSaveOrder_Click(object sender, EventArgs e)
        {
            if (dxValidation.Validate())
            {
                var po = new PO();
                if (PoID != 0)
                {
                    po.LoadByPrimaryKey(PoID);
                }
                else
                {
                    po.AddNew();
                }
                if (PoID == 0 && po.DoesPONumberExists(txtOrderInformation.Text))
                {
                    XtraMessageBox.Show(string.Format(@"There is an existing Order with the same OrderNo as {0}. Please try to use another OrderNo!",txtOrderInformation.Text), "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (PoID == 0) po.PONumber = txtOrderInformation.Text;
                po.TotalValue = Convert.ToDouble(txtTotalValue.EditValue);
                po.Insurance = Convert.ToDouble(txtInsurance.EditValue);
                po.OtherExpense = Convert.ToDouble(txtInsuredSum.EditValue);
                po.NBE = Convert.ToDouble(txtNBEServiceCharge.EditValue);
                po.SupplierID = Convert.ToInt32(lkSupplier.EditValue);
                po.SavedbyUserID = CurrentContext.LoggedInUser.ID;
                //Make PurchaseType Default Value to Internale ID = 8
                //po.PurchaseType = Convert.ToInt32(gridLkEditOrderType.EditValue) == 0 || Convert.ToInt32(gridLkEditOrderType.EditValue) == null ? POType.GetAllPOTypes().Find(pot=>pot.ID == POType.INTERNAL).ID : Convert.ToInt32(gridLkEditOrderType.EditValue);
                po.PurchaseType =  Convert.ToInt32(gridLkEditOrderType.EditValue);
                po.StoreID = Convert.ToInt32(grdLkEditAccounts.EditValue);
                po.ExhangeRate =Convert.ToDouble(txtExchangeRate.EditValue);
                po.RefNo = txtRefNo.EditValue.ToString();

                po.Delivery = txtDelivery.EditValue != null ? txtDelivery.EditValue.ToString() : "";
                if (txtFreight.EditValue != null)
                {
                    po.AirFreight = Convert.ToDouble(txtFreight.EditValue);
                }
                po.Description = txtDescription.EditValue != null ? txtDescription.EditValue.ToString() : "";

                var serverDateTime = DateTimeHelper.ServerDateTime;
                po.PODate = serverDateTime;
                po.DateOfEntry = serverDateTime;
                po.LCID = Convert.ToInt32(lkCurrencyLCID.EditValue);
                //Make TermOfPayment Default to Internal , ID = 7,
                //po.TermOfPayement = Convert.ToInt32(lkTermOfPayement.EditValue) == 0 || Convert.ToInt32(lkTermOfPayement.EditValue) == null ? TermOfPayment.List[6].ID : Convert.ToInt32(lkTermOfPayement.EditValue);
                po.TermOfPayement = Convert.ToInt32(lkTermOfPayement.EditValue) == 0 || Convert.ToInt32(lkTermOfPayement.EditValue) == null ? PaymentTerm.Internal : Convert.ToInt32(lkTermOfPayement.EditValue);
                po.PaymentTypeID = PaymentType.Constants.STV;
                po.PurchaseOrderStatusID = PurchaseOrderStatus.Processed; //PurchaseOrderStatus ==> Processed

                po.IsElectronic = false;
                po.POFinalized = false;
                po.Rowguid = Guid.NewGuid();
                po.Identifier = "00000";

                var acc = new Activity();
                acc.LoadByPrimaryKey(po.StoreID);
                po.ModeID = acc.ModeID;
                po.Save();

                this.LogActivity("Save-PO", po.ID);
                this.DialogResult = DialogResult.Yes;
                this.Close();

            }
        }
        private void LoadPurchaseOrderForEdit()
        {
            PO po = new PO();
            po.LoadByPrimaryKey(PoID);

            //TODO: Populate the data
            if (!po.IsColumnNull("Insurance"))
                 txtInsurance.EditValue = po.Insurance;

            txtOrderInformation.EditValue = po.PONumber;
            if (!po.IsColumnNull("TotalValue"))
                txtTotalValue.EditValue = po.TotalValue;
            if (!po.IsColumnNull("SupplierID"))
                lkSupplier.EditValue = po.SupplierID;
            if (!po.IsColumnNull("PurchaseType"))
                gridLkEditOrderType.EditValue = po.PurchaseType;
            if (!po.IsColumnNull("StoreID"))
                grdLkEditAccounts.EditValue = po.StoreID;

            if (!po.IsColumnNull("LCID"))
                LCID = po.LCID;
            //Currency and Formating
            lkCurrencyLCID.EditValue = LCID;
                txtTotalValue.Properties.DisplayFormat.FormatString = Helpers.FormattingHelpers.GetCurrencyFormatByLCID(Convert.ToInt32(LCID));

            if(!po.IsColumnNull("NBE"))
                txtNBEServiceCharge.EditValue = po.NBE;
            if (!po.IsColumnNull("ExhangeRate"))
                txtExchangeRate.EditValue = po.ExhangeRate;
            if (po.s_OtherExpense != "")
                txtInsuredSum.EditValue = po.OtherExpense;
            if (!po.IsColumnNull("RefNo"))
                txtRefNo.EditValue = po.RefNo;
            if (!po.IsColumnNull("Delivery"))
                txtDelivery.EditValue = po.Delivery;
            if (!po.IsColumnNull("Description"))
                txtDescription.EditValue = po.Description;
            if (!po.IsColumnNull("TermOfPayement"))
                lkTermOfPayement.EditValue = po.TermOfPayement;
            if (!po.IsColumnNull("AirFreight"))
                txtFreight.EditValue = po.AirFreight;
            DisableEditDependingOnSetting();
        }
Пример #10
0
        private void LoadData(int ReceiptID, int InvoiceID, int PoID)
        {
            //PO Cost Elements;
            purchaseOrder.LoadByPrimaryKey(PoID);
            Invoice.LoadByPrimaryKey(InvoiceID);
            GRV.LoadByPrimaryKey(ReceiptID);

            if (Invoice.IsColumnNull("InvoiceTypeID"))
            {
                Invoice.InvoiceTypeID = ReceiptInvoiceType.InvoiceType.NON_STANDARD;
            }
            if (Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.INVOICE_SEA)
            {
                UseSeaFreight = true;
            }
            else
            {
                UseSeaFreight = false;
            }

            if (!purchaseOrder.IsColumnNull("TotalValue"))
            {
                PurchaseOrderTotal = purchaseOrder.TotalValue;
            }
            if (!purchaseOrder.IsColumnNull("AirFreight"))
            {
                PurchaseOrderAirFreight = purchaseOrder.AirFreight;
            }
            if (!purchaseOrder.IsColumnNull("SeaFreight"))
            {
                PurchaseOrderSeaFreight = purchaseOrder.SeaFreight;
            }
            if (!purchaseOrder.IsColumnNull("Insurance"))
            {
                PurchaseOrderInsurance = purchaseOrder.Insurance;
            }
            if (!purchaseOrder.IsColumnNull("NBE"))
            {
                PurcahseOrderNBE = purchaseOrder.NBE;
            }

            //Invoice Cost Elements;
            if (!Invoice.IsColumnNull("TotalValue"))
            {
                InvoiceTotal = Invoice.TotalValue;
            }
            if (!Invoice.IsColumnNull("AirFreight"))
            {
                InvoiceAirFreight = Invoice.AirFreight;
            }
            if (!Invoice.IsColumnNull("SeaFreight"))
            {
                InvoiceSeaFreight = Invoice.SeaFreight;
            }
            if (!Invoice.IsColumnNull("InlandFreight"))
            {
                InvoiceInlandFreight = Invoice.InlandFreight;
            }
            if (!Invoice.IsColumnNull("Insurance"))
            {
                InvoiceInsurance = Invoice.Insurance;
            }
            if (!Invoice.IsColumnNull("NBE"))
            {
                InvoiceNBE = Invoice.NBE;
            }
            if (!Invoice.IsColumnNull("CBE"))
            {
                InvoiceCBE = Invoice.CBE;
            }
            if (!Invoice.IsColumnNull("CustomDutyTax"))
            {
                InvoiceCustomDutyTax = Invoice.CustomDutyTax;
            }


            //GRV Cost Elements



            if (UseSeaFreight)
            {
                if (!GRV.IsColumnNull("SeaFreight"))
                {
                    GRVSeaFreight = GRV.SeaFreight;
                }
            }
            else
            {
                if (!GRV.IsColumnNull("AirFreight"))
                {
                    GRVAirFreight = GRV.AirFreight;
                }
            }

            if (!GRV.IsColumnNull("InlandFreight"))
            {
                GRVInlandFreight = GRV.InlandFreight;
            }

            if (!GRV.IsColumnNull("Insurance"))
            {
                GRVInsurance = GRV.Insurance;
            }

            if (!GRV.IsColumnNull("NBE"))
            {
                GRVNBE = GRV.NBE;
            }

            if (!GRV.IsColumnNull("CBE"))
            {
                GRVCBE = GRV.CBE;
            }

            if (!GRV.IsColumnNull("CustomDutyTax"))
            {
                GRVCustomDutyTax = GRV.CustomDutyTax;
            }

            if (!GRV.IsColumnNull("TransitServiceCharge"))
            {
                GRVTransit = GRV.TransitServiceCharge;
            }
            else
            {
                GRVTransit = UseTransitServiceCharge ? 250 : 0;
            }

            //if (!GRV.IsColumnNull("OtherExpenses"))
            //  GRVOtherExpense = GRV;

            //Exchange rate
            if (!purchaseOrder.IsColumnNull("ExhangeRate"))
            {
                FOBExchangeRate = purchaseOrder.ExhangeRate;
            }
            if (!Invoice.IsColumnNull("ExchangeRate"))
            {
                FreightExchangeRate = Invoice.ExchangeRate;
            }
        }