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"; } } }
public static List <ReceiptInvoice> ToList(BLL.ReceiptInvoice v) { List <ReceiptInvoice> list = new List <ReceiptInvoice>(); while (!v.EOF) { ReceiptInvoice t = new ReceiptInvoice(); if (!v.IsColumnNull("ID")) { t.ID = v.ID; } if (!v.IsColumnNull("InvoiceTypeID")) { t.InvoiceTypeID = v.InvoiceTypeID; } if (!v.IsColumnNull("STVOrInvoiceNo")) { t.STVOrInvoiceNo = v.STVOrInvoiceNo; } if (!v.IsColumnNull("WayBillNo")) { t.WayBillNo = v.WayBillNo; } if (!v.IsColumnNull("TransitTransferNo")) { t.TransitTransferNo = v.TransitTransferNo; } if (!v.IsColumnNull("InsurancePolicyNo")) { t.InsurancePolicyNo = v.InsurancePolicyNo; } if (!v.IsColumnNull("DateOfEntry")) { t.DateOfEntry = v.DateOfEntry; } if (!v.IsColumnNull("ReceiptInvoiceType")) { t.ReceiptInvoiceType = v.ReceiptInvoiceType; } if (!v.IsColumnNull("TotalValue")) { t.TotalValue = v.TotalValue; } if (!v.IsColumnNull("Insurance")) { t.Insurance = v.Insurance; } if (!v.IsColumnNull("AirFreight")) { t.AirFreight = v.AirFreight; } if (!v.IsColumnNull("SeaFreight")) { t.SeaFreight = v.SeaFreight; } if (!v.IsColumnNull("InlandFreight")) { t.InlandFreight = v.InlandFreight; } if (!v.IsColumnNull("NBE")) { t.NBE = v.NBE; } if (!v.IsColumnNull("CBE")) { t.CBE = v.CBE; } if (!v.IsColumnNull("CustomDutyTax")) { t.CustomDutyTax = v.CustomDutyTax; } if (!v.IsColumnNull("TransitServiceCharge")) { t.TransitServiceCharge = v.TransitServiceCharge; } if (!v.IsColumnNull("Provision")) { t.Provision = v.Provision; } if (!v.IsColumnNull("OtherExpense")) { t.OtherExpense = v.OtherExpense; } if (!v.IsColumnNull("ExchangeRate")) { t.ExchangeRate = v.ExchangeRate; } if (!v.IsColumnNull("SavedByUserID")) { t.SavedByUserID = v.SavedByUserID; } if (!v.IsColumnNull("POID")) { t.POID = v.POID; } if (!v.IsColumnNull("Currency")) { t.Currency = v.Currency; } if (!v.IsColumnNull("LCID")) { t.LCID = v.LCID; } list.Add(t); v.MoveNext(); } return(list); }
private void btnSaveInvoice_Click(object sender, EventArgs e) { PO po = new PO(_orderID); if (dxValidation.Validate()) { ReceiptInvoice invoice = new ReceiptInvoice(); if (_receiptInvoiceID != 0) { invoice.LoadByPrimaryKey(_receiptInvoiceID); } else { invoice.AddNew(); } //TODO: save the Invoice Type Here. invoice.InvoiceTypeID = 1; invoice.InsurancePolicyNo = txtInsurance.Text; double TotalValue = 0; if (!invoice.IsColumnNull("TotalValue")) { TotalValue = invoice.TotalValue; } if (_receiptInvoiceID != 0 && po.Remaining + TotalValue < Convert.ToDouble(txtTotalValue.EditValue) && POType.GetModes(po.PurchaseType) == POType.STANDARD) { XtraMessageBox.Show("Invoice value can't be be greater than Order value", "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } invoice.TotalValue = Convert.ToDouble(txtTotalValue.EditValue); if (po.Remaining < invoice.TotalValue && POType.GetModes(po.PurchaseType) == POType.STANDARD && _receiptInvoiceID == 0) { XtraMessageBox.Show("Invoice value can't be be greater than Order value", "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } invoice.WayBillNo = txtWayBill.Text; invoice.TransitTransferNo = txtTransitNumber.Text; invoice.STVOrInvoiceNo = txtInvoiceNumber.Text; invoice.POID = _orderID; invoice.SavedByUserID = CurrentContext.UserId; invoice.AirFreight = Convert.ToDouble(txtInvoiceAirFreight.EditValue); invoice.SeaFreight = Convert.ToDouble(txtInvoiceSeaFreight.EditValue); invoice.InlandFreight = Convert.ToDouble(txtInvoiceInlandFreight.EditValue); invoice.CustomDutyTax = Convert.ToDouble(txtInvoiceCustomDutyTax.EditValue); invoice.CBE = Convert.ToDouble(txtInvoiceCBEServiceCharge.EditValue); invoice.InvoiceTypeID = Convert.ToInt32(lkInvoiceType.EditValue); invoice.DateOfEntry = Convert.ToDateTime(dtInvoiceDate.EditValue); invoice.ExchangeRate = Convert.ToDouble(txtExchangeRate.EditValue); invoice.LCID = Convert.ToInt32(lkCurrencyLCID.EditValue); invoice.ActivityID = po.StoreID; invoice.Rowguid = Guid.NewGuid(); invoice.PrintedDate = dtInvoiceDate.DateTime; invoice.IsVoided = false ; invoice.ShippingSite = " "; invoice.IsConvertedFromDeliveryNote = false; invoice.IsDeliveryNote = Convert.ToInt32(lkDocumentType.EditValue) == DocumentType.CONSTANTS.DLVN; if (Convert.ToInt32(lkDocumentType.EditValue) != -1) invoice.DocumentTypeID = Convert.ToInt32(lkDocumentType.EditValue); invoice.Save(); this.LogActivity("Save-Invoice", invoice.ID); lblInvoiceNoDetail.Text = txtInvoiceNumber.EditValue.ToString(); lblInvoiceTypeDetail.Text = lkInvoiceType.Text; BLL.Receipt receipt = new BLL.Receipt(); receipt.UpdateInvoiceRelatedHeaders(invoice); _receiptInvoiceID = invoice.ID; MessageBox.Show("Invoice saved!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); HeaderGroupDetail.Text = "Invoice No: " + txtInvoiceNumber.EditValue.ToString(); } }
private void ReceiptInvoiceDialog_Load(object sender, EventArgs e) { InitializeForm(); LayoutAndBindingByAccess(); LoadDecimalFormatings(); ConstructTableColumns(); gridViewInvoiceDetail.RowStyle += new RowStyleEventHandler(gridInvoiceDetail_RowStyle); lkInvoiceType.Properties.DataSource = BLL.Settings.IsCenter ? ReceiptInvoiceType.GetAllInvoiceTypes() : ReceiptInvoiceType.GetAllInvoiceTypeByCode("INT"); //Internal for Hubs lkInvoiceType.EditValue = BLL.Settings.IsCenter ? -1 : ReceiptInvoiceType.InvoiceType.INTERNAL; lkCurrencyLCID.Properties.DataSource = Helpers.FormattingHelpers.GetCurrencyList(); var etb = Convert.ToInt32(Helpers.FormattingHelpers.GetCurrencyList().ToTable().Select("Symbol = 'ETB'")[0]["ID"]); lkCurrencyLCID.EditValue = etb; //ETB is the default value PO Order = new PO(_orderID); if (_orderID != 0) { Activity act = new Activity(); act.LoadByPrimaryKey(Order.StoreID); lblAccount.Text = act.AccountName; lblAccountDetail.Text = act.AccountName; lblSubAccount.Text = act.SubAccountName; lblSubAccountDetail.Text = act.SubAccountName; lblActivity.Text = act.Name; lblActivityDetail.Text = act.Name; lblPOType.Text = POType.GetPOTypeNameByID(Order.PurchaseType); lblPOTypeDetail.Text = POType.GetPOTypeNameByID(Order.PurchaseType); lblPONumberDetail.Text = Order.PONumber.ToString(); //lblInvoiceNoDetail.Text = var poStatus = new PurchaseOrderStatus(); poStatus.LoadByPrimaryKey(Order.PurchaseOrderStatusID); lblOrderStatus.Text = poStatus.Name; var Mode = new Mode(); Mode.LoadByPrimaryKey(Order.ModeID); lblMode.Text = Mode.TypeName; lblModeDetail.Text = Mode.TypeName; var receiptInvoice = new ReceiptInvoice(); receiptInvoice.LoadForPO(_orderID); try { lblInvoiceNoDetail.Text = !receiptInvoice.IsColumnNull("STVOrInvoiceNo") ? receiptInvoice.STVOrInvoiceNo : "-"; } catch (Exception) { lblInvoiceNoDetail.Text = "-"; } var invoiceType = new ReceiptInvoiceType(); HeaderGroup.Text = "PO No: " + Order.PONumber; } //documentType var po = new PO(_orderID); var documentTypes = BLL.DocumentType.GetDocumentTypesByPOType(po.PurchaseType); lkDocumentType.Properties.DataSource = documentTypes; lkDocumentType.EditValue = documentTypes.Rows.Count > 0 ? documentTypes.Rows[0]["DocumentTypeID"] : -1; if (_receiptInvoiceID != 0) { ReceiptInvoice rinvoice = new ReceiptInvoice(_receiptInvoiceID); //bind data to invoicedetail tab BindInvoiceDetail(rinvoice); lblOrderNumber.Text = rinvoice.PO.PONumber; lblSupplier.Text = rinvoice.PO.Supplier.IsActive ? rinvoice.PO.Supplier.CompanyName : ""; lblRefNo.Text = rinvoice.PO.RefNo != "" ? rinvoice.PO.RefNo : "-"; gridGrv.DataSource = rinvoice.Receipts.DefaultView; txtInsurance.Text = rinvoice.InsurancePolicyNo; txtInvoiceNumber.Text = rinvoice.STVOrInvoiceNo; txtTransitNumber.Text = rinvoice.TransitTransferNo; txtWayBill.Text = rinvoice.WayBillNo; dtInvoiceDate.EditValue = !rinvoice.IsColumnNull("DateofEntry") ? rinvoice.DateOfEntry : DateTimeHelper.ServerDateTime; txtTotalValue.EditValue = !rinvoice.IsColumnNull("TotalValue") ? rinvoice.TotalValue : 0; lkInvoiceType.EditValue = !rinvoice.IsColumnNull("InvoiceTypeID") ? rinvoice.InvoiceTypeID : 0; txtInvoiceAirFreight.EditValue = !rinvoice.IsColumnNull("AirFreight") ? rinvoice.AirFreight : 0; txtInvoiceSeaFreight.EditValue = !rinvoice.IsColumnNull("SeaFreight") ? rinvoice.SeaFreight : 0; txtInvoiceInlandFreight.EditValue = !rinvoice.IsColumnNull("InlandFreight") ? rinvoice.InlandFreight : 0; txtInvoiceCustomDutyTax.EditValue = !rinvoice.IsColumnNull("CustomDutyTax") ? rinvoice.CustomDutyTax : 0; txtInvoiceCBEServiceCharge.EditValue = !rinvoice.IsColumnNull("CBE") ? rinvoice.CBE : 0; txtExchangeRate.EditValue = !rinvoice.IsColumnNull("ExchangeRate") ? rinvoice.ExchangeRate : 1; lkCurrencyLCID.EditValue = _currency = !rinvoice.IsColumnNull("LCID") ? rinvoice.LCID : 0; lkDocumentType.EditValue = !rinvoice.IsColumnNull("DocumentTypeID") ? rinvoice.DocumentTypeID : -1; DisableEditDependingOnSetting(); var activity = new Activity(); activity.LoadByPrimaryKey(rinvoice.ActivityID); if (activity.IsHealthProgram()) { txtInvoiceCustomDutyTax.EditValue = 0; txtInvoiceCustomDutyTax.Enabled = false; } // var receiptINvoice = new ReceiptInvoice(); // receiptINvoice.LoadForPO(_orderID); lblInvoiceNoDetail.Text = rinvoice.STVOrInvoiceNo.ToString(); lblInvoiceTypeDetail.Text = lkInvoiceType.Text; } else { PO PO = new PO(_orderID); lblOrderNumber.Text = PO.PONumber; BindInvoiceDetailByPO(PO.ID); lblSupplier.Text = PO.Supplier.IsActive ? PO.Supplier.CompanyName : "_"; lkCurrencyLCID.EditValue = 1118; //ETB is the dafault lblRefNo.Text = PO.RefNo != "" ? PO.RefNo : "-"; if (PO.StoreID != null) { var activity = new Activity(); activity.LoadByPrimaryKey(po.StoreID); if (activity.IsHealthProgram()) { txtInvoiceCustomDutyTax.EditValue = 0; txtInvoiceCustomDutyTax.Enabled = false; } } layoutGoodsReceived.Enabled = false; } //gridViewInvoiceDetail.ValidateRow += GridViewInvoiceDetailOnValidateRow; }
public void LoadByReceiptIDInvoiceIDAndPoID(int ReceiptID, int InvoiceID, int PoID, string GRNString,double GRVTotalValue) { purchaseOrder = new PO(); Invoice = new ReceiptInvoice(); GRV = new Receipt(); //Load this.GRVTotal = GRVTotalValue; LoadData(ReceiptID, InvoiceID, PoID); _activity = new Activity(); _activity.LoadByPrimaryKey(Invoice.ActivityID); Supplier = purchaseOrder.Supplier.CompanyName; OrderNo = purchaseOrder.PONumber; InvoiceNo = Invoice.STVOrInvoiceNo; GRVNo = GRNString; AWBNo = Invoice.WayBillNo; ShippedBy = Invoice.ShippedBy; if (Invoice.IsColumnNull("InvoiceTypeID") || GRV.ReceiptTypeID == ReceiptType.CONSTANTS.STOCK_RETURN) { AutoProrate = false; purchaseOrder.ExhangeRate = FOBExchangeRate = 1; } else if (Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.NON_STANDARD) { AutoProrate = false; purchaseOrder.ExhangeRate = FOBExchangeRate = 1; } else { if (purchaseOrder.PurchaseType == POType.COST_AND_EST_FREIGHT) { ProrateUsingFreightOnPO = true; ProrateUsingFreightOnInvoice = true; UsePOFreight = true; } else if (purchaseOrder.PurchaseType == POType.COST_AND_FREIGHT) { ProrateUsingFreightOnPO = true; ProrateUsingFreightOnInvoice = true; UsePOFreight = false; } } if (!_activity.IsHealthProgram()) UseCustomDutyTax = true; if (AutoProrate && Invoice.InvoiceTypeID != -255 && Invoice.InvoiceTypeID != InvoiceType.Internal) Prorate(); if (Invoice.IsColumnNull("InvoiceTypeID") || Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.LOCAL_PURCHASE || Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.CIP || Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.NON_STANDARD || _activity.IsHealthProgram()) UseProvison = false; else UseProvison = true; CalculateCostCoefficient(); PopulateDataTable(); }
private void ReceiptInvoiceDialog_Load(object sender, EventArgs e) { InitializeForm(); LayoutAndBindingByAccess(); LoadDecimalFormatings(); ConstructTableColumns(); gridViewInvoiceDetail.RowStyle += new RowStyleEventHandler(gridInvoiceDetail_RowStyle); lkInvoiceType.Properties.DataSource = BLL.Settings.IsCenter ? ReceiptInvoiceType.GetAllInvoiceTypes() : ReceiptInvoiceType.GetAllInvoiceTypeByCode("INT"); //Internal for Hubs lkInvoiceType.EditValue = BLL.Settings.IsCenter ? -1 : ReceiptInvoiceType.InvoiceType.INTERNAL; lkCurrencyLCID.Properties.DataSource = Helpers.FormattingHelpers.GetCurrencyList(); var etb = Convert.ToInt32(Helpers.FormattingHelpers.GetCurrencyList().ToTable().Select("Symbol = 'ETB'")[0]["ID"]); lkCurrencyLCID.EditValue = etb; //ETB is the default value PO Order = new PO(_orderID); if (_orderID != 0) { Activity act = new Activity(); act.LoadByPrimaryKey(Order.StoreID); lblAccount.Text = act.AccountName; lblAccountDetail.Text = act.AccountName; lblSubAccount.Text = act.SubAccountName; lblSubAccountDetail.Text = act.SubAccountName; lblActivity.Text = act.Name; lblActivityDetail.Text = act.Name; lblPOType.Text = POType.GetPOTypeNameByID(Order.PurchaseType); lblPOTypeDetail.Text = POType.GetPOTypeNameByID(Order.PurchaseType); lblPONumberDetail.Text = Order.PONumber.ToString(); //lblInvoiceNoDetail.Text = var poStatus = new PurchaseOrderStatus(); poStatus.LoadByPrimaryKey(Order.PurchaseOrderStatusID); lblOrderStatus.Text = poStatus.Name; var Mode = new Mode(); Mode.LoadByPrimaryKey(Order.ModeID); lblMode.Text = Mode.TypeName; lblModeDetail.Text = Mode.TypeName; var receiptInvoice = new ReceiptInvoice(); receiptInvoice.LoadForPO(_orderID); try { lblInvoiceNoDetail.Text = !receiptInvoice.IsColumnNull("STVOrInvoiceNo") ? receiptInvoice.STVOrInvoiceNo : "-"; } catch (Exception) { lblInvoiceNoDetail.Text = "-"; } var invoiceType = new ReceiptInvoiceType(); HeaderGroup.Text = "PO No: " + Order.PONumber; } //documentType var po = new PO(_orderID); var documentTypes = BLL.DocumentType.GetDocumentTypesByPOType(po.PurchaseType); lkDocumentType.Properties.DataSource = documentTypes; lkDocumentType.EditValue = documentTypes.Rows.Count > 0 ? documentTypes.Rows[0]["DocumentTypeID"] : -1; if (_receiptInvoiceID != 0) { ReceiptInvoice rinvoice = new ReceiptInvoice(_receiptInvoiceID); //bind data to invoicedetail tab BindInvoiceDetail(rinvoice); lblOrderNumber.Text = rinvoice.PO.PONumber; lblSupplier.Text = rinvoice.PO.Supplier.IsActive ? rinvoice.PO.Supplier.CompanyName : ""; lblRefNo.Text = rinvoice.PO.RefNo != "" ? rinvoice.PO.RefNo : "-"; gridGrv.DataSource = rinvoice.Receipts.DefaultView; txtInsurance.Text = rinvoice.InsurancePolicyNo; txtInvoiceNumber.Text = rinvoice.STVOrInvoiceNo; txtTransitNumber.Text = rinvoice.TransitTransferNo; txtWayBill.Text = rinvoice.WayBillNo; dtInvoiceDate.EditValue = !rinvoice.IsColumnNull("DateofEntry") ? rinvoice.DateOfEntry : DateTimeHelper.ServerDateTime; txtTotalValue.EditValue = !rinvoice.IsColumnNull("TotalValue") ? rinvoice.TotalValue : 0; lkInvoiceType.EditValue = !rinvoice.IsColumnNull("InvoiceTypeID") ? rinvoice.InvoiceTypeID : 0; txtInvoiceAirFreight.EditValue = !rinvoice.IsColumnNull("AirFreight") ? rinvoice.AirFreight : 0; txtInvoiceSeaFreight.EditValue = !rinvoice.IsColumnNull("SeaFreight") ? rinvoice.SeaFreight : 0; txtInvoiceInlandFreight.EditValue = !rinvoice.IsColumnNull("InlandFreight") ? rinvoice.InlandFreight : 0; txtInvoiceCustomDutyTax.EditValue = !rinvoice.IsColumnNull("CustomDutyTax") ? rinvoice.CustomDutyTax : 0; txtInvoiceCBEServiceCharge.EditValue = !rinvoice.IsColumnNull("CBE") ? rinvoice.CBE : 0; txtExchangeRate.EditValue = !rinvoice.IsColumnNull("ExchangeRate") ? rinvoice.ExchangeRate : 1; lkCurrencyLCID.EditValue = _currency = !rinvoice.IsColumnNull("LCID") ? rinvoice.LCID : 0; lkDocumentType.EditValue = !rinvoice.IsColumnNull("DocumentTypeID") ? rinvoice.DocumentTypeID : -1; DisableEditDependingOnSetting(); var activity = new Activity(); activity.LoadByPrimaryKey(rinvoice.ActivityID); if (activity.IsHealthProgram()) { txtInvoiceCustomDutyTax.EditValue = 0; txtInvoiceCustomDutyTax.Enabled = false; } // var receiptINvoice = new ReceiptInvoice(); // receiptINvoice.LoadForPO(_orderID); lblInvoiceNoDetail.Text = rinvoice.STVOrInvoiceNo.ToString(); lblInvoiceTypeDetail.Text = lkInvoiceType.Text; } else { PO PO = new PO(_orderID); lblOrderNumber.Text = PO.PONumber; BindInvoiceDetailByPO(PO.ID); lblSupplier.Text = PO.Supplier.IsActive ? PO.Supplier.CompanyName : "_"; lkCurrencyLCID.EditValue = 1118; //ETB is the dafault lblRefNo.Text = PO.RefNo != "" ? PO.RefNo : "-"; if (PO.StoreID != null) { var activity = new Activity(); activity.LoadByPrimaryKey(po.StoreID); if (activity.IsHealthProgram()) { txtInvoiceCustomDutyTax.EditValue = 0; txtInvoiceCustomDutyTax.Enabled = false; } } layoutGoodsReceived.Enabled = false; } //gridViewInvoiceDetail.ValidateRow += GridViewInvoiceDetailOnValidateRow; }
private void btnSaveInvoice_Click(object sender, EventArgs e) { PO po = new PO(_orderID); if (dxValidation.Validate()) { ReceiptInvoice invoice = new ReceiptInvoice(); if (_receiptInvoiceID != 0) { invoice.LoadByPrimaryKey(_receiptInvoiceID); } else { invoice.AddNew(); } //TODO: save the Invoice Type Here. invoice.InvoiceTypeID = 1; invoice.InsurancePolicyNo = txtInsurance.Text; double TotalValue = 0; if (!invoice.IsColumnNull("TotalValue")) { TotalValue = invoice.TotalValue; } if (_receiptInvoiceID != 0 && po.Remaining + TotalValue < Convert.ToDouble(txtTotalValue.EditValue) && POType.GetModes(po.PurchaseType) == POType.STANDARD) { XtraMessageBox.Show("Invoice value can't be be greater than Order value", "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } invoice.TotalValue = Convert.ToDouble(txtTotalValue.EditValue); if (po.Remaining < invoice.TotalValue && POType.GetModes(po.PurchaseType) == POType.STANDARD && _receiptInvoiceID == 0) { XtraMessageBox.Show("Invoice value can't be be greater than Order value", "Invalid Value", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } invoice.WayBillNo = txtWayBill.Text; invoice.TransitTransferNo = txtTransitNumber.Text; invoice.STVOrInvoiceNo = txtInvoiceNumber.Text; invoice.POID = _orderID; invoice.SavedByUserID = CurrentContext.UserId; invoice.AirFreight = Convert.ToDouble(txtInvoiceAirFreight.EditValue); invoice.SeaFreight = Convert.ToDouble(txtInvoiceSeaFreight.EditValue); invoice.InlandFreight = Convert.ToDouble(txtInvoiceInlandFreight.EditValue); invoice.CustomDutyTax = Convert.ToDouble(txtInvoiceCustomDutyTax.EditValue); invoice.CBE = Convert.ToDouble(txtInvoiceCBEServiceCharge.EditValue); invoice.InvoiceTypeID = Convert.ToInt32(lkInvoiceType.EditValue); invoice.DateOfEntry = Convert.ToDateTime(dtInvoiceDate.EditValue); invoice.ExchangeRate = Convert.ToDouble(txtExchangeRate.EditValue); invoice.LCID = Convert.ToInt32(lkCurrencyLCID.EditValue); invoice.ActivityID = po.StoreID; invoice.Rowguid = Guid.NewGuid(); invoice.PrintedDate = dtInvoiceDate.DateTime; invoice.IsVoided = false; invoice.ShippingSite = " "; invoice.IsConvertedFromDeliveryNote = false; invoice.IsDeliveryNote = Convert.ToInt32(lkDocumentType.EditValue) == DocumentType.CONSTANTS.DLVN; if (Convert.ToInt32(lkDocumentType.EditValue) != -1) { invoice.DocumentTypeID = Convert.ToInt32(lkDocumentType.EditValue); } invoice.Save(); this.LogActivity("Save-Invoice", invoice.ID); lblInvoiceNoDetail.Text = txtInvoiceNumber.EditValue.ToString(); lblInvoiceTypeDetail.Text = lkInvoiceType.Text; BLL.Receipt receipt = new BLL.Receipt(); receipt.UpdateInvoiceRelatedHeaders(invoice); _receiptInvoiceID = invoice.ID; MessageBox.Show("Invoice saved!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); HeaderGroupDetail.Text = "Invoice No: " + txtInvoiceNumber.EditValue.ToString(); } }
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; } }
public void LoadByReceiptIDInvoiceIDAndPoID(int ReceiptID, int InvoiceID, int PoID, string GRNString, double GRVTotalValue) { purchaseOrder = new PO(); Invoice = new ReceiptInvoice(); GRV = new Receipt(); //Load this.GRVTotal = GRVTotalValue; LoadData(ReceiptID, InvoiceID, PoID); _activity = new Activity(); _activity.LoadByPrimaryKey(Invoice.ActivityID); Supplier = purchaseOrder.Supplier.CompanyName; OrderNo = purchaseOrder.PONumber; InvoiceNo = Invoice.STVOrInvoiceNo; GRVNo = GRNString; AWBNo = Invoice.WayBillNo; ShippedBy = Invoice.ShippedBy; if (Invoice.IsColumnNull("InvoiceTypeID") || GRV.ReceiptTypeID == ReceiptType.CONSTANTS.STOCK_RETURN) { AutoProrate = false; purchaseOrder.ExhangeRate = FOBExchangeRate = 1; } else if (Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.NON_STANDARD) { AutoProrate = false; purchaseOrder.ExhangeRate = FOBExchangeRate = 1; } else { if (purchaseOrder.PurchaseType == POType.COST_AND_EST_FREIGHT) { ProrateUsingFreightOnPO = true; ProrateUsingFreightOnInvoice = true; UsePOFreight = true; } else if (purchaseOrder.PurchaseType == POType.COST_AND_FREIGHT) { ProrateUsingFreightOnPO = true; ProrateUsingFreightOnInvoice = true; UsePOFreight = false; } } if (!_activity.IsHealthProgram()) { UseCustomDutyTax = true; } if (AutoProrate && Invoice.InvoiceTypeID != -255 && Invoice.InvoiceTypeID != InvoiceType.Internal) { Prorate(); } if (Invoice.IsColumnNull("InvoiceTypeID") || Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.LOCAL_PURCHASE || Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.CIP || Invoice.InvoiceTypeID == ReceiptInvoiceType.InvoiceType.NON_STANDARD || _activity.IsHealthProgram()) { UseProvison = false; } else { UseProvison = true; } CalculateCostCoefficient(); PopulateDataTable(); }