예제 #1
0
        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 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 LoadPurchaseOrderForEdit()
        {
            PO po = new PO();
            po.LoadByPrimaryKey(PoID);

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

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

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

            if(!po.IsColumnNull("NBE"))
                txtNBEServiceCharge.EditValue = po.NBE;
            if (!po.IsColumnNull("ExhangeRate"))
                txtExchangeRate.EditValue = po.ExhangeRate;
            if (po.s_OtherExpense != "")
                txtInsuredSum.EditValue = po.OtherExpense;
            if (!po.IsColumnNull("RefNo"))
                txtRefNo.EditValue = po.RefNo;
            if (!po.IsColumnNull("Delivery"))
                txtDelivery.EditValue = po.Delivery;
            if (!po.IsColumnNull("Description"))
                txtDescription.EditValue = po.Description;
            if (!po.IsColumnNull("TermOfPayement"))
                lkTermOfPayement.EditValue = po.TermOfPayement;
            if (!po.IsColumnNull("AirFreight"))
                txtFreight.EditValue = po.AirFreight;
            DisableEditDependingOnSetting();
        }
 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); }
     }
 }
예제 #5
0
        private void LoadData(int ReceiptID, int InvoiceID, int PoID)
        {
            //PO Cost Elements;
            purchaseOrder.LoadByPrimaryKey(PoID);
            Invoice.LoadByPrimaryKey(InvoiceID);
            GRV.LoadByPrimaryKey(ReceiptID);

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

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

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


            //GRV Cost Elements



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

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

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

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

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

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

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

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

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