Exemplo n.º 1
0
        /// <summary>
        /// Method to get propane pumps by grade Id
        /// </summary>
        /// <param name="gradeId">Grade Id</param>
        /// <param name="error">Error message</param>
        /// <returns>Propane pumps</returns>
        public List <PropanePump> GetPropanePumpsByGradeId(int gradeId, out ErrorMessage error)
        {
            var grades = CacheManager.GetPropaneGrades();
            var offSet = _policyManager.LoadStoreInfo().OffSet;

            if (grades == null)
            {
                error = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 38, 76, null)
                };
                return(null);
            }
            var firstOrdDefault = grades.FirstOrDefault(p => p.Id == gradeId);

            if (firstOrdDefault == null)
            {
                error = new ErrorMessage
                {
                    MessageStyle = new MessageStyle
                    {
                        Message     = "Invalid Request",
                        MessageType = MessageType.Critical
                    }
                };
                return(null);
            }

            var stockCode = firstOrdDefault.StockCode;

            var pumps = _fuelPumpService.GetPumpsByPropaneGradeId(gradeId);

            error = new ErrorMessage();
            if (pumps.Count == 0)
            {
                // "There's no Pump set for " & Stock_Code(index) & ". Please set it in Fuel Control at first.", vbinformation+vbokonly
                error = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 38, 12, stockCode, InformationOkMessageType)
                };
                return(null);
            }

            foreach (PropanePump propanePump in pumps)
            {
                propanePump.Name = _resourceManager.GetResString(offSet, (short)323) + " " + propanePump.Id;
            }
            return(pumps);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method to get volume value
        /// </summary>
        /// <param name="gradeId">Grade Id</param>
        /// <param name="pumpId">Pump Id</param>
        /// <param name="saleNumber">Sale number</param>
        /// <param name="tillNumber">Till number</param>
        /// <param name="registerNumber">Register number</param>
        /// <param name="propaneValue">Propane value</param>
        /// <param name="error">Error message</param>
        /// <returns>Volume value</returns>
        public string GetVolumeValue(int gradeId, int pumpId, int saleNumber, int tillNumber, byte registerNumber,
                                     decimal propaneValue, out ErrorMessage error)
        {
            string quantity = "";
            var    sale     = _saleManager.GetCurrentSale(saleNumber, tillNumber, registerNumber, UserCode, out error);
            var    offSet   = _policyManager.LoadStoreInfo().OffSet;

            if (!string.IsNullOrEmpty(error?.MessageStyle?.Message))
            {
                return(null);
            }

            var grades = CacheManager.GetPropaneGrades();

            if (grades == null)
            {
                error = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 38, 76, null)
                };
                return(null);
            }
            var firstOrdDefault = grades.FirstOrDefault(p => p.Id == gradeId);

            if (firstOrdDefault == null)
            {
                error = new ErrorMessage
                {
                    MessageStyle = new MessageStyle
                    {
                        Message     = "Invalid Request",
                        MessageType = MessageType.Critical
                    }
                };
                return(null);
            }
            var pumps = _fuelPumpService.GetPumpsByPropaneGradeId(gradeId);

            if (pumps == null || !pumps.Any(p => p.Id == pumpId))
            {
                error = new ErrorMessage
                {
                    MessageStyle = new MessageStyle
                    {
                        Message     = "Invalid Request",
                        MessageType = MessageType.Critical
                    }
                };
                return(null);
            }

            var stockCode = firstOrdDefault.StockCode;


            if (sale.DeletePrepay)
            {
                // "There's no Pump set for " & Stock_Code(index) & ". Please set it in Fuel Control at first.", vbinformation+vbokonly
                error = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 0, 1150, null, InformationOkMessageType)
                };
                return(null);
            }

            var slProp = new Sale_Line();

            _saleLineManager.SetPluCode(ref sale, ref slProp, stockCode, out error);
            slProp.GradeID = (byte)gradeId;
            if (slProp.Regular_Price == 0)
            {
                // "There's no price for " & Stock_Code(Index) & ". Please set it in BackOffice at first.", vbInformation + vbOKOnly
                //MsgBoxStyle temp_VbStyle = (int)MsgBoxStyle.Information + MsgBoxStyle.OkOnly;
                //Chaps_Main.DisplayMessage(this, (short)11, temp_VbStyle, Stock_Code[Index], (byte)0);
                error = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 48, 11, stockCode, InformationOkMessageType)
                };
                return(null);
            }

            if (slProp.Regular_Price > 0)
            {
                quantity = (Conversion.Val(propaneValue) / slProp.Regular_Price).ToString("#####0.000");
            }
            return(quantity);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Method to add propane sale
        /// </summary>
        /// <param name="gradeId">Grade Id</param>
        /// <param name="pumpId">Pump Id</param>
        /// <param name="saleNumber">Sale number</param>
        /// <param name="tillNumber">Till number</param>
        /// <param name="registerNumber">Register number</param>
        /// <param name="isAmount">Is amount</param>
        /// <param name="propaneValue">Propane value</param>
        /// <param name="error">Error message</param>
        /// <returns>Sale</returns>
        public Sale AddPropaneSale(int gradeId, int pumpId, int saleNumber, int tillNumber, byte registerNumber,
                                   bool isAmount, decimal propaneValue, out ErrorMessage error)
        {
            var sale   = _saleManager.GetCurrentSale(saleNumber, tillNumber, registerNumber, UserCode, out error);
            var offSet = _policyManager.LoadStoreInfo().OffSet;

            if (!string.IsNullOrEmpty(error?.MessageStyle?.Message))
            {
                return(null);
            }

            var grades = CacheManager.GetPropaneGrades();

            if (grades == null)
            {
                error = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 38, 76, null)
                };
                return(null);
            }
            var firstOrdDefault = grades.FirstOrDefault(p => p.Id == gradeId);

            if (firstOrdDefault == null)
            {
                error = new ErrorMessage
                {
                    MessageStyle = new MessageStyle
                    {
                        Message     = "Invalid Request",
                        MessageType = MessageType.Critical
                    }
                };
                return(null);
            }
            var pumps = _fuelPumpService.GetPumpsByPropaneGradeId(gradeId);

            if (pumps == null || !pumps.Any(p => p.Id == pumpId))
            {
                error = new ErrorMessage
                {
                    MessageStyle = new MessageStyle
                    {
                        Message     = "Invalid Request",
                        MessageType = MessageType.Critical
                    }
                };
                return(null);
            }

            var stockCode = firstOrdDefault.StockCode;


            if (sale.DeletePrepay)
            {
                // "There's no Pump set for " & Stock_Code(index) & ". Please set it in Fuel Control at first.", vbinformation+vbokonly
                error = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 0, 1150, null, InformationOkMessageType)
                };
                return(null);
            }

            var slProp = new Sale_Line();

            _saleLineManager.SetPluCode(ref sale, ref slProp, stockCode, out error);
            slProp.GradeID = (byte)gradeId;
            if (slProp.Regular_Price == 0)
            {
                // "There's no price for " & Stock_Code(Index) & ". Please set it in BackOffice at first.", vbInformation + vbOKOnly
                //MsgBoxStyle temp_VbStyle = (int)MsgBoxStyle.Information + MsgBoxStyle.OkOnly;
                //Chaps_Main.DisplayMessage(this, (short)11, temp_VbStyle, Stock_Code[Index], (byte)0);
                error = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 48, 11, stockCode, InformationOkMessageType)
                };
                return(null);
            }

            slProp.pumpID     = (byte)pumpId;
            slProp.PositionID = (byte)_fuelPumpService.GetPositionId(pumpId, gradeId);

            SetQuantity(ref slProp, isAmount, propaneValue, out error);

            if (!string.IsNullOrEmpty(error?.MessageStyle?.Message))
            {
                return(null);
            }

            if (_policyManager.USE_CUST)
            {
                if (_policyManager.USE_LOYALTY && Strings.UCase(System.Convert.ToString(_policyManager.LOYAL_TYPE)) == "PRICES" && sale.Customer.Loyalty_Code.Length > 0 && sale.Customer.CL_Status == "A" && (!slProp.LOY_EXCLUDE))
                {
                    var loyalPricecode = System.Convert.ToInt16(_policyManager.LOYAL_PRICE);
                    if (loyalPricecode > 0)
                    {
                        _saleLineManager.SetPriceNumber(ref slProp, loyalPricecode);
                    }
                    else
                    {
                        _saleLineManager.SetPriceNumber(ref slProp, sale.Customer.Price_Code != 0 ? sale.Customer.Price_Code : (short)1);
                    }
                }
                else
                {
                    _saleLineManager.SetPriceNumber(ref slProp, sale.Customer.Price_Code != 0 ? sale.Customer.Price_Code : (short)1);
                }
            }
            else
            {
                //SL_Prop.Price_Number = (short)1;
                _saleLineManager.SetPriceNumber(ref slProp, (short)1);
            }
            _saleManager.Add_a_Line(ref sale, slProp, UserCode, sale.TillNumber, out error, true);

            CacheManager.AddCurrentSaleForTill(tillNumber, saleNumber, sale);
            return(sale);
        }