Esempio n. 1
0
        void workerLoadRetail_DoWork(object sender, DoWorkEventArgs e)
        {
            string     errorCode;
            string     errorText;
            CustomerVO customerObj  = null;
            SaleVO     saleObj      = null;
            int        ticketNumber = (int)e.Argument;

            RetailProcedures.GetSaleData(GlobalDataAccessor.Instance.DesktopSession, GlobalDataAccessor.Instance.OracleDA, Utilities.GetIntegerValue(CDS.CurrentSiteId.StoreNumber, 0),
                                         ticketNumber, "3", StateStatus.BLNK, "SALE", true, out saleObj, out customerObj, out errorCode, out errorText);

            Action <string>  actionShowMessageBox = s => MessageBox.Show(s);
            Action <Control> setFocus             = c => c.Focus();

            if (saleObj == null || saleObj.RetailItems.Count == 0)
            {
                this.Invoke(actionShowMessageBox, new object[] { "No records found or not the originating shop of the number entered." });
                this.Invoke(setFocus, new object[] { txtReceiptNumber });
                e.Result = false;
                return;
            }
            else
            {
                int maxDaysForRefundEligibility = new BusinessRulesProcedures(GlobalDataAccessor.Instance.DesktopSession).GetMaxDaysForRefundEligibility(CDS.CurrentSiteId);
                if (ShopDateTime.Instance.FullShopDateTime.Date > saleObj.DateMade.AddDays(maxDaysForRefundEligibility))
                {
                    this.Invoke(actionShowMessageBox, new object[] { "The number of days eligible for refund has expired for the MSR number entered." });
                    this.Invoke(setFocus, new object[] { txtReceiptNumber });
                    e.Result = false;
                    return;
                }

                this.Invoke(new Action(() =>
                {
                    GlobalDataAccessor.Instance.DesktopSession.Sales = new List <SaleVO>();
                    GlobalDataAccessor.Instance.DesktopSession.Sales.Add(saleObj);
                    GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer = customerObj;
                }));
            }
        }
        private void customButtonOK_Click(object sender, EventArgs e)
        {
            labelErrorMessage.Visible = false;
            noDataFound = false;
            PurchaseVO     purchaseObj         = null;
            CustomerVO     customerObj         = null;
            SaleVO         saleObj             = null;
            LayawayVO      layawayObj          = null;
            CashTransferVO bankTransferObj     = null;
            CashTransferVO shopCashTransferObj = null;
            DataSet        mdseInfo            = null;
            string         errorCode;
            string         errorText;

            getCustomerInfo = true;
            string tenderType;

            GlobalDataAccessor.Instance.DesktopSession.Purchases = new List <PurchaseVO>();
            GlobalDataAccessor.Instance.DesktopSession.Sales     = new List <SaleVO>();
            GlobalDataAccessor.Instance.DesktopSession.Layaways  = new List <LayawayVO>();
            ReleaseFingerprintsInfo releaseFingerprintsequest = null;
            bool retValue = false;

            if (voidBuyReturn)
            {
                retValue = PurchaseProcedures.GetPurchaseData(Utilities.GetIntegerValue(GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber, 0),
                                                              Utilities.GetIntegerValue(customTextBoxTranNo.Text, 0), "2", StateStatus.BLNK, "RET", true, out purchaseObj, out customerObj, out tenderType, out errorCode, out errorText);
            }
            else if (voidBuy)
            {
                retValue = PurchaseProcedures.GetPurchaseData(Utilities.GetIntegerValue(GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber, 0),
                                                              Utilities.GetIntegerValue(customTextBoxTranNo.Text, 0), "2", StateStatus.BLNK, "", true, out purchaseObj, out customerObj, out tenderType, out errorCode, out errorText);
            }
            else if (voidSale)
            {
                retValue = RetailProcedures.GetSaleData(GlobalDataAccessor.Instance.DesktopSession, GlobalDataAccessor.Instance.OracleDA, Utilities.GetIntegerValue(GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber, 0),
                                                        Utilities.GetIntegerValue(customTextBoxTranNo.Text, 0), "3", StateStatus.BLNK, "SALE", false, out saleObj, out customerObj, out errorCode, out errorText);
            }
            else if (voidLayaway)
            {
                retValue = RetailProcedures.GetLayawayData(GlobalDataAccessor.Instance.DesktopSession, GlobalDataAccessor.Instance.OracleDA, Utilities.GetIntegerValue(GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber, 0),
                                                           Utilities.GetIntegerValue(customTextBoxTranNo.Text, 0), "4", StateStatus.BLNK, "ALL", false, out layawayObj, out customerObj, out errorCode, out errorText);
            }
            else if (voidSaleRefund)
            {
                retValue = RetailProcedures.GetSaleData(GlobalDataAccessor.Instance.DesktopSession, GlobalDataAccessor.Instance.OracleDA, Utilities.GetIntegerValue(GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber, 0),
                                                        Utilities.GetIntegerValue(customTextBoxTranNo.Text, 0), "3", StateStatus.BLNK, "REFUND", false, out saleObj, out customerObj, out errorCode, out errorText);
            } //BZ # 419
            else if (voidBanktoShopCashTransfer)
            {
                retValue = ShopCashProcedures.GetBankTransferDetails(customTextBoxTranNo.Text, "BANKTOSHOP", GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber, GlobalDataAccessor.Instance.DesktopSession,
                                                                     out bankTransferObj, out errorCode, out errorText);
            }
            else if (voidShopToBankCashTransfer)
            {
                retValue = ShopCashProcedures.GetBankTransferDetails(customTextBoxTranNo.Text, "SHOPTOBANK", GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber, GlobalDataAccessor.Instance.DesktopSession,
                                                                     out bankTransferObj, out errorCode, out errorText);
            }//BZ # 419 end

            else if (voidStoreCashTransfer)
            {
                string storeNumber = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber;
                retValue = ShopCashProcedures.GetShopCashTransferData(customTextBoxTranNo.Text, "", storeNumber, GlobalDataAccessor.Instance.DesktopSession, out shopCashTransferObj, out errorCode, out errorText);
            }
            else if (voidMerchandiseTransfer)
            {
                string storeNumber = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber;
                string tranNo      = customTextBoxTranNo.Text;

                if (customTextBoxTranNo.Text.Length > 6)
                {
                    tranNo = tranNo.Substring(5);
                }

                retValue = VoidProcedures.getTransferToVoid(Utilities.GetIntegerValue(tranNo, 0),
                                                            storeNumber, out mdseInfo, out errorCode, out errorText);
                //                retValue = VoidProcedures.GetEligibleToScrapItems(Utilities.GetIntegerValue(customTextBoxTranNo.Text, 0),
                //                    storeNumber, out mdse , out errorCode, out errorText);
            }
            else if (voidReleaseFingerprints)
            {
                string storeNumber = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber;
                string tranNo      = customTextBoxTranNo.Text;

                if (tranNo.Length > 6)
                {
                    tranNo = tranNo.Substring(5);
                }

                // Add procedure to VoidsProcedurees to Locate the Release Fingerprint Authorization
                GlobalDataAccessor.Instance.FingerPrintRelaseAuthorizationInfo =
                    HoldsProcedures.GetReleaseFingerprintAuthorization(tranNo,
                                                                       storeNumber, out errorCode, out errorText);
            }

            if (voidBuy || voidBuyReturn)
            {
                if (retValue && purchaseObj != null)
                {
                    GlobalDataAccessor.Instance.DesktopSession.Purchases.Add(purchaseObj);
                    if (purchaseObj.EntityType != "V" && customerObj != null)
                    {
                        GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer = customerObj;
                    }

                    GlobalDataAccessor.Instance.DesktopSession.HistorySession.Back();
                }
                else
                {
                    noDataFound = true;
                }
            }
            else if (voidSale || voidSaleRefund)
            {
                if (retValue && saleObj != null)
                {
                    if (saleObj.RefType == "4")
                    {
                        MessageBox.Show("This sale originated from a layaway. You have to void the last layaway payment and not the sale");
                        return;
                    }
                    GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer = customerObj;
                    GlobalDataAccessor.Instance.DesktopSession.Sales.Add(saleObj);
                    GlobalDataAccessor.Instance.DesktopSession.HistorySession.Back();
                }
                else
                {
                    noDataFound = true;
                }
            }
            else if (voidLayaway)
            {
                if (retValue && layawayObj != null)
                {
                    GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer = customerObj;
                    GlobalDataAccessor.Instance.DesktopSession.Layaways.Add(layawayObj);
                    GlobalDataAccessor.Instance.DesktopSession.HistorySession.Back();
                }
                else
                {
                    noDataFound = true;
                }
            }
            //BZ # 419
            //else if (voidCashTransfer)
            else if (voidBanktoShopCashTransfer || voidShopToBankCashTransfer)
            {
                //BZ # 419 end
                if (retValue && bankTransferObj != null)
                {
                    GlobalDataAccessor.Instance.DesktopSession.CashTransferData = bankTransferObj;
                    GlobalDataAccessor.Instance.DesktopSession.HistorySession.Back();
                }
                else
                {
                    noDataFound = true;
                }
            }
            else if (voidStoreCashTransfer)
            {
                if (retValue && shopCashTransferObj != null)
                {
                    GlobalDataAccessor.Instance.DesktopSession.CashTransferData = shopCashTransferObj;
                    GlobalDataAccessor.Instance.DesktopSession.HistorySession.Back();
                }
                else
                {
                    noDataFound = true;
                }
            }
            else if (voidMerchandiseTransfer)
            {
                if (retValue && mdseInfo != null && mdseInfo.Tables.Count > 0)
                {
                    if (isFaultyTransferINOUT(mdseInfo))
                    {
                        noDataFound = true;
                    }
                    else
                    {
                        GlobalDataAccessor.Instance.DesktopSession.MdseTransferData       = mdseInfo;
                        GlobalDataAccessor.Instance.DesktopSession.SelectedTransferNumber = customTextBoxTranNo.Text;
                        GlobalDataAccessor.Instance.DesktopSession.HistorySession.Back();
                    }
                }
                else
                {
                    noDataFound = true;
                }
            }
            else if (voidReleaseFingerprints && GlobalDataAccessor.Instance.FingerPrintRelaseAuthorizationInfo != null)
            {
                this.DialogResult = DialogResult.OK;
                //GlobalDataAccessor.Instance.DesktopSession.HistorySession.Back();
            }

            if (noDataFound)
            {
                labelErrorMessage.Text    = "The number entered is not valid. Please enter another number";
                labelErrorMessage.Visible = true;
                return;
            }
        }