Ejemplo n.º 1
0
        private void textBoxPhone_Leave(object sender, EventArgs e)
        {
            string sPhone = "";

            sPhone = Convert.ToString(txtSTD.Text).Trim() + Convert.ToString(textBoxPhone.Text).Trim();

            if (sPhone.Length > 13)
            {
                using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage("Phone number should be within 10 digits", MessageBoxButtons.OK, MessageBoxIcon.Error))
                {
                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                    textBoxPhone.Focus();
                }
            }

            string retString = string.Empty;
            string sMyStr    = textBoxPhone.Text;

            //if(!string.IsNullOrEmpty(txtSTD.Text) && !string.IsNullOrEmpty(txtMobilePrimary.Text))
            //{
            //    if(sMyStr.Length > 7)
            //        retString = sMyStr.Substring(Convert.ToInt16(txtSTD.Text.Length), Convert.ToInt16(txtMobilePrimary.Text.Length) - Convert.ToInt16(txtSTD.Text.Length));
            //}
            txtMobilePrimary.Text = sMyStr;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Show customertransactions for customer
        /// </summary>
        /// <param name="customerId">The id of the customer</param>
        public void Transactions(string customerId)
        {
            string[] custTransactionsLanguageTexts = new string[3];
            custTransactionsLanguageTexts[0] = ApplicationLocalizer.Language.Translate(51151);
            custTransactionsLanguageTexts[1] = ApplicationLocalizer.Language.Translate(51152);
            custTransactionsLanguageTexts[2] = ApplicationLocalizer.Language.Translate(51153);

            CustomerData customerData = new CustomerData(Application.Settings.Database.Connection, Application.Settings.Database.DataAreaID);

            using (DataTable dt = customerData.GetCustomerTransactions(string.Empty, customerId, 1, custTransactionsLanguageTexts))
            {
                if (dt.Rows.Count > 0)
                {
                    using (frmCustomerTransactions customerTransactions = new frmCustomerTransactions(customerId, Application))
                    {
                        this.Application.ApplicationFramework.POSShowForm(customerTransactions);
                    }
                }
                else
                {
                    using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(51000))//No transactions are found for the customer.
                    {
                        this.Application.ApplicationFramework.POSShowForm(dialog);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private static bool CheckCustomer(DE.IPosTransaction posTransaction)
        {
            RetailTransaction retailTransaction = (RetailTransaction)posTransaction;

            if (retailTransaction.Customer.Blocked == DE.BlockedEnum.All)
            {
                //Display a message
                using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(51002)) //This customer has been blocked. No sales or transactions are allowed.
                {
                    Customer.InternalApplication.ApplicationFramework.POSShowForm(dialog);
                }

                //Cancel the customer account
                retailTransaction.Customer = GetBlankCustomer();

                return(false);
            }

            if (retailTransaction.Customer.Blocked == DE.BlockedEnum.Invoice)
            {
                //Display message
                using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(51003)) //This customer has been blocked. This account can not be charged to.
                {
                    Customer.InternalApplication.ApplicationFramework.POSShowForm(dialog);
                }
            }

            return(true);
        }
Ejemplo n.º 4
0
        public void AddToGiftCard(IRetailTransaction retailTransaction, ITender gcTenderInfo)
        {
            //Start: added on 16/07/2014 for customer selection is must
            RetailTransaction retailTrans = retailTransaction as RetailTransaction;

            if (retailTrans != null)
            {
                if (Convert.ToString(retailTrans.Customer.CustomerId) == string.Empty || string.IsNullOrEmpty(retailTrans.Customer.CustomerId))
                {
                    using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage("Add a customer to transaction before making a deposit", MessageBoxButtons.OK, MessageBoxIcon.Error))
                    {
                        LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                    }
                    return;
                }
            }
            //End: added on 16/07/2014 for customer selection is must

            LogMessage("Adding money to gift card.",
                       LSRetailPosis.LogTraceLevel.Trace,
                       "GiftCard.AddToGiftCard");

            GiftCardController controller = new GiftCardController(GiftCardController.ContextType.GiftCardAddTo, (PosTransaction)retailTransaction, (Tender)gcTenderInfo);

            using (GiftCardForm giftCardForm = new GiftCardForm(controller))
            {
                POSFormsManager.ShowPOSForm(giftCardForm);

                if (giftCardForm.DialogResult == DialogResult.OK)
                {
                    // Add the gift card to the transaction.
                    GiftCertificateItem giftCardItem = (GiftCertificateItem)this.Application.BusinessLogic.Utility.CreateGiftCardLineItem(
                        ApplicationSettings.Terminal.StoreCurrency, this.Application.Services.Rounding, retailTransaction);

                    giftCardItem.SerialNumber  = controller.CardNumber;
                    giftCardItem.StoreId       = retailTransaction.StoreId;
                    giftCardItem.TerminalId    = retailTransaction.TerminalId;
                    giftCardItem.StaffId       = retailTransaction.OperatorId;
                    giftCardItem.TransactionId = retailTransaction.TransactionId;
                    giftCardItem.ReceiptId     = retailTransaction.ReceiptId;
                    giftCardItem.Amount        = controller.Amount;
                    giftCardItem.Balance       = controller.Balance;
                    giftCardItem.Date          = DateTime.Now;
                    giftCardItem.AddTo         = true;

                    giftCardItem.Price = giftCardItem.Amount;
                    giftCardItem.StandardRetailPrice = giftCardItem.Amount;
                    giftCardItem.Quantity            = 1;
                    giftCardItem.TaxRatePct          = 0;
                    giftCardItem.Description         = ApplicationLocalizer.Language.Translate(55000); // Add to Gift Card
                    giftCardItem.Comment             = controller.CardNumber;
                    giftCardItem.NoDiscountAllowed   = true;
                    giftCardItem.Found = true;

                    ((RetailTransaction)retailTransaction).Add(giftCardItem);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Created by : Ripan Hossain
        /// Created on : 12/04/2013
        /// Modified by :
        /// Modified on :
        /// Purpose :
        /// </summary>
        /// <param name="_dt"></param>
        /// <param name="_line"></param>
        public frmOrderSketch(DataTable _dt, decimal _line, string _breadCrumb)
        {
            InitializeComponent();
            btnClear.Enabled  = false;
            btnSearch.Enabled = false;
            btnSearch.Enabled = false;
            btnSubmit.Enabled = false;
            DataRow[] drView = _dt.Select("LINENUM=" + _line);

            lblBreadCrumbs.Text = _breadCrumb + " > " + " Line no : " + " " + Convert.ToInt16(_line) + " > " + " Sketch";
            if (drView.Count() > 0)
            {
                if (!string.IsNullOrEmpty(Convert.ToString(drView[0]["SKETCH"])))
                {
                    Byte[] pictureData = (byte[])(drView[0]["SKETCH"]);


                    if (pictureData.Length > 0)
                    {
                        Image i = LSRetailPosis.ButtonGrid.GUIHelper.GetBitmap(pictureData);
                        if (i != null)
                        {
                            Bitmap bitmap = new Bitmap(i);

                            PictureBox imageControl = new PictureBox();
                            imageControl.Height = 433;
                            imageControl.Width  = 749;

                            if (i.Height > imageControl.Height && i.Width > imageControl.Width || (i.Height > imageControl.Height || i.Width > imageControl.Width))
                            {
                                picItem.SizeMode = PictureBoxSizeMode.StretchImage;
                            }
                            else
                            {
                                picItem.SizeMode = PictureBoxSizeMode.Normal;
                            }

                            imageControl.Image = i;
                            picItem.Image      = i;
                        }
                    }
                }

                this.ShowDialog();
            }
            else
            {
                using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage("No Sketch Found.", MessageBoxButtons.OK, MessageBoxIcon.Information))
                {
                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                }
                this.Close();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Called to update points when conclude a transaction.
        /// </summary>
        /// <param name="retailTransaction"></param>
        public void UpdateLoyaltyPoints(IRetailTransaction retailTransaction)
        {
            if (retailTransaction == null)
            {
                throw new ArgumentNullException("retailTransaction");
            }

            this.transaction = (RetailTransaction)retailTransaction;

            // Sending confirmation to the transactions service about earned points
            if (this.transaction.LoyaltyItem != null)
            {
                if (this.transaction.LoyaltyItem.UsageType == LoyaltyItemUsageType.UsedForLoyaltyRequest)
                {
                    UpdateIssuedLoyaltyPoints(this.transaction.LoyaltyItem);

                    if (this.transaction.LoyaltyItem.CalculatedLoyaltyPoints < 0)
                    {
                        bool    cardIsValid           = false;
                        string  comment               = string.Empty;
                        int     loyaltyTenderTypeBase = 0;
                        decimal pointsEarned          = 0M;

                        GetPointStatus(ref pointsEarned, ref cardIsValid, ref comment, ref loyaltyTenderTypeBase, this.transaction.LoyaltyItem.LoyaltyCardNumber);

                        if (cardIsValid && pointsEarned < 0)
                        {
                            string message = string.Format(LSRetailPosis.ApplicationLocalizer.Language.Translate(50500), pointsEarned);

                            using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(message, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error))
                            {
                                LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog); // Not enough points available to complete payment
                            }
                        }
                    }
                }
                else if (this.transaction.LoyaltyItem.UsageType == LoyaltyItemUsageType.UsedForLoyaltyTender)
                {
                    // Sending confirmation to the transaction service about used points
                    foreach (ITenderLineItem tenderItem in this.transaction.TenderLines)
                    {
                        ILoyaltyTenderLineItem asLoyaltyTenderLineItem = tenderItem as ILoyaltyTenderLineItem;

                        if ((asLoyaltyTenderLineItem != null) && !asLoyaltyTenderLineItem.Voided)
                        {
                            if (asLoyaltyTenderLineItem.LoyaltyPoints != 0)
                            {
                                UpdateUsedLoyaltyPoints(asLoyaltyTenderLineItem);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private void txtSTD_Leave(object sender, EventArgs e)
        {
            string sPhone = "";

            sPhone = Convert.ToString(txtSTD.Text).Trim() + Convert.ToString(textBoxPhone.Text).Trim();

            if (sPhone.Length > 13)
            {
                using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage("Phone number should be within 10 digits", MessageBoxButtons.OK, MessageBoxIcon.Error))
                {
                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                }
            }
        }
Ejemplo n.º 8
0
        private static bool CheckInvoicedCustomer(DE.IPosTransaction posTransaction)
        {
            RetailTransaction retailTransaction = (RetailTransaction)posTransaction;

            //If the Invoiced customer has All as blocked then the selected customer can not be added to the transaction
            if (retailTransaction.InvoicedCustomer.Blocked == DE.BlockedEnum.All)
            {
                //If Invoiced Customer is blocked then the original customer should be blocked too.
                retailTransaction.Customer.Blocked = DE.BlockedEnum.All;

                //Display the message
                using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(51004)) //The invoiced customer has been blocked. Charging to this account will not be allowed.
                {
                    Customer.InternalApplication.ApplicationFramework.POSShowForm(dialog);
                }

                //Cancel all customer accounts
                retailTransaction.Customer         = GetBlankCustomer();
                retailTransaction.InvoicedCustomer = GetBlankCustomer();

                return(false);
            }

            if (retailTransaction.InvoicedCustomer.Blocked == DE.BlockedEnum.Invoice)
            {
                //If a similar message has already been displayed for the original customer then don't display it again.
                if (retailTransaction.Customer.Blocked != DE.BlockedEnum.Invoice)
                {
                    using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(51005)) //This customer has been blocked. This account can not be charged to.
                    {
                        Customer.InternalApplication.ApplicationFramework.POSShowForm(dialog);
                    }
                }

                //If Invoiced Customer is blocked then the original customer should be blocked too.
                retailTransaction.Customer.Blocked = DE.BlockedEnum.Invoice;
            }

            return(true);
        }
Ejemplo n.º 9
0
        private void InventoryLookup(string barcode)
        {
            ClearForm();

            if (GetItemInfo(barcode) == false)
            {
                ClearForm();
                return;
            }

            // Get the inventory through the Transaction Services....
            bool   retVal  = false;
            string comment = string.Empty;

            try
            {
                // Begin by checking if there is a connection to the Transaction Service
                Dialog.InternalApplication.TransactionServices.CheckConnection();

                // Get the inventory status from the Transaction Services...
                Dialog.InternalApplication.TransactionServices.InventoryLookup(ref retVal, ref comment, ref inventoryTable, saleLineItem.ItemId, saleLineItem.Dimension.VariantId);
            }
            catch (PosisException px)
            {
                LSRetailPosis.ApplicationExceptionHandler.HandleException(this.ToString(), px);
                LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSErrorDialog(px);

                ClearForm();
                return;
            }
            catch (Exception x)
            {
                LSRetailPosis.ApplicationExceptionHandler.HandleException(this.ToString(), x);
                LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSErrorDialog(new PosisException(13010, x));      // Could not connect to the transaction services.

                ClearForm();
                return;
            }

            // Populate the foreground of the dialog => The local store and remove it from the list of other stores....
            LSRetailPosis.DataAccess.SettingsData settingsData = new LSRetailPosis.DataAccess.SettingsData(ApplicationSettings.Database.LocalConnection, ApplicationSettings.Database.DATAAREAID);
            int tableIndex = -1;

            lblItem.Text         = saleLineItem.Description;
            lblItemId.Text       = saleLineItem.ItemId;
            colInventory.Caption = string.Format(ApplicationLocalizer.Language.Translate(2613), saleLineItem.SalesOrderUnitOfMeasure);

            // Display dimensions if it is a variant item {Color - Size - Style - Config}
            if (!string.IsNullOrEmpty(saleLineItem.Dimension.VariantId))
            {
                StringBuilder dimensions = new StringBuilder();

                if (!string.IsNullOrEmpty(saleLineItem.Dimension.ColorName))
                {
                    dimensions.Append(saleLineItem.Dimension.ColorName);
                }

                if (!string.IsNullOrEmpty(saleLineItem.Dimension.SizeName))
                {
                    if (dimensions.Length > 0)
                    {
                        dimensions.Append(dimensionSeparator);
                    }

                    dimensions.Append(saleLineItem.Dimension.SizeName);
                }

                if (!string.IsNullOrEmpty(saleLineItem.Dimension.StyleName))
                {
                    if (dimensions.Length > 0)
                    {
                        dimensions.Append(dimensionSeparator);
                    }

                    dimensions.Append(saleLineItem.Dimension.StyleName);
                }

                if (!string.IsNullOrEmpty(saleLineItem.Dimension.ConfigName))
                {
                    if (dimensions.Length > 0)
                    {
                        dimensions.Append(dimensionSeparator);
                    }

                    dimensions.Append(saleLineItem.Dimension.ConfigName);
                }

                lblItemDimensions.Text = dimensions.ToString();

                if (!lblItemDimensions.Visible)
                {
                    lblItemDimensions.Visible = true;
                }
            }
            else
            {
                lblItemDimensions.Text = string.Empty;

                if (lblItemDimensions.Visible)
                {
                    lblItemDimensions.Visible = false;
                }
            }

            if (inventoryTable.Rows.Count > 0)
            {
                foreach (DataRow row in inventoryTable.Rows)
                {
                    // Convert the quantity from Inventory units to Sales units.
                    decimal inventory = saleLineItem.UnitQtyConversion.Convert(DBUtil.ToDecimal(row["INVENTORY"]));
                    row["INVENTORY"] = Dialog.InternalApplication.Services.Rounding.RoundQuantity(inventory, saleLineItem.SalesOrderUnitOfMeasure);

                    // Inventory for the local store will be shown on the right panel of dialog (and not in grid)
                    string itemInventLocation = DBUtil.ToStr(row["INVENTLOCATIONID"]);

                    if (ApplicationSettings.Terminal.InventLocationId.Equals(itemInventLocation, StringComparison.OrdinalIgnoreCase))
                    {
                        lblInventory.Text = string.Format(ApplicationLocalizer.Language.Translate(2614), row["INVENTORY"], saleLineItem.SalesOrderUnitOfMeasure);
                        tableIndex        = inventoryTable.Rows.IndexOf(row);
                    }
                }

                if (tableIndex != -1)
                {
                    inventoryTable.Rows.RemoveAt(tableIndex);
                }

                grInventory.DataSource = this.inventoryTable;
            }
            else
            {
                using (LSRetailPosis.POSProcesses.frmMessage msgBox = new LSRetailPosis.POSProcesses.frmMessage(2609, MessageBoxButtons.OK, MessageBoxIcon.Error))  // Unable to retrieve the inventory status.
                {
                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(msgBox);
                }

                ClearForm();
            }
        }
Ejemplo n.º 10
0
        public void IssueGiftCard(IPosTransaction posTransaction, ITender gcTenderInfo)
        {
            //Start: added on 16/07/2014 for customer selection is must
            RetailTransaction retailTrans = posTransaction as RetailTransaction;

            if (retailTrans != null)
            {
                if (Convert.ToString(retailTrans.Customer.CustomerId) == string.Empty || string.IsNullOrEmpty(retailTrans.Customer.CustomerId))
                {
                    using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage("Add a customer to transaction before making a deposit", MessageBoxButtons.OK, MessageBoxIcon.Error))
                    {
                        LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                    }
                    return;
                }
            }
            //End :added on 16/07/2014 for customer selection is must

            LogMessage("Issuing a gift card",
                       LSRetailPosis.LogTraceLevel.Trace,
                       "GiftCard.IssueGiftCard");

            if (FiscalPrinter.FiscalPrinter.Instance.FiscalPrinterEnabled())
            {
                //The operation should proceed after the fiscal printer handles IssueGiftCard
                FiscalPrinter.FiscalPrinter.Instance.IssueGiftCard(posTransaction, gcTenderInfo);
            }

            GiftCardController controller = new GiftCardController(GiftCardController.ContextType.GiftCardIssue, (PosTransaction)posTransaction, (Tender)gcTenderInfo);

            //controller.CardNumber = "111111"; testing for autogenerate no req sailendra da

            using (GiftCardForm giftCardForm = new GiftCardForm(controller))
            {
                POSFormsManager.ShowPOSForm(giftCardForm);

                if (giftCardForm.DialogResult == DialogResult.OK)
                {
                    // Add the gift card to the transaction.
                    RetailTransaction   retailTransaction = posTransaction as RetailTransaction;
                    GiftCertificateItem giftCardItem      = (GiftCertificateItem)this.Application.BusinessLogic.Utility.CreateGiftCardLineItem(
                        ApplicationSettings.Terminal.StoreCurrency,
                        this.Application.Services.Rounding, retailTransaction);

                    giftCardItem.SerialNumber  = controller.CardNumber;
                    giftCardItem.StoreId       = posTransaction.StoreId;
                    giftCardItem.TerminalId    = posTransaction.TerminalId;
                    giftCardItem.StaffId       = posTransaction.OperatorId;
                    giftCardItem.TransactionId = posTransaction.TransactionId;
                    giftCardItem.ReceiptId     = posTransaction.ReceiptId;
                    giftCardItem.Amount        = controller.Amount;
                    giftCardItem.Balance       = controller.Balance;
                    giftCardItem.Date          = DateTime.Now;

                    // Necessary property settings for the the gift certificate "item"...
                    giftCardItem.Price = giftCardItem.Amount;
                    giftCardItem.StandardRetailPrice = giftCardItem.Amount;
                    giftCardItem.Quantity            = 1;
                    giftCardItem.TaxRatePct          = 0;
                    giftCardItem.Description         = ApplicationLocalizer.Language.Translate(55001); // Gift Card
                    giftCardItem.Comment             = controller.CardNumber;
                    giftCardItem.NoDiscountAllowed   = true;
                    giftCardItem.Found = true;

                    retailTransaction.Add(giftCardItem);
                }
            }
        }
Ejemplo n.º 11
0
        public void AddLoyaltyPayment(IRetailTransaction retailTransaction, ICardInfo cardInfo, decimal amount)
        {
            try
            {
                try
                {
                    NewMessageWindow(50051, LSPosMessageTypeButton.NoButtons, System.Windows.Forms.MessageBoxIcon.Information);

                    this.transaction = (RetailTransaction)retailTransaction;

                    // Getting the loyalty info for the card, how many points have previously been earned
                    LoyaltyItem paymentLoyaltyItem = GetLoyaltyItem(ref cardInfo);

                    if (paymentLoyaltyItem != null)
                    {
                        //customerData.
                        if (this.transaction.Customer == null || string.Equals(this.transaction.Customer.CustomerId, paymentLoyaltyItem.CustID, StringComparison.OrdinalIgnoreCase) == false)
                        {
                            UpdateTransactionWithNewCustomer(paymentLoyaltyItem.CustID);
                        }

                        // if the amount is higher than the "new" NetAmountWithTax, then it is acceptable to lower the amount
                        if (Math.Abs(amount) > Math.Abs(this.transaction.TransSalePmtDiff))
                        {
                            amount = this.transaction.TransSalePmtDiff;
                        }

                        // Getting all possible loyalty posssiblities for the found scheme id
                        DataTable loyaltyPointsTable = GetLoyaltyPointsSchemeFromDB(paymentLoyaltyItem.SchemeID);

                        decimal totalNumberOfPoints = 0;
                        bool    tenderRuleFound     = false;

                        // now we add the points needed to pay current tender
                        totalNumberOfPoints = CalculatePointsForTender(ref tenderRuleFound, cardInfo.TenderTypeId, amount, loyaltyPointsTable);

                        if (tenderRuleFound)
                        {
                            bool    cardIsValid           = false;
                            string  comment               = string.Empty;
                            int     loyaltyTenderTypeBase = 0;
                            decimal pointsEarned          = 0;

                            // check to see if the user can afford so many points
                            GetPointStatus(ref pointsEarned, ref cardIsValid, ref comment, ref loyaltyTenderTypeBase, paymentLoyaltyItem.LoyaltyCardNumber);

                            if ((cardIsValid) && ((LoyaltyTenderTypeBase)loyaltyTenderTypeBase != LoyaltyTenderTypeBase.NoTender))
                            {
                                if (pointsEarned >= (totalNumberOfPoints * -1))
                                {
                                    //customerData.
                                    if (this.transaction.Customer == null || string.Equals(this.transaction.Customer.CustomerId, paymentLoyaltyItem.CustID, StringComparison.OrdinalIgnoreCase) == false)
                                    {
                                        UpdateTransactionWithNewCustomer(paymentLoyaltyItem.CustID);
                                    }

                                    //Add loyalty item to transaction.
                                    this.transaction.LoyaltyItem           = paymentLoyaltyItem;
                                    this.transaction.LoyaltyItem.UsageType = LoyaltyItemUsageType.UsedForLoyaltyTender;

                                    // Gathering tender information
                                    TenderData tenderData = new TenderData(ApplicationSettings.Database.LocalConnection, ApplicationSettings.Database.DATAAREAID);
                                    ITender    tenderInfo = tenderData.GetTender(cardInfo.TenderTypeId, ApplicationSettings.Terminal.StoreId);

                                    // this is the grand total
                                    decimal totalAmountDue = this.transaction.TransSalePmtDiff - amount;

                                    TenderRequirement tenderRequirement = new TenderRequirement((Tender)tenderInfo, amount, true, this.transaction.TransSalePmtDiff);
                                    if (!string.IsNullOrWhiteSpace(tenderRequirement.ErrorText))
                                    {
                                        using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(tenderRequirement.ErrorText, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error))
                                        {
                                            LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                                        }
                                    }

                                    //Add a loyalty tender item to transaction.
                                    LoyaltyTenderLineItem loyaltyTenderItem = (LoyaltyTenderLineItem)this.Application.BusinessLogic.Utility.CreateLoyaltyTenderLineItem();
                                    loyaltyTenderItem.CardNumber = paymentLoyaltyItem.LoyaltyCardNumber;
                                    loyaltyTenderItem.CardTypeId = cardInfo.CardTypeId;
                                    loyaltyTenderItem.Amount     = amount;

                                    //tenderInfo.
                                    loyaltyTenderItem.Description   = tenderInfo.TenderName;
                                    loyaltyTenderItem.TenderTypeId  = cardInfo.TenderTypeId;
                                    loyaltyTenderItem.LoyaltyPoints = totalNumberOfPoints;

                                    //convert from the store-currency to the company-currency...
                                    loyaltyTenderItem.CompanyCurrencyAmount = this.Application.Services.Currency.CurrencyToCurrency(
                                        ApplicationSettings.Terminal.StoreCurrency,
                                        ApplicationSettings.Terminal.CompanyCurrency,
                                        amount);

                                    // the exchange rate between the store amount(not the paid amount) and the company currency
                                    loyaltyTenderItem.ExchrateMST = this.Application.Services.Currency.ExchangeRate(
                                        ApplicationSettings.Terminal.StoreCurrency) * 100;

                                    // card tender processing and printing require an EFTInfo object to be attached.
                                    // however, we don't want loyalty info to show up where other EFT card info would on the receipt
                                    //  because loyalty has its own receipt template fields, so we just assign empty EFTInfo object
                                    loyaltyTenderItem.EFTInfo = Application.BusinessLogic.Utility.CreateEFTInfo();
                                    // we don't want Loyalty to be 'captured' by payment service, so explicitly set not to capture to be safe
                                    loyaltyTenderItem.EFTInfo.IsPendingCapture = false;

                                    loyaltyTenderItem.SignatureData = LSRetailPosis.POSProcesses.TenderOperation.ProcessSignatureCapture(tenderInfo, loyaltyTenderItem);

                                    this.transaction.Add(loyaltyTenderItem);
                                }
                                else
                                {
                                    using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(50057, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error))
                                    {
                                        LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                                    } // Not enough points available to complete payment
                                }
                            }
                            else
                            {
                                LSRetailPosis.POSProcesses.frmMessage dialog = null;
                                try
                                {
                                    if (string.IsNullOrEmpty(comment))
                                    {
                                        dialog = new LSRetailPosis.POSProcesses.frmMessage(50058, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                                    }
                                    else
                                    {
                                        dialog = new LSRetailPosis.POSProcesses.frmMessage(comment, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                                    }

                                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);    // Invalid loyaltycard
                                }
                                finally
                                {
                                    if (dialog != null)
                                    {
                                        dialog.Dispose();
                                    }
                                }
                            }
                        }
                        else
                        {
                            using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(50059, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error))
                            {
                                LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog); // Not enough points available to complete payment
                            }
                        }
                    }
                }
                finally
                {
                    CloseExistingMessageWindow();
                }
            }
            catch (Exception ex)
            {
                NetTracer.Error(ex, "Loyalty::AddLoyaltyPayment failed for retailTransaction {0} cardInfo {1} amount {2}", retailTransaction.TransactionId, cardInfo.CardNumber, amount);
                LSRetailPosis.ApplicationExceptionHandler.HandleException(this.ToString(), ex);
                throw;
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// This creates a loyalty line item based on the passed in card info, or prompts
        ///  to initialize default loyalty card info if no card info is supplied.
        /// </summary>
        /// <param name="cardInfo">Card info of loyalty card. If null, it will be initialized through user prompt.</param>
        /// <returns>Loyalty line item and loyalty card info if un-initialized</returns>
        private LoyaltyItem GetLoyaltyItem(ref ICardInfo cardInfo)
        {
            if (cardInfo == null)
            {
                // The loyalty card was not swiped and therefore we need to prompt for the card number...

                using (LSRetailPosis.POSProcesses.frmInputNumpad inputDialog = new LSRetailPosis.POSProcesses.frmInputNumpad(true, true))
                {
                    inputDialog.EntryTypes = NumpadEntryTypes.CardValidation;
                    inputDialog.PromptText = LSRetailPosis.ApplicationLocalizer.Language.Translate(50056); //Loyalty card number
                    inputDialog.Text       = ApplicationLocalizer.Language.Translate(50062);               // Add loyalty card
                    LP.POSFormsManager.ShowPOSForm(inputDialog);
                    DialogResult result = inputDialog.DialogResult;
                    // Quit if cancel is pressed...
                    if (result != System.Windows.Forms.DialogResult.OK)
                    {
                        return(null);
                    }
                    else
                    {
                        cardInfo = Utility.CreateCardInfo();
                        cardInfo.CardEntryType = CardEntryTypes.MANUALLY_ENTERED;
                        cardInfo.CardNumber    = inputDialog.InputText;
                        // Set card type to Loyalty card since this is a loyalty payment
                        //  Calling GetCardType sets the tender type properties on the cardInfo object or prompts user for more information.
                        cardInfo.CardType = CardTypes.LoyaltyCard;
                        this.Application.Services.Card.GetCardType(ref cardInfo);
                    }
                }
            }

            // Create the loyalty item
            LoyaltyItem loyaltyItem = (LoyaltyItem)this.Application.BusinessLogic.Utility.CreateLoyaltyItem();

            // Set its properties
            if (cardInfo.CardEntryType == CardEntryTypes.MAGNETIC_STRIPE_READ)
            {
                loyaltyItem.LoyaltyCardNumber = cardInfo.Track2Parts[0];
            }
            else
            {
                loyaltyItem.LoyaltyCardNumber = cardInfo.CardNumber;
            }

            // Check whether the card is allowed to collect loyalty points
            bool    cardIsValid           = false;
            string  comment               = string.Empty;
            int     loyaltyTenderTypeBase = 0;
            decimal pointsEarned          = 0;

            GetPointStatus(ref pointsEarned, ref cardIsValid, ref comment, ref loyaltyTenderTypeBase, loyaltyItem.LoyaltyCardNumber);

            if (cardIsValid)
            {
                loyaltyItem.AccumulatedLoyaltyPoints = pointsEarned;
                GetLoyaltyInfoFromDB(loyaltyItem);

                if (string.IsNullOrEmpty(this.transaction.Customer.CustomerId) ||
                    string.IsNullOrEmpty(loyaltyItem.CustID) ||
                    string.Compare(this.transaction.Customer.CustomerId, loyaltyItem.CustID, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    return(loyaltyItem);
                }
                else
                {
                    // loyalty payment could change customer, which is not desirable under various condition.
                    // All logic is captured in CustomerClear action, so we ask cashier to do that first.
                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSMessageDialog(3222);  // You must clear the customer before performing this operation.
                    return(null);
                }
            }
            else
            {
                LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSStatusBarText("Card ID: " + loyaltyItem.LoyaltyCardNumber); //License only allows limited number of item sales
                LSRetailPosis.POSProcesses.frmMessage dialog = null;
                try
                {
                    if (string.IsNullOrEmpty(comment))
                    {
                        dialog = new LSRetailPosis.POSProcesses.frmMessage(50058, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    }
                    else
                    {
                        dialog = new LSRetailPosis.POSProcesses.frmMessage(comment, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
                    }

                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);    // Invalid loyaltycard
                    return(null);
                }
                finally
                {
                    if (dialog != null)
                    {
                        dialog.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 13
0
        private bool ValidateControls()
        {
            bool bReturn = true;

            //if(string.IsNullOrEmpty(textBoxEmail.Text.Trim())) // added on 03/12/2014 req by S.Sharma
            //{
            //    using(LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.
            //                                            frmMessage("Please enter a valid email.", MessageBoxButtons.OK, MessageBoxIcon.Error))
            //    {
            //        LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
            //        textBoxEmail.Focus();
            //    }

            //    bReturn = false;

            //}

            if (string.IsNullOrEmpty(txtSalutation.Text.Trim())) // added on 03/12/2014 req by S.Sharma
            {
                using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.
                                                                      frmMessage("Please select a salutation.", MessageBoxButtons.OK, MessageBoxIcon.Error))
                {
                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                }

                bReturn = false;
            }
            if (string.IsNullOrEmpty(this.textBoxFirstName.Text.Trim()))
            {
                using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.
                                                                      frmMessage("Please enter first name.", MessageBoxButtons.OK, MessageBoxIcon.Error))
                {
                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                }

                bReturn = false;
            }

            if (string.IsNullOrEmpty(this.textBoxLastName.Text.Trim()))
            {
                using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.
                                                                      frmMessage("Please enter last name.", MessageBoxButtons.OK, MessageBoxIcon.Error))
                {
                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                }

                bReturn = false;
            }

            //if(string.IsNullOrEmpty(this.addressViewModel.City.Trim()))
            //{
            //    using(LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.
            //                                            frmMessage("Please enter city.", MessageBoxButtons.OK, MessageBoxIcon.Error))
            //    {
            //        LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
            //    }

            //    bReturn = false;
            //}
            //if(string.IsNullOrEmpty(this.addressViewModel.Country.Trim()))
            //{
            //    using(LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.
            //                                            frmMessage("Please enter country.", MessageBoxButtons.OK, MessageBoxIcon.Error))
            //    {
            //        LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
            //    }

            //    bReturn = false;
            //}

            if (string.IsNullOrEmpty(this.addressViewModel.SalesTaxGroup)) // added on 300318 req by U.Mustafi
            {
                using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.
                                                                      frmMessage("Please select a tax group.", MessageBoxButtons.OK, MessageBoxIcon.Error))
                {
                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                }

                bReturn = false;
            }

            if (txtMobilePrimary.Text.Trim().Length > 13 || txtMobilePrimary.Text.Trim().Length < 7) // added on 27/06/2014 req by S.Sharma
            {
                using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.
                                                                      frmMessage("Please enter a valid mobile no.", MessageBoxButtons.OK, MessageBoxIcon.Error))
                {
                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                    txtMobilePrimary.Focus();
                }

                bReturn = false;
            }
            if (string.IsNullOrEmpty(textNationality.Text.Trim()))
            {
                using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.
                                                                      frmMessage("Please select nationality.", MessageBoxButtons.OK, MessageBoxIcon.Error))
                {
                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                    textNationality.Focus();
                }

                bReturn = false;
            }
            //if(string.IsNullOrEmpty(txtCustClassificationGroup.Text.Trim()))
            //{
            //    using(LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.
            //                                            frmMessage("Please select customer classification group.", MessageBoxButtons.OK, MessageBoxIcon.Error))
            //    {
            //        LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
            //        txtCustClassificationGroup.Focus();
            //    }

            //    bReturn = false;
            //}

            if (string.IsNullOrEmpty(txtGender.Text.Trim()))
            {
                using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.
                                                                      frmMessage("Please select gender.", MessageBoxButtons.OK, MessageBoxIcon.Error))
                {
                    LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(dialog);
                    txtGender.Focus();
                }

                bReturn = false;
            }


            return(bReturn);
        }
        public decimal FindTenderRestriction(IRetailTransaction retailTransaction, ICardInfo cardInfo)
        {
            NetTracer.Information("TenderRestriction::FindTenderRestriction - Start");
            RetailTransaction transaction = retailTransaction as RetailTransaction;

            if (transaction == null)
            {
                throw new ArgumentNullException("retailTransaction");
            }

            if (cardInfo == null)
            {
                throw new ArgumentNullException("cardInfo");
            }

            decimal    payableAmount = 0; //the return value of total amount payd with tender id
            ItemStatus itemStatus;        //is the item included / excluded by the tender id

            // Check if there are items in the transaction
            if (transaction.SaleItems.Count == 0)
            {
                POSFormsManager.ShowPOSMessageDialog(50251); //"There are no sales items to check."
                return(payableAmount);
            }

            // Calclulating how much amount of the original amount can be paid.
            foreach (ISaleLineItem lineItem in transaction.SaleItems)
            {
                if (string.IsNullOrEmpty(lineItem.TenderRestrictionId) && (!lineItem.Voided))
                {
                    itemStatus = CheckTenderRestriction(cardInfo.RestrictionCode, cardInfo.TenderTypeId, lineItem.ItemId, lineItem.ItemGroupId);

                    if (itemStatus == ItemStatus.INCLUDE)
                    {
                        lineItem.TenderRestrictionId = cardInfo.RestrictionCode;
                        lineItem.FleetCardNumber     = cardInfo.CardNumber;
                        lineItem.PaymentIndex        = transaction.TenderLines.Count;
                        payableAmount += lineItem.NetAmountWithTax;
                    }
                }
            }

            if (payableAmount != retailTransaction.NetAmountWithTax)
            {
                // If nothing can be paid, then it can be concluded that this card is prohibited
                if (payableAmount == 0)
                {
                    using (LSRetailPosis.POSProcesses.frmMessage dialog = new LSRetailPosis.POSProcesses.frmMessage(50253))
                    {
                        this.Application.ApplicationFramework.POSShowForm(dialog);
                    }
                }
                else
                {
                    string message = string.Format(
                        LSRetailPosis.ApplicationLocalizer.Language.Translate(50151),
                        this.Application.Services.Rounding.Round(payableAmount, false));

                    using (frmTenderRestriction frmExcluded = new frmTenderRestriction(transaction))
                    {
                        frmExcluded.DisplayMsg = message;
                        this.Application.ApplicationFramework.POSShowForm(frmExcluded);

                        if (frmExcluded.DialogResult == DialogResult.No)
                        {
                            ClearTenderRestriction(retailTransaction);
                            return(0);
                        }
                    }
                }
            }

            NetTracer.Information("TenderRestriction::FindTenderRestriction - End");
            return(payableAmount);
        }
Ejemplo n.º 15
0
        private void PaySalesInvoice(IPosTransaction posTransaction)
        {
            try
            {
                DataTable salesInvoices = new DataTable();
                GetSalesInvoicesForCustomer(ref salesInvoices, posTransaction);

                if (salesInvoices.Rows.Count == 0)
                {
                    // There are no sales invoices in the database for this customer....
                    using (LSRetailPosis.POSProcesses.frmMessage messageDialog = new LSRetailPosis.POSProcesses.frmMessage(57001, MessageBoxButtons.OK, MessageBoxIcon.Exclamation))
                    {
                        this.Application.ApplicationFramework.POSShowForm(messageDialog);

                        return;
                    }
                }

                // Show the available sales invoices for selection...
                using (WinFormsTouch.frmGetSalesInvoice salesInvoicesDialog = new global::Microsoft.Dynamics.Retail.Pos.SalesInvoice.WinFormsTouch.frmGetSalesInvoice())
                {
                    salesInvoicesDialog.SalesInvoices = salesInvoices;
                    this.Application.ApplicationFramework.POSShowForm(salesInvoicesDialog);

                    RetailTransaction retailTransaction = posTransaction as RetailTransaction;

                    if (salesInvoicesDialog.SelectedSalesInvoiceId != null && retailTransaction != null)
                    {
                        // Check if this Sales Invoice has already been added to the transaction
                        foreach (ISaleLineItem salesInvoiceInTrans in retailTransaction.SaleItems)
                        {
                            if (salesInvoiceInTrans is SalesInvoiceLineItem)
                            {
                                if (!salesInvoiceInTrans.Voided)
                                {
                                    if (((SalesInvoiceLineItem)salesInvoiceInTrans).SalesInvoiceId == salesInvoicesDialog.SelectedSalesInvoiceId)
                                    {
                                        using (LSRetailPosis.POSProcesses.frmMessage msgDialog = new LSRetailPosis.POSProcesses.frmMessage(57003, MessageBoxButtons.OK, MessageBoxIcon.Error))  // This sales invoice has already been added to the transaction
                                        {
                                            this.Application.ApplicationFramework.POSShowForm(msgDialog);
                                            return;
                                        }
                                    }
                                }
                            }
                        }

                        // There is a valid sales invoice selected and it's not been already added to the transaction. So let's get the details for it...
                        SalesInvoiceLineItem salesInvoiceLineItem = (SalesInvoiceLineItem)this.Application.BusinessLogic.Utility.CreateSalesInvoiceLineItem(
                            ApplicationSettings.Terminal.StoreCurrency,
                            this.Application.Services.Rounding, retailTransaction);

                        GetSalesInvoice(posTransaction, ref salesInvoiceLineItem, salesInvoicesDialog.SelectedSalesInvoiceId);

                        // And add it to the transaction
                        retailTransaction.Add(salesInvoiceLineItem);
                        retailTransaction.SalesInvoiceAmounts += salesInvoiceLineItem.Amount;
                    }
                }
            }
            catch (PosisException px)
            {
                LSRetailPosis.ApplicationExceptionHandler.HandleException(this.ToString(), px);
                throw;
            }
            catch (Exception x)
            {
                LSRetailPosis.ApplicationExceptionHandler.HandleException(this.ToString(), x);
                throw;
            }
            finally
            {
                if (posTransaction is SalesInvoiceTransaction)
                {
                    ((SalesInvoiceTransaction)posTransaction).CalcTotals();
                }
            }
        }