private void simpleButton1_Click(object sender, EventArgs e)
        {
            var dt = (DataView) gridView1.DataSource;
            dt.RowFilter = "Requested >0";
            if (dt == null) return;
            var po = new PO();
            po.AddNew();
            var serverDateTime = DateTimeHelper.ServerDateTime;
            po.PODate = serverDateTime;
            po.DateOfEntry = serverDateTime;
            po.PurchaseType = POType.INTERNAL;
            po.PaymentTypeID = PaymentType.Constants.STV;
            po.TermOfPayement = TermOfPayment.List[6].ID;
            po.PurchaseOrderStatusID = 9; //PurchaseOrderStatus ==> Processed
            po.SavedbyUserID = CurrentContext.LoggedInUser.ID;
            po.Save();
            var purchaseOrderDetail = new PurchaseOrderDetail();
            foreach (DataRowView dr in dt)
            {
                var itemUnit = new ItemUnitBase();
                itemUnit.LoadByPrimaryKey(Convert.ToInt32(dr["UnitID"]));

                purchaseOrderDetail.AddNew();
                purchaseOrderDetail.ItemID = Convert.ToInt32(dr["ItemID"]);
                purchaseOrderDetail.UnitOfIssueID = itemUnit.UnitOfIssueID;
                purchaseOrderDetail.Quantity = Convert.ToInt32(dr["Requested"]);
                purchaseOrderDetail.PurchaseOrderID = po.ID;
                purchaseOrderDetail.Rowguid = Guid.NewGuid();
                purchaseOrderDetail.ApprovedQuantity = 0;

            }
            purchaseOrderDetail.Save();
            lookUpEdit1_EditValueChanged(null, null);
        }
Example #2
0
        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);
                }
            }
        }
        public PurchaseOrderDetailForm(int poid, int storeID)
        {
            _poid = poid;
            _po = new PO(_poid);

            _storeID = storeID;
            InitializeComponent();
        }
Example #4
0
        private void LoadDecimalFormatings()
        {
            string sharps              = Helpers.FormattingHelpers.GetNumberFormatting();
            string displaySharpsBirr   = Helpers.FormattingHelpers.GetBirrFormatting();
            string displayExchangeRate = Helpers.FormattingHelpers.GetExchangeRateFormatting();
            PO     po       = new PO(_orderID);
            string PoSharps = Helpers.FormattingHelpers.GetCurrencyFormatByLCID(po.LCID);

            //GRV Formating
            SetDisplayFormatAndEditMask(txtTotalValue, sharps,
                                        Helpers.FormattingHelpers.GetCurrencyFormatByLCID(Convert.ToInt32(_currency)));

            //Invoice Formating
            SetDisplayFormatAndEditMask(txtInvoiceAirFreight, sharps,
                                        Helpers.FormattingHelpers.GetCurrencyFormatByLCID(Convert.ToInt32(_currency)));
            SetDisplayFormatAndEditMask(txtInvoiceSeaFreight, sharps,
                                        Helpers.FormattingHelpers.GetCurrencyFormatByLCID(Convert.ToInt32(_currency)));
            SetDisplayFormatAndEditMask(txtInvoiceInlandFreight, sharps, displaySharpsBirr);
            SetDisplayFormatAndEditMask(txtInvoiceCBEServiceCharge, sharps, displaySharpsBirr);
            SetDisplayFormatAndEditMask(txtInvoiceCustomDutyTax, sharps, displaySharpsBirr);
        }
Example #5
0
        public static void SaveList(List <HCMIS.Desktop.STVSyncService.STVList> list, int userID)
        {
            BLL.ReceiptInvoice bv = new BLL.ReceiptInvoice();
            foreach (HCMIS.Desktop.STVSyncService.STVList v in list)
            {
                // try to load by primary key
                bv.LoadBySTVNoAndAccountType(v.STVNo, v.AccountID);

                // if the entry doesn't exist, create it
                if (bv.RowCount == 0)
                {
                    BLL.PO po = new BLL.PO();
                    po.AddNew();
                    if (v.AccountID.HasValue)
                    {
                        po.StoreID = v.AccountID.Value;
                    }
                    po.SupplierID = BLL.Supplier.CONSTANTS.HOME_OFFICE;
                    if (v.HubID.HasValue)
                    {
                        po.PONumber = v.HubID.Value + "-" + v.STVNo;
                    }
                    po.Save();

                    bv.AddNew();
                    bv.STVOrInvoiceNo = v.STVNo.ToString();
                    bv.InvoiceTypeID  = BLL.ReceiptInvoiceType.InvoiceType.STV;
                    bv.DateOfEntry    = DateTimeHelper.ServerDateTime;
                    bv.POID           = po.ID;
                    bv.SavedByUserID  = userID;
                }
                // populate the contents of v on the to the database list
                bv.TotalValue    = v.InvoiceTotalValue;
                bv.Insurance     = v.Insurance;
                bv.SavedByUserID = userID;
                bv.Save();
            }
        }
        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 gridOrderView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            if (e != null && e.PrevFocusedRowHandle < -1)
             return;

            if (gridOrderView.GetFocusedDataRow() != null)
            {
                var dr = gridOrderView.GetFocusedDataRow();

                int OrderID = Convert.ToInt32(dr["ID"]);
                string sharps = Helpers.FormattingHelpers.GetNumberFormatting();
                Order = new PO(OrderID);
                RefreshInvoice();
                RefreshPoDetail();
                // Layout  ... Show the damn correct layout

                // Hide the empty layout
                LayoutEmptyDetails.Visibility = LayoutVisibility.Never;
                LayoutSelectedOrderDetail.Visibility = LayoutVisibility.Always;

                int Currency = 0x0409;
                if(!Order.IsColumnNull("LCID"))
                    Currency = Order.LCID;

                if(!string.IsNullOrEmpty(Order.s_PurchaseType))
                    PurchaseTypes = POType.GetAllPOTypes().Find(t => t.ID == Order.PurchaseType);
                string space = "";
                DataRow dar = gridInvoiceView.GetFocusedDataRow();
                HeaderGroup.Text = "PO No: " + dr["OrderNumber"].ToString();
               if (dar != null)
               {
                   HeaderGroup.Text = HeaderGroup.Text + space.PadRight(160) + "Invoice No: " + gridInvoiceView.GetFocusedDataRow()["STVOrInvoiceNo"];
               }

              // lblOrderType.Text = PurchaseTypes != null ?  string.Format("{0} : {1}" ,PurchaseTypes.Group , PurchaseTypes.Name) : "";
                lblPONumber.Text = Order.PONumber;
                lblTotalValue.Text = Order.TotalValue.ToString(Helpers.FormattingHelpers.GetCurrencyFormatByLCID(Currency));
                lblInsurance.Text = Order.Insurance.ToString(Helpers.FormattingHelpers.GetBirrFormatting());
                lblNBE.Text = Order.NBE.ToString(Helpers.FormattingHelpers.GetBirrFormatting());
                lblSupplier.Text = Order.Supplier.CompanyName;
                lblShipper.Text = String.IsNullOrEmpty(Order.ShippingSite) ? "-" : Order.ShippingSite;
                lblLetterNo.Text = String.IsNullOrEmpty(Order.LetterNo) ? "-" : Order.LetterNo;
                lblPOType.Text = dr["Name"].ToString();

                var PaymentType = new PaymentType();
                PaymentType.LoadByPrimaryKey(Order.PaymentTypeID);
                lblPaymentType.Text = String.IsNullOrEmpty(PaymentType.Name) ? "-" : PaymentType.Name ;

                var User = new User();
                User.LoadByPrimaryKey(Order.SavedbyUserID);
                lblPOBy.Text = String.IsNullOrEmpty(User.FullName) ? "-" : User.FullName;

                if (!Order.IsColumnNull("ModeID"))
                {
                    var Mode = new Mode();
                    Mode.LoadByPrimaryKey(Order.ModeID);
                    lblMode.Text = Mode.TypeName;
                }
                else lblMode.Text = "-";

                if (!Order.IsColumnNull("PurchaseOrderStatusID"))
                {
                    var poStatus = new PurchaseOrderStatus();
                    poStatus.LoadByPrimaryKey(Order.PurchaseOrderStatusID);
                    lblPOStatus.Text = poStatus.Name;
                }

                chkboxIsElectronic.Checked = Order.IsElectronic;
                lblOrderDate.Text = Order.PODate.ToShortDateString();
                lblSyncDate.Text = Order.ModifiedDate == DateTime.MinValue ? "NA" :  Order.ModifiedDate.ToString(CultureInfo.InvariantCulture);

                if (!Order.IsColumnNull("StoreID"))
                {
                    Activity act = new Activity();
                    act.LoadByPrimaryKey(Order.StoreID);
                    lblAccount.Text = act.AccountName;
                    lblSubAccount.Text = act.SubAccountName;
                    lblActivity.Text = act.Name;

                }
                else
                {
                    lblAccount.Text = lblSubAccount.Text = lblActivity.Text = "-";
                }

                lblRefNo.Text = String.IsNullOrEmpty(Order.RefNo) ? "-" : Order.RefNo;
              lblRemainingValue.Text = Order.Remaining.ToString(Helpers.FormattingHelpers.GetCurrencyFormatByLCID(Currency));
                if (BLL.Settings.UseNewUserManagement && this.HasPermission("Add-Invoice"))
                {
                    btnAddInvoice.Enabled = true;
                }
                else if (BLL.Settings.UseNewUserManagement)
                {
                    btnAddInvoice.Enabled = false;
                }

                btnAddInvoice.Enabled = btnEditOrder.Enabled =btnAddOrderDetail.Enabled = !Order.IsElectronic;

                if (Order.IsElectronic)
                {
                    grdPoDetail.Enabled = false;
                    gridInvoice.Enabled = false;
                }
                else
                {
                    grdPoDetail.Enabled = true ;
                    gridInvoice.Enabled = true;
                }

                //purchse order details
                grdPoDetail.DataSource = Order.PurchaseOrderDetail.DefaultView;
            }
            else
            {
                // Hide the empty layout
                LayoutEmptyDetails.Visibility = LayoutVisibility.Always;
                LayoutSelectedOrderDetail.Visibility = LayoutVisibility.Never;
            }
        }
        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 LoadDecimalFormatings()
        {
            string sharps = Helpers.FormattingHelpers.GetNumberFormatting();
            string displaySharpsBirr = Helpers.FormattingHelpers.GetBirrFormatting();
            string displayExchangeRate = Helpers.FormattingHelpers.GetExchangeRateFormatting();
            PO po = new PO(_orderID);
            string PoSharps = Helpers.FormattingHelpers.GetCurrencyFormatByLCID(po.LCID);

            //GRV Formating
            SetDisplayFormatAndEditMask(txtTotalValue, sharps,
                Helpers.FormattingHelpers.GetCurrencyFormatByLCID(Convert.ToInt32(_currency)));

            //Invoice Formating
            SetDisplayFormatAndEditMask(txtInvoiceAirFreight, sharps,
                Helpers.FormattingHelpers.GetCurrencyFormatByLCID(Convert.ToInt32(_currency)));
            SetDisplayFormatAndEditMask(txtInvoiceSeaFreight, sharps,
                Helpers.FormattingHelpers.GetCurrencyFormatByLCID(Convert.ToInt32(_currency)));
            SetDisplayFormatAndEditMask(txtInvoiceInlandFreight, sharps, displaySharpsBirr);
            SetDisplayFormatAndEditMask(txtInvoiceCBEServiceCharge, sharps, displaySharpsBirr);
            SetDisplayFormatAndEditMask(txtInvoiceCustomDutyTax, sharps, displaySharpsBirr);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ReceiptInvoice" /> class.
 /// </summary>
 /// <param name="ID">The ID.</param>
 public ReceiptInvoice(int ID)
 {
     LoadByPrimaryKey(ID);
     _po = new PO(POID);
     ConvertNull();
 }
Example #11
0
        private void lkInvoiceType_EditValueChanged(object sender, EventArgs e)
        {
            int InvoiceType = Convert.ToInt32(lkInvoiceType.EditValue);

            if (InvoiceType == ReceiptInvoiceType.InvoiceType.INVOICE_AIR)
            {
                txtTotalValue.Enabled = BLL.Settings.IsCenter;

                txtInvoiceAirFreight.Enabled       = true;
                txtInvoiceSeaFreight.EditValue     = 0;
                txtInvoiceSeaFreight.Enabled       = false;
                txtInvoiceInlandFreight.EditValue  = 0;
                txtInvoiceInlandFreight.Enabled    = false;
                txtInvoiceCustomDutyTax.Enabled    = true;
                txtInvoiceCBEServiceCharge.Enabled = true;
            }
            else if (InvoiceType == ReceiptInvoiceType.InvoiceType.INVOICE_SEA)
            {
                txtTotalValue.Enabled = BLL.Settings.IsCenter;

                txtInvoiceAirFreight.EditValue     = 0;
                txtInvoiceAirFreight.Enabled       = false;
                txtInvoiceSeaFreight.Enabled       = true;
                txtInvoiceInlandFreight.Enabled    = true;
                txtInvoiceCustomDutyTax.Enabled    = true;
                txtInvoiceCBEServiceCharge.Enabled = true;
            }
            else if (InvoiceType == ReceiptInvoiceType.InvoiceType.CIP ||
                     InvoiceType == ReceiptInvoiceType.InvoiceType.LOCAL_PURCHASE)
            {
                txtTotalValue.Enabled          = BLL.Settings.IsCenter;
                txtInvoiceAirFreight.EditValue = 0;
                txtInvoiceAirFreight.Enabled   = false;

                txtInvoiceSeaFreight.EditValue = 0;
                txtInvoiceSeaFreight.Enabled   = false;

                txtInvoiceInlandFreight.EditValue = 0;
                txtInvoiceInlandFreight.Enabled   = false;

                txtInvoiceCustomDutyTax.EditValue    = 0;
                txtInvoiceCustomDutyTax.Enabled      = false;
                txtInvoiceCBEServiceCharge.EditValue = 0;
                txtInvoiceCBEServiceCharge.Enabled   = false;
            }
            else if (InvoiceType == ReceiptInvoiceType.InvoiceType.INVENTORY)
            {
                txtTotalValue.EditValue        = 0;
                txtTotalValue.Enabled          = false;
                txtInvoiceAirFreight.EditValue = 0;
                txtInvoiceAirFreight.Enabled   = false;

                txtInvoiceSeaFreight.EditValue = 0;
                txtInvoiceSeaFreight.Enabled   = false;

                txtInvoiceInlandFreight.EditValue = 0;
                txtInvoiceInlandFreight.Enabled   = false;

                txtInvoiceCustomDutyTax.EditValue    = 0;
                txtInvoiceCustomDutyTax.Enabled      = false;
                txtInvoiceCBEServiceCharge.EditValue = 0;
                txtInvoiceCBEServiceCharge.Enabled   = false;
            }
            else if (InvoiceType == ReceiptInvoiceType.InvoiceType.STV)
            {
                txtTotalValue.Enabled          = BLL.Settings.IsCenter;
                txtInvoiceAirFreight.EditValue = 0;
                txtInvoiceAirFreight.Enabled   = false;

                txtInvoiceSeaFreight.EditValue = 0;
                txtInvoiceSeaFreight.Enabled   = false;

                txtInvoiceInlandFreight.EditValue = 0;
                txtInvoiceInlandFreight.Enabled   = false;

                txtInvoiceCustomDutyTax.EditValue    = 0;
                txtInvoiceCustomDutyTax.Enabled      = false;
                txtInvoiceCBEServiceCharge.EditValue = 0;
                txtInvoiceCBEServiceCharge.Enabled   = false;
            }

            PO PO = new PO(_orderID);

            if (PO.StoreID != null)
            {
                var activity = new Activity();
                activity.LoadByPrimaryKey(PO.StoreID);
                if (activity.IsHealthProgram())
                {
                    txtInvoiceCustomDutyTax.EditValue = 0;
                    txtInvoiceCustomDutyTax.Enabled   = false;
                }
            }
        }
        public static bool IsPOElectronic(int ID)
        {
            var purchaseOrder = new PO();
            var query = HCMIS.Repository.Queries.PO.SelectIsPOElectronic(ID);
            purchaseOrder.LoadFromRawSql(query);

            if (purchaseOrder.RowCount == 0) return false;
            return (bool)purchaseOrder.GetColumn("IsElectronic");
        }
        public static PO CreatePOforStandard(int orderType, int StoreID, int? SupplierID, string Remark,int userID)
        {
            BLL.PO po = new PO();
            po.AddNew();

            po.StoreID = StoreID;

            po.ExhangeRate = 1;
            po.Insurance = 0;
            po.Description = Remark;
            if (SupplierID != null)
                po.SupplierID = Convert.ToInt32(SupplierID);

            //po.PurchaseType =
            po.SavedbyUserID = userID;
            po.IsElectronic = false;
            po.POFinalized = false;
            po.Rowguid = Guid.NewGuid();
            po.Identifier = "00000";
            po.DateOfEntry = DateTimeHelper.ServerDateTime;
            UpdatePoNumberAndPOType(orderType, po);
             po.Save();
            //~ Update PONumber for Transfers and Error Correction ~//
            UpdatePoNumberAndPOType(orderType, po);
            po.Save();

            return po;
        }
 /// <summary>
 /// Gets the uncomplete purchase order.
 /// </summary>
 /// <returns></returns>
 public static DataView GetUncompletePurchaseOrder()
 {
     PO purchaseOrder = new PO();
     var query = HCMIS.Repository.Queries.PO.SelectGetUncompletePurchaseOrder();
     purchaseOrder.LoadFromRawSql(query);
     return purchaseOrder.DefaultView;
 }
        public static bool IsPOEditable(int ID)
        {
            PO PurchaseOrder = new PO();

            var query = HCMIS.Repository.Queries.PO.SelectIsPOEditable(ID, Settings.DisableInvoiceEditAfterStepNo);
            PurchaseOrder.LoadFromRawSql(query);
            return PurchaseOrder.RowCount == 0;
        }
        public static DataTable GetOrderSummary(int invoiceId)
        {
            var purchaseOrder = new PO();

            var query = HCMIS.Repository.Queries.PO.SelectGetOrderSummary(invoiceId);
            purchaseOrder.LoadFromRawSql(query);
            return purchaseOrder.DataTable;
        }
 /// <summary>
 /// Get Receiving Order Information
 /// </summary>
 /// <param name="userID">The user ID.</param>
 /// <param name="purchaseOrderTypeID">Type of the purchase.</param>
 /// <returns>
 /// DataView: ID OrderNumber CompanyName
 /// </returns>
 public static DataView GetOrderForSelection(int userID,int? purchaseOrderTypeID)
 {
     var purchaseOrder = new PO();
     var query = HCMIS.Repository.Queries.PO.SelectGetOrderForSelection(userID,purchaseOrderTypeID);
     purchaseOrder.LoadFromRawSql(query);
     return purchaseOrder.DefaultView;
 }
 public static DataView GetOrderAll(int userID)
 {
     PO purchaseOrder = new PO();
     var query = HCMIS.Repository.Queries.PO.SelectGetOrderAll(userID);
     purchaseOrder.LoadFromRawSql(query);
     return purchaseOrder.DefaultView;
 }
Example #19
0
        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;
        }
 /// <summary>
 /// Alls the order for report.
 /// </summary>
 /// <returns></returns>
 public DataTable AllOrderForReport()
 {
     PO purchaseOrder = new PO();
     var query = HCMIS.Repository.Queries.PO.SelectAllOrderForReport();
     purchaseOrder.LoadFromRawSql(query);
     return purchaseOrder.DataTable;
 }
        private int SaveRelevantReceiptHeaders(int receiptTypeID, int warehouseID)
        {
            int receiptID;
            var receipt = new BLL.Receipt();
            var sup = new BLL.Supplier();

            if (lkReceiptInvoice.EditValue != null && Convert.ToInt32(lkReceiptInvoice.EditValue) != -1)
            {
                receiptID = receipt.AddNewReceipt(receiptTypeID, warehouseID, CurrentContext.UserId,
                    Convert.ToInt32(lkReceiptInvoice.EditValue), txtEditTransferNo.Text,
                    ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED);
                // , txtTransitNo.Text, txtInsuranceNo.Text, txtWayBillNo.Text);
            }
            else
            {
                //PO and ReceiptInvoice created automatically.
                //Needs to be fixed.
                BLL.PO po = new PO();
                BLL.ReceiptInvoice rctInvoice = new ReceiptInvoice();

                po.AddNew();
                var serverDateTime = DateTimeHelper.ServerDateTime;
                po.PODate = serverDateTime;
                po.DateOfEntry = serverDateTime;
                po.PurchaseType = POType.INVENTORY;
                po.IsElectronic = false;
                po.POFinalized = false;
                po.Rowguid = Guid.NewGuid();
                po.Identifier = "00000";

                po.PaymentTypeID = BLL.PaymentType.Constants.STV;
                po.TermOfPayement = BLL.PaymentTerm.Internal;
                po.PurchaseOrderStatusID = PurchaseOrderStatus.Processed;

                rctInvoice.AddNew();

                po.StoreID = Convert.ToInt32(lkAccounts.EditValue);
                Activity acc = new Activity();
                acc.LoadByPrimaryKey(po.StoreID);
                po.ModeID = acc.ModeID;

                //po.PONumber = srm ? lkSTVInvoiceNo.EditValue.ToString() : (deliveryNote ? txtRefNo.Text : (beginningBalance ? "BeginningBalance" : String.Empty));

                if (lcSTVNo.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always)
                {
                    po.PONumber = srm && !chkSRMForOldSystemIssues.Checked
                        ? txtSTVNo.Text
                        : ((deliveryNoteType != DeliveryNoteType.NotSet)
                            ? txtSTVNo.Text
                            : (beginningBalance
                                ? "BeginningBalance"
                                : (srm && chkSRMForOldSystemIssues.Checked
                                    ? txtSTVInvoiceNoOldSystem.Text
                                    : txtRefNo.Text)));
                }
                else
                {
                    po.PONumber = srm && !chkSRMForOldSystemIssues.Checked
                        ? lkSTVInvoiceNo.Text
                        : ((deliveryNoteType != DeliveryNoteType.NotSet)
                            ? txtRefNo.Text
                            : (beginningBalance
                                ? "BeginningBalance"
                                : (srm && chkSRMForOldSystemIssues.Checked
                                    ? txtSTVInvoiceNoOldSystem.Text
                                    : txtRefNo.Text)));
                }

                   //TODO: Ugly hack, supplier. To be fixed.
                    if (srm)
                    {
                        po.SupplierID = BLL.Supplier.CONSTANTS.RETURNED_FROM_FACILITY;

                        //Let's put Finance Required stuff here.
                        po.Insurance = 0;
                        po.ExhangeRate = 1;
                        rctInvoice.ExchangeRate = 1;
                        rctInvoice.Insurance = 0;

                        rctInvoice.InvoiceTypeID = ReceiptInvoiceType.InvoiceType.LOCAL_PURCHASE;

                        if (chkSRMForOldSystemIssues.Checked)
                        {
                            if (lkForFacility.EditValue == null)
                                throw new Exception("Facility not chosen!");
                            po.RefNo = lkForFacility.EditValue.ToString();
                        }
                    }

                po.SavedbyUserID = CurrentContext.LoggedInUser.ID;
                po.Save();

                rctInvoice.POID = po.ID;
                if (lcSTVNo.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always)
                {
                    rctInvoice.STVOrInvoiceNo = srm && !chkSRMForOldSystemIssues.Checked
                        ? txtSTVNo.Text
                        : ((deliveryNoteType != DeliveryNoteType.NotSet)
                            ? txtSTVNo.Text
                            : (beginningBalance
                                ? "BeginningBalance"
                                : (srm && chkSRMForOldSystemIssues.Checked
                                    ? txtSTVInvoiceNoOldSystem.Text
                                    : txtSTVNo.Text)));
                }
                else
                {
                    rctInvoice.STVOrInvoiceNo = srm && !chkSRMForOldSystemIssues.Checked
                        ? lkSTVInvoiceNo.Text
                        : ((deliveryNoteType != DeliveryNoteType.NotSet)
                            ? txtRefNo.Text
                            : (beginningBalance
                                ? "BeginningBalance"
                                : (srm && chkSRMForOldSystemIssues.Checked
                                    ? txtSTVInvoiceNoOldSystem.Text
                                    : txtRefNo.Text)));
                }
                rctInvoice.DateOfEntry = DateTimeHelper.ServerDateTime;
                rctInvoice.ActivityID = po.StoreID;
                rctInvoice.SavedByUserID = CurrentContext.LoggedInUser.ID;
                rctInvoice.IsDeliveryNote = false;

                rctInvoice.Rowguid = Guid.NewGuid();
                rctInvoice.PrintedDate = po.DateOfEntry;
                rctInvoice.IsVoided = false;
                rctInvoice.ShippingSite = " ";
                rctInvoice.IsConvertedFromDeliveryNote = false;
                rctInvoice.IsDeliveryNote = false;
                rctInvoice.DocumentTypeID = DocumentType.CONSTANTS.SRM;

                rctInvoice.Save();

                receiptID = receipt.AddNewReceipt(receiptTypeID, warehouseID, CurrentContext.UserId, rctInvoice.ID,
                    txtTransitTransferVoucherNo.Text, ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED);

                //receiptID = receipt.AddNewReceipt(receiptTypeID, NewMainWindow.UserId);
            }
            return receiptID;
        }
        public bool DoesPOHasDuplicateInvoiceNumbers(int poid,string invoiceNo)
        {
            var po = new PO();
            var query = HCMIS.Repository.Queries.PO.DoesPOHasDuplicateInvoiceNumbers(poid,invoiceNo);
            po.LoadFromRawSql(query);

            return po.RowCount != 0;
        }
 /// <summary>
 /// Gets the supplier.
 /// </summary>
 /// <returns></returns>
 public int GetSupplier()
 {
     BLL.PO po = new PO();
     po.LoadByPrimaryKey(this.POID);
     return po.SupplierID;
 }
        public bool DoesPONumberExists(string poNumber)
        {
            var po = new PO();
            var query = HCMIS.Repository.Queries.PO.DoesPONumberExists(poNumber);
            po.LoadFromRawSql(query);

            return po.RowCount != 0;
        }
        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();
        }
        /// <summary>
        /// Gets the data table.
        /// </summary>
        /// <returns></returns>
        public System.Data.DataTable GetDataTable()
        {
            PO purchaseOrder = new PO();
            var query = HCMIS.Repository.Queries.PO.SelectGetDataTable();
            purchaseOrder.LoadFromRawSql(query);

            return purchaseOrder.DataTable;
        }
Example #27
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int warehouseID = Convert.ToInt32(lkWarehouse.EditValue);

            receiveDoc.Rewind();
            var po             = new BLL.PO();
            var receiptInvoice = new BLL.ReceiptInvoice();

            while (!receiveDoc.EOF)
            {
                //Handle the PO.
                //int receiptID;
                if (po.RowCount == 0 || po.StoreID != receiveDoc.StoreID)
                {
                    Supplier supplier = new Supplier();
                    po = BLL.PO.CreatePOforStandard(OrderType.CONSTANTS.STANDARD_ORDER, receiveDoc.StoreID,
                                                    supplier.GetHubHomeOfficeSupplierID(), "", CurrentContext.LoggedInUser.ID);
                    //Should we receive it as hub to hub transfer? We're now using Standard order.
                    receipt = BLL.ReceiptInvoice.CreateAutomaticReceiptInvoiceForSTVTransfer(po.ID, warehouseID, STVNo,
                                                                                             CurrentContext.UserId);
                }

                receiveDoc.Quantity  = receiveDoc.QtyPerPack * receiveDoc.NoOfPack;
                receiveDoc.ReceiptID = receipt.ID;
                receiveDoc.MoveNext();
            }
            receiveDoc.Save();

            //Save the location
            receiveDoc.Rewind();

            BLL.ReceivePallet receivePallet = new ReceivePallet();
            while (!receiveDoc.EOF)
            {
                //Save Location Information
                BLL.PalletLocation palletLocation = new PalletLocation();

                receivePallet.AddNew();

                int palletLocationID = Convert.ToInt32(receiveDoc.GetColumn("PalletLocationID"));
                receivePallet.PalletLocationID = palletLocationID;

                palletLocation.LoadByPrimaryKey(palletLocationID);

                receivePallet.PalletID         = palletLocation.PalletID;
                receivePallet.ReceivedQuantity = receiveDoc.Quantity;
                receivePallet.Balance          = receiveDoc.Quantity;
                receivePallet.ReceiveID        = receiveDoc.ID;
                receivePallet.ReservedStock    = 0;


                //Save Discrepancy information if there is any
                receiveDocShortage.Rewind();
                while (receiveDocShortage.FindNextByGUID(receiveDoc.GetColumn("GUID").ToString()))
                {
                    receiveDocShortage.ReceiveDocID = receiveDoc.ID;

                    if (receiveDocShortage.ShortageReasonID == ShortageReasons.Constants.DAMAGED)
                    {
                        receiveDoc.NoOfPack += receiveDocShortage.NoOfPacks;
                        receiveDoc.Quantity += receiveDocShortage.NoOfPacks * receiveDoc.QtyPerPack;

                        palletLocationID = Convert.ToInt32(receiveDocShortage.GetColumn("PalletLocationID"));
                        receivePallet.AddNew();
                        receivePallet.PalletLocationID = palletLocationID;
                        palletLocation.LoadByPrimaryKey(palletLocationID);

                        receivePallet.PalletID         = palletLocation.PalletID;
                        receivePallet.ReceivedQuantity = receiveDocShortage.NoOfPacks * receiveDoc.QtyPerPack;
                        receivePallet.Balance          = receiveDocShortage.NoOfPacks * receiveDoc.QtyPerPack;
                        receivePallet.ReceiveID        = receiveDoc.ID;
                        receivePallet.ReservedStock    = 0;
                    }
                }

                receiveDoc.MoveNext();
            }
            receivePallet.IsOriginalReceive = true;
            receivePallet.Save();
        }
 private static void UpdatePoNumberAndPOType(int orderType, PO po)
 {
     bool IsJustNewEntry = po.IsColumnNull("ID");
     if (orderType == OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER)
     {
         if (IsJustNewEntry) { po.PurchaseType = POType.ACCOUNT_TO_ACCOUNT_TRANSFER; }
         else { po.PONumber = string.Format("A2A-{0}", po.ID); }
     }
     else if (orderType == OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER)
     {
         if (IsJustNewEntry) {po.PurchaseType = POType.STORE_TO_STORE_TRANSFER; }
         else { po.PONumber = string.Format("S2S-{0}", po.ID);}
     }
     else if (orderType == OrderType.CONSTANTS.ERROR_CORRECTION_TRANSFER)
     {
         if (IsJustNewEntry) {po.PurchaseType = POType.ERROR_CORRECTION_TRANSFER; }
         else {po.PONumber = string.Format("EC-{0}", po.ID); }
     }
     else if (orderType == OrderType.CONSTANTS.INVENTORY)
     {
         if (IsJustNewEntry) { po.PurchaseType = POType.INVENTORY;}
         else { po.PONumber = string.Format("INV-{0}", po.ID); }
     }
 }
        private void lkInvoiceType_EditValueChanged(object sender, EventArgs e)
        {
            int InvoiceType = Convert.ToInt32(lkInvoiceType.EditValue);
            if (InvoiceType == ReceiptInvoiceType.InvoiceType.INVOICE_AIR)
            {

                txtTotalValue.Enabled = BLL.Settings.IsCenter;

                txtInvoiceAirFreight.Enabled = true;
                txtInvoiceSeaFreight.EditValue = 0;
                txtInvoiceSeaFreight.Enabled = false;
                txtInvoiceInlandFreight.EditValue = 0;
                txtInvoiceInlandFreight.Enabled = false;
                txtInvoiceCustomDutyTax.Enabled = true;
                txtInvoiceCBEServiceCharge.Enabled = true;
            }
            else if (InvoiceType == ReceiptInvoiceType.InvoiceType.INVOICE_SEA)
            {

                txtTotalValue.Enabled = BLL.Settings.IsCenter;

                txtInvoiceAirFreight.EditValue = 0;
                txtInvoiceAirFreight.Enabled = false;
                txtInvoiceSeaFreight.Enabled = true;
                txtInvoiceInlandFreight.Enabled = true;
                txtInvoiceCustomDutyTax.Enabled = true;
                txtInvoiceCBEServiceCharge.Enabled = true;

            }
            else if (InvoiceType == ReceiptInvoiceType.InvoiceType.CIP ||
                     InvoiceType == ReceiptInvoiceType.InvoiceType.LOCAL_PURCHASE)
            {

                txtTotalValue.Enabled = BLL.Settings.IsCenter;
                txtInvoiceAirFreight.EditValue = 0;
                txtInvoiceAirFreight.Enabled = false;

                txtInvoiceSeaFreight.EditValue = 0;
                txtInvoiceSeaFreight.Enabled = false;

                txtInvoiceInlandFreight.EditValue = 0;
                txtInvoiceInlandFreight.Enabled = false;

                txtInvoiceCustomDutyTax.EditValue = 0;
                txtInvoiceCustomDutyTax.Enabled = false;
                txtInvoiceCBEServiceCharge.EditValue = 0;
                txtInvoiceCBEServiceCharge.Enabled = false;

            }
            else if (InvoiceType == ReceiptInvoiceType.InvoiceType.INVENTORY)
            {

                txtTotalValue.EditValue = 0;
                txtTotalValue.Enabled = false;
                txtInvoiceAirFreight.EditValue = 0;
                txtInvoiceAirFreight.Enabled = false;

                txtInvoiceSeaFreight.EditValue = 0;
                txtInvoiceSeaFreight.Enabled = false;

                txtInvoiceInlandFreight.EditValue = 0;
                txtInvoiceInlandFreight.Enabled = false;

                txtInvoiceCustomDutyTax.EditValue = 0;
                txtInvoiceCustomDutyTax.Enabled = false;
                txtInvoiceCBEServiceCharge.EditValue = 0;
                txtInvoiceCBEServiceCharge.Enabled = false;

            }
            else if (InvoiceType == ReceiptInvoiceType.InvoiceType.STV)
            {
                txtTotalValue.Enabled = BLL.Settings.IsCenter;
                txtInvoiceAirFreight.EditValue = 0;
                txtInvoiceAirFreight.Enabled = false;

                txtInvoiceSeaFreight.EditValue = 0;
                txtInvoiceSeaFreight.Enabled = false;

                txtInvoiceInlandFreight.EditValue = 0;
                txtInvoiceInlandFreight.Enabled = false;

                txtInvoiceCustomDutyTax.EditValue = 0;
                txtInvoiceCustomDutyTax.Enabled = false;
                txtInvoiceCBEServiceCharge.EditValue = 0;
                txtInvoiceCBEServiceCharge.Enabled = false;

            }

            PO PO = new PO(_orderID);
            if (PO.StoreID != null)
            {
                var activity = new Activity();
                activity.LoadByPrimaryKey(PO.StoreID);
                if (activity.IsHealthProgram())
                {
                    txtInvoiceCustomDutyTax.EditValue = 0;
                    txtInvoiceCustomDutyTax.Enabled = false;
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ReceiptInvoice" /> class.
 /// </summary>
 /// <param name="ID">The ID.</param>
 public ReceiptInvoice(int ID)
 {
     LoadByPrimaryKey(ID);
     _po = new PO(POID);
     ConvertNull();
 }
        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;
        }
 /// <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 PrintReceiptConfirmation(string referenceNumber, int? reprintOfReceiptConfirmationPrintoutID)
        {
            var rc = new ReceiptConfirmationPrintout();
            var srmPrintout = new HCMIS.Desktop.Reports.SRMPrintout(CurrentContext.LoggedInUserName);

            int ReceiptID = Convert.ToInt32(gridReceiveView.GetFocusedDataRow()["ReceiptID"]);
            var receiveDoc = new ReceiveDoc();
            receiveDoc.LoadByReceiptID(ReceiptID);
            ReceiptConfirmationPrintout.GetGRNFNo(ReceiptID);
            srmPrintout.BranchName.Text = GeneralInfo.Current.HospitalName;
            rc.PrepareDataForPrintout(ReceiptID, CurrentContext.UserId, false, 3, null,
                                                  reprintOfReceiptConfirmationPrintoutID,FiscalYear.Current);
            srmPrintout.DataSource = rc.DefaultView.ToTable();

            var rUnit = new Institution();
            var idoc = new IssueDoc();
            if (!receiveDoc.IsColumnNull("ReturnedFromIssueDocID"))
            {
                idoc.LoadByPrimaryKey(receiveDoc.ReturnedFromIssueDocID);
                rUnit.LoadByPrimaryKey(idoc.ReceivingUnitID);
            }
            else
            {
                var po = new PO();
                po.LoadByReceiptID(receiveDoc.ReceiptID);
                rUnit.LoadByPrimaryKey(int.Parse(po.RefNo));
            }

            srmPrintout.xrFromValue.Text = rUnit.Name;
            srmPrintout.xrWoredaValue.Text = rUnit.WoredaText;
            srmPrintout.xrRegionValue.Text = rUnit.Region;
            srmPrintout.xrZoneValue.Text = rUnit.ZoneText;

            if (!receiveDoc.IsColumnNull("ReturnedFromIssueDocID"))
            {
                var stvLog = new BLL.Issue();
                stvLog.LoadByPrimaryKey(idoc.STVID);

                srmPrintout.xrIssueDateValue.Text = idoc.Date.ToString("M/d/yyyy");
                var activity = new Activity();
                activity.LoadByPrimaryKey(idoc.StoreId);
                 srmPrintout.xrAccountName.Text = activity.FullActivityName;
                var rct = new BLL.Receipt();
                rct.LoadByPrimaryKey(ReceiptID);
                var rctInvoice = new ReceiptInvoice();
                rctInvoice.LoadByPrimaryKey(rct.ReceiptInvoiceID);
                srmPrintout.xrSTVNoValue.Text = rctInvoice.STVOrInvoiceNo;
            }
            else
            {
                var activity = new Activity();
                activity.LoadByPrimaryKey(receiveDoc.StoreID);
                srmPrintout.xrAccountName.Text = activity.FullActivityName;
                srmPrintout.xrSTVNoValue.Text = receiveDoc.RefNo;
            }

            var dtDate = new DateTimePickerEx();
            dtDate.Value = receiveDoc.EurDate;
            srmPrintout.Date.Text = dtDate.Text;
            if (srmPrintout.PrintDialog() != DialogResult.OK)
            {
                throw new Exception("Print cancelled by user!");
            }

            //Successfully printed

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

            String reference = gridReceiveView.GetFocusedDataRow()["RefNo"].ToString();
            var recDoc = new ReceiveDoc();
            recDoc.LoadByReferenceNo(reference);
            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();
        }
        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);
                }

            }
        }
        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();
                }
            }
        }
Example #36
0
        private void gridReceiveView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            // Bind the detail grid
            PalletLocation pl = new PalletLocation();

            if (e != null && e.PrevFocusedRowHandle < -1)
            {
                return;
            }

            try
            {
                DataRow dr = gridReceiveView.GetFocusedDataRow();

                if (dr == null)
                {
                    return;
                }

                ReceiptID = Convert.ToInt32(dr["ReceiptID"]);
                BLL.Receipt receiptDoc = new BLL.Receipt();
                receiptDoc.LoadByPrimaryKey(ReceiptID);

                DataTable GRNFDetail = receiptDoc.GetDetailsForGRNF();


                if (GRNFDetail.Rows.Count > 0)
                {
                    //var store = new Store();
                    //store.
                    BLL.PO order = new BLL.PO();
                    //var Mode = new Mode();
                    //Mode.LoadByPrimaryKey(order.ModeID);
                    //lblMode.Text = Mode.TypeName;
                    HeaderSection.Text = GRNFDetail.Rows[0]["PONumber"].ToString();


                    lblRecieveStatus.Text     = dr["recieveStatus"].ToString();
                    lblReceiptNo.Text         = dr["ReceiptNo"].ToString();
                    lblRecievedBy.Text        = dr["ReceivedBy"].ToString();
                    lblRecievedDate.Text      = Convert.ToDateTime(dr["Date"]).ToShortDateString();
                    lblReciveType.Text        = (dr["ReceiveType"]).ToString();
                    lblWayBill.Text           = (dr["WayBillNo"]).ToString() != "" ? dr["WayBillNo"].ToString() : "-";
                    lblTransferVoucherNo.Text = (dr["transferNo"]).ToString() != "" ? dr["transferNo"].ToString() : "-";

                    var warehouse = new BLL.Warehouse();
                    warehouse.LoadByPrimaryKey(receiptDoc.WarehouseID);
                    lblWarehouse.Text = warehouse.Name;
                    lblSupplier.Text  = dr["Supplier"].ToString();

                    var cluster = new BLL.Cluster();
                    cluster.LoadByPrimaryKey(warehouse.ClusterID);
                    lblCluster.Text = cluster.Name;



                    lblDocType.Text = "";

                    lblPoType.Text = dr["POType"].ToString();
                    //var ps = new BLL.PhysicalStore();
                    //ps.LoadByPrimaryKey(order.p);
                    //lblStore.Text = ps.Name;


                    txtOrderNo.EditValue = GRNFDetail.Rows[0]["PONumber"];
                    lblPoNumber.Text     = GRNFDetail.Rows[0]["PONumber"].ToString();

                    lblInvoiceNumber.Text = receiptDoc.STVOrInvoiceNo;

                    lblInsurancePolicy.Text = receiptDoc.InsurancePolicyNo != ""?receiptDoc.InsurancePolicyNo : "-";

                    var activity = new Activity();
                    activity.LoadByPrimaryKey(Convert.ToInt32(GRNFDetail.Rows[0]["ActivityID"]));

                    txtActivity.EditValue = activity.FullActivityName;
                    lblActivity.Text      = activity.Name;

                    lblSubAccount.Text = activity.SubAccountName;
                    lblMode.Text       = activity.ModeName;
                    lblAccount.Text    = activity.AccountName;

                    gridDetails.DataSource = GRNFDetail;
                }

                if (ReceiveDoc.IsThereShortageOrDamage(ReceiptID))
                {
                    gridShortage.DataSource = receiptDoc.GetDiscrepancyForGRNF();
                }
            }

            catch
            {
                gridDetails.DataSource = null;
            }
        }
        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";
                }

            }
        }
Example #38
0
        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();
            }
        }
 /// <summary>
 /// Gets the supplier.
 /// </summary>
 /// <returns></returns>
 public int GetSupplier()
 {
     BLL.PO po = new PO();
     po.LoadByPrimaryKey(this.POID);
     return(po.SupplierID);
 }
        /// <summary>
        /// Costs the analysis.
        /// </summary>
        /// <param name="pGRVNo">The p GRV no.</param>
        /// <returns></returns>
        public DataView CostAnalysis(string pGRVNo)
        {
            GetGrandTotal();
            PO             PO             = ReceiptInvoice.PO;
            ReceiptInvoice receiptInvoice = ReceiptInvoice;
            Activity       Activity       = new Activity();

            Activity.LoadByPrimaryKey(receiptInvoice.ActivityID);
            double       GIT             = TotalLandedCost - Provision;
            JournalEntry UnitCostJournal = new JournalEntry(Activity.AccountName, Activity.SubAccountName, Activity.Name, PO.Supplier.CompanyName, "", PO.PONumber, pGRVNo, receiptInvoice.STVOrInvoiceNo, receiptInvoice.TransitTransferNo, receiptInvoice.WayBillNo, receiptInvoice.InsurancePolicyNo);
            double       PriceDifference = Math.Round(TotalLandedCost - this.GrandTotal, BLL.Settings.NoOfDigitsAfterTheDecimalPoint);


            if (BLL.Settings.IsCenter)
            {
                if (this.ReceiptInvoice.InvoiceTypeID != ReceiptInvoiceType.InvoiceType.LOCAL_PURCHASE && this.ReceiptInvoice.InvoiceTypeID != ReceiptInvoiceType.InvoiceType.CIP)
                {
                    UnitCostJournal.AddNewEntry("Stock", GrandTotal, null);
                    UnitCostJournal.AddNewEntry("ClaimFromSupplier", GetSupplierClaim(), null);
                    UnitCostJournal.AddNewEntry("ClaimFromInsurance", GetInsuranceClaim(), null);

                    if (PriceDifference < 0)
                    {
                        UnitCostJournal.AddNewEntry("Price Difference", null, Math.Abs(PriceDifference));
                    }
                    else
                    {
                        UnitCostJournal.AddNewEntry("Price Difference", Math.Abs(PriceDifference), null);
                    }

                    UnitCostJournal.AddNewEntry("GIT", null, GIT);
                    UnitCostJournal.AddNewEntry("Provision", null, Provision);
                    UnitCostJournal.AddNewEntry("Other Income", null, 0);
                }
                else
                {
                    UnitCostJournal.AddNewEntry("Stock", GrandTotal, null);
                    if (PriceDifference < 0)
                    {
                        UnitCostJournal.AddNewEntry("Price Difference", null, Math.Abs(PriceDifference));
                    }
                    else
                    {
                        UnitCostJournal.AddNewEntry("Price Difference", Math.Abs(PriceDifference), null);
                    }
                    UnitCostJournal.AddNewEntry("Account Payable ", null, GIT);
                }
            }
            else
            {
                UnitCostJournal.AddNewEntry("Stock", GrandTotal, null);
                if (PriceDifference < 0)
                {
                    UnitCostJournal.AddNewEntry("Price Difference", null, Math.Abs(PriceDifference));
                }
                else if (PriceDifference > 0)
                {
                    UnitCostJournal.AddNewEntry("Price Difference", Math.Abs(PriceDifference), null);
                }
                UnitCostJournal.AddNewEntry("Account Payable ", null, GIT);
            }

            return(UnitCostJournal.DefaultView());
        }
        /// <summary>
        /// Commits the account to account transfer.
        /// </summary>
        /// <param name="orderID">The order ID.</param>
        /// <param name="userID">The user ID.</param>
        /// <param name="convertedEthDate">The converted eth date.</param>
        public void CommitAccountToAccountTransfer(int orderID, int userID, DateTime convertedEthDate)
        {
            int?supplierID = null;

            BLL.Transfer transfer = new Transfer();
            transfer.LoadByOrderID(orderID);
            if (transfer.RowCount == 0)
            {
                return;
            }

            int newStoreID, newPhysicalStoreID;

            newStoreID         = transfer.ToStoreID;
            newPhysicalStoreID = transfer.ToPhysicalStoreID;

            PhysicalStore toPhysicalStore = new PhysicalStore();

            toPhysicalStore.LoadByPrimaryKey(transfer.ToPhysicalStoreID);

            BLL.PickList picklist = new PickList();
            picklist.LoadByOrderID(orderID);
            BLL.PickListDetail pld = new PickListDetail();
            pld.LoadByPickListIDWithStvlogID(picklist.ID);
            BLL.ReceiveDoc rdOriginal = new ReceiveDoc();
            rdOriginal.LoadByPrimaryKey(pld.ReceiveDocID);


            BLL.Order order = new Order();
            order.LoadByPrimaryKey(orderID);
            if (order.OrderTypeID == OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER)
            {
                var activity = new Activity();
                activity.LoadByPrimaryKey(newStoreID);
                supplierID = activity.SupplierID;
            }
            else if (order.OrderTypeID == OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER)
            {
                var activity = new Activity();
                activity.LoadByPrimaryKey(newPhysicalStoreID);
                supplierID = activity.SupplierID;
            }
            PO  po            = PO.CreatePOforStandard((int)order.GetColumn("OrderTypeID"), transfer.ToStoreID, supplierID, "Transfer", CurrentContext.LoggedInUser.ID);
            int IDPrinted     = Convert.ToInt32(pld.GetColumn("IDPrinted"));
            int receiptTypeID = order.OrderTypeID == OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER
                                    ? ReceiptType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER
                                    :order.OrderTypeID == OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER
                                          ? ReceiptType.CONSTANTS.STORE_TO_STORE_TRANSFER
                                          : order.OrderTypeID == OrderType.CONSTANTS.ERROR_CORRECTION_TRANSFER
                                          ? ReceiptType.CONSTANTS.ERROR_CORRECTION:ReceiptType.CONSTANTS.STANDARD_RECEIPT;



            Receipt receipt = ReceiptInvoice.CreateReceiptInvoiceAndReceiptForTransfer(receiptTypeID, po.ID, toPhysicalStore.PhysicalStoreTypeID, IDPrinted, userID);

            var mergedPickLists = MergePickListsOfSameInfo(pld); // Picklists of the same info means: Based on all constraints we have on receiveDoc(Batch,Exp,ItemID,UnitID...): should be merged with summed quantity.

            pld.Rewind();
            while (!pld.EOF)
            {
                if (IDPrinted != Convert.ToInt32(pld.GetColumn("IDPrinted")))
                {
                    IDPrinted = Convert.ToInt32(pld.GetColumn("IDPrinted"));
                    receipt   = ReceiptInvoice.CreateReceiptInvoiceAndReceiptForTransfer(receiptTypeID, po.ID, toPhysicalStore.PhysicalStoreTypeID, IDPrinted, userID);
                }

                var rDoc = new ReceiveDoc();
                if (!mergedPickLists.ContainsKey(pld.ID))
                {
                    pld.MoveNext();
                    continue;
                }

                rDoc.SaveNewReceiveDocEntryFromPicklistDetail(pld, userID, newStoreID, newPhysicalStoreID,
                                                              convertedEthDate, receipt.ID, supplierID);
                pld.MoveNext();
            }
        }
 /// <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 btnSave_Click(object sender, EventArgs e)
        {
            int warehouseID = Convert.ToInt32(lkWarehouse.EditValue);

            receiveDoc.Rewind();
            var po = new BLL.PO();
            var receiptInvoice = new BLL.ReceiptInvoice();

            while (!receiveDoc.EOF)
            {
                //Handle the PO.
                //int receiptID;
                if (po.RowCount == 0 || po.StoreID != receiveDoc.StoreID)
                {
                    Supplier supplier = new Supplier();
                    po = BLL.PO.CreatePOforStandard(OrderType.CONSTANTS.STANDARD_ORDER, receiveDoc.StoreID,
                                                    supplier.GetHubHomeOfficeSupplierID(), "",CurrentContext.LoggedInUser.ID);
                    //Should we receive it as hub to hub transfer? We're now using Standard order.
                    receipt = BLL.ReceiptInvoice.CreateAutomaticReceiptInvoiceForSTVTransfer(po.ID, warehouseID, STVNo,
                                                                                             CurrentContext.UserId);
                }

                receiveDoc.Quantity = receiveDoc.QtyPerPack * receiveDoc.NoOfPack;
                receiveDoc.ReceiptID = receipt.ID;
                receiveDoc.MoveNext();
            }
            receiveDoc.Save();

            //Save the location
            receiveDoc.Rewind();

            BLL.ReceivePallet receivePallet = new ReceivePallet();
            while (!receiveDoc.EOF)
            {
                //Save Location Information
                BLL.PalletLocation palletLocation = new PalletLocation();

                receivePallet.AddNew();

                int palletLocationID = Convert.ToInt32(receiveDoc.GetColumn("PalletLocationID"));
                receivePallet.PalletLocationID = palletLocationID;

                palletLocation.LoadByPrimaryKey(palletLocationID);

                receivePallet.PalletID = palletLocation.PalletID;
                receivePallet.ReceivedQuantity = receiveDoc.Quantity;
                receivePallet.Balance = receiveDoc.Quantity;
                receivePallet.ReceiveID = receiveDoc.ID;
                receivePallet.ReservedStock = 0;

                //Save Discrepancy information if there is any
                receiveDocShortage.Rewind();
                while (receiveDocShortage.FindNextByGUID(receiveDoc.GetColumn("GUID").ToString()))
                {
                    receiveDocShortage.ReceiveDocID = receiveDoc.ID;

                    if (receiveDocShortage.ShortageReasonID == ShortageReasons.Constants.DAMAGED)
                    {
                        receiveDoc.NoOfPack += receiveDocShortage.NoOfPacks;
                        receiveDoc.Quantity += receiveDocShortage.NoOfPacks*receiveDoc.QtyPerPack;

                        palletLocationID = Convert.ToInt32(receiveDocShortage.GetColumn("PalletLocationID"));
                        receivePallet.AddNew();
                        receivePallet.PalletLocationID = palletLocationID;
                        palletLocation.LoadByPrimaryKey(palletLocationID);

                        receivePallet.PalletID = palletLocation.PalletID;
                        receivePallet.ReceivedQuantity = receiveDocShortage.NoOfPacks*receiveDoc.QtyPerPack;
                        receivePallet.Balance = receiveDocShortage.NoOfPacks*receiveDoc.QtyPerPack;
                        receivePallet.ReceiveID = receiveDoc.ID;
                        receivePallet.ReservedStock = 0;
                    }
                }

                receiveDoc.MoveNext();
            }
            receivePallet.IsOriginalReceive = true;
            receivePallet.Save();
        }
Example #44
0
        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();
        }