Esempio n. 1
0
        public override void LabelKey(int labelKey)
        {
            System.Collections.Generic.List <IProduct> sList = new System.Collections.Generic.List <IProduct>();
            if (cr.DataConnector.CurrentSettings.GetProgramOption(Setting.DefineBarcodeLabelKeys) == PosConfiguration.ON)
            {
                sList = cr.DataConnector.SearchProductByBarcode(Label.GetLabel(labelKey));
            }
            else
            {
                sList = cr.DataConnector.SearchProductByLabel(Label.GetLabel(labelKey));
            }

            if (sList.Count == 0)
            {
                cr.State = AlertCashier.Instance(new Error(new ProductNotFoundException()));
                return;
            }

            // Check Printer Status before add label
            cr.Printer.CheckPrinterStatus();

            MenuList itemList = new MenuList();

            foreach (IProduct p in sList)
            {
                if (cr.Item is VoidItem)
                {
                    cr.Item = new SalesItem();
                }
                SalesItem si = (SalesItem)cr.Item.Clone();
                si.Product = p;
                if (p.Status == ProductStatus.Weighable && cr.Scale != null)
                {
                    try
                    {
                        si.Quantity = cr.Scale.GetWeight(p.UnitPrice);
                    }
                    catch (Exception) { }
                }
                itemList.Add(si);
            }

            if (itemList.Count == 1)
            {
                if (itemList.MoveNext())
                {
                    cr.Execute(((IDoubleEnumerator)itemList).Current);
                }
            }
            else
            {
                cr.State = ListLabel.Instance(itemList,
                                              new ProcessSelectedItem <IProduct>(cr.Execute),
                                              labelKey);
            }
        }
Esempio n. 2
0
        public override void LabelKey(int labelKey)
        {
            System.Collections.Generic.List <IProduct> sList = new System.Collections.Generic.List <IProduct>();
            if (cr.DataConnector.CurrentSettings.GetProgramOption(Setting.DefineBarcodeLabelKeys) == PosConfiguration.ON)
            {
                sList = cr.DataConnector.SearchProductByBarcode(Label.GetLabel(labelKey));
            }
            else
            {
                sList = cr.DataConnector.SearchProductByLabel(Label.GetLabel(labelKey));
            }

            if (sList.Count == 0)
            {
                cr.State = AlertCashier.Instance(new Error(new ProductNotFoundException()));
                return;
            }
            MenuList itemList = new MenuList();

            foreach (IProduct p in sList)
            {
                FiscalItem fi = (FiscalItem)cr.Item.Clone();
                fi.Product = p;
                itemList.Add(fi);
            }
            IDoubleEnumerator listEnumerator = (IDoubleEnumerator)itemList;

            if (itemList.Count == 1)
            {
                if (listEnumerator.MoveNext())
                {
                    cr.Execute(((FiscalItem)listEnumerator.Current).Product);
                }
            }
            else
            {
                cr.State = ListLabel.Instance(itemList,
                                              new ProcessSelectedItem <IProduct>(cr.Execute),
                                              labelKey);
            }
        }
Esempio n. 3
0
        //public static IState Instance(IDoubleEnumerator ide, ProcessSelectedItem<Product> psi, int labelKey, int autoEnterMillis)
        //{
        //    ListLabel.labelKey = labelKey;
        //    ProcessSelected = psi;
        //    autoEnterMillis = autoEnterMillis;
        //    List.Instance(ide);
        //    return state;
        //}

        public override void LabelKey(int labelKey)
        {
            if (labelKey == ListLabel.labelKey)
            {
                base.DownArrow();
            }
            else
            {
                System.Collections.Generic.List <IProduct> sList = new System.Collections.Generic.List <IProduct>();
                if (CashRegister.DataConnector.CurrentSettings.GetProgramOption(Setting.DefineBarcodeLabelKeys) == PosConfiguration.ON)
                {
                    sList = CashRegister.DataConnector.SearchProductByBarcode(Label.GetLabel(labelKey));
                }
                else
                {
                    sList = CashRegister.DataConnector.SearchProductByLabel(Label.GetLabel(labelKey));
                }

                MenuList itemList = new MenuList();
                foreach (IProduct p in sList)
                {
                    FiscalItem si = (FiscalItem)CashRegister.Item.Clone();
                    si.Product = p;
                    itemList.Add(si);
                }

                if (itemList.IsEmpty)
                {
                    CashRegister.State = AlertCashier.Instance(new Error(new ProductNotFoundException()));
                }
                else
                {
                    CashRegister.State = ListLabel.Instance(itemList, ProcessSelected, labelKey);
                }
            }
        }
Esempio n. 4
0
        //public override void BackSpace()
        //{
        //    input.RemoveLastDigit();
        //    DisplayAdapter.Cashier.BackSpace();
        //}
        public override void LabelKey(int labelKey)
        {
            //switch (label)
            //{
            //    case Label.BackSpace:
            //        input.RemoveLastDigit();
            //        DisplayAdapter.Cashier.BackSpace();
            //        break;
            //    case Label.Space:
            //        base.LabelKey(label);
            //        break;
            //    default:
            //        base.LabelKey(label);
            //        break;
            //}

            Quantity();
            if (input.ToDecimal() > 0)
            {
                return;
            }

            System.Collections.Generic.List <IProduct> sList = new System.Collections.Generic.List <IProduct>();
            if (cr.DataConnector.CurrentSettings.GetProgramOption(Setting.DefineBarcodeLabelKeys) == PosConfiguration.ON)
            {
                sList = cr.DataConnector.SearchProductByBarcode(Label.GetLabel(labelKey));
            }
            else
            {
                sList = cr.DataConnector.SearchProductByLabel(Label.GetLabel(labelKey));
            }

            MenuList itemList = new MenuList();

            Exception productEx = null;

            foreach (IProduct p in sList)
            {
                SalesItem si;
                try
                {
                    si = (SalesItem)cr.Item.Clone();
                }
                catch (InvalidCastException)
                {
                    throw new CmdSequenceException();
                }
                try
                {
                    si.Product = p;
                    Decimal la = si.ListedAmount;
                    itemList.Add(si);
                }
                catch (Exception ex)
                {
                    productEx = ex;
                }
            }

            if (itemList.IsEmpty)
            {
                if (productEx != null)
                {
                    throw productEx;
                }
                cr.State = AlertCashier.Instance(new Error(new ProductNotFoundException()));
                return;
            }


            if (sList.Count == 1 && itemList.Count == 1)
            {
                if (itemList.MoveNext())
                {
                    cr.Execute(((IDoubleEnumerator)itemList).Current);
                }
                // cr.State = States.Start.Instance();
            }
            else
            {
                //The below function passes enumerator to a list of
                //Sales items. Each sales item has properties of cr.CurrentItem as well
                //as the product whose id is held in the label configuration file
                //Second property tells the state to sell the item once it is selected
                cr.State = ListLabel.Instance(itemList,
                                              new ProcessSelectedItem <IProduct>(cr.Execute),
                                              labelKey);
            }
        }