protected override void LoadEmpty()
 {
     Title       = "קנה וקבל";
     BuyProduct  = null;
     BuyAmount   = 1;
     GetProduct  = null;
     GetAmount   = 1;
     GetDiscount = new DiscountM(0, DiscountTypes.Fix_Price);
 }
示例#2
0
        protected override void LoadEmpty()
        {
            Title           = "מוצר מוזל";
            SelectedProduct = null;
            Discount        = new DiscountM(10, DiscountTypes.Fix_Discount);

            IsDiscountPerAmount = false;
            AmountDiscounted    = 1;
            IsAmountLimited     = false;
            LimitedAmount       = 1;

            IsGiftAvailable = false;
            Gifted          = null;
        }
示例#3
0
        public SalesGroupM LoadGroup(int groupID)
        {
            ActivityLogService.Logger.LogFunctionCall(groupID);
            DataTable dt;
            var       sales = new List <SaleM>();

            try
            {
                CheckIsRemote();
                OpenConnection();

                string sql = "select * from Sales where SaleGroupID = @GroupID order by GroupIndex";
                _cmd = new SqlCommand(sql, _conn);
                _cmd.Parameters.Add(new SqlParameter("@GroupID", SqlDbType.Int)).Value = groupID;

                var salesTable = new DataTable();
                var da         = new SqlDataAdapter(_cmd);
                da.Fill(salesTable);

                foreach (DataRow Rs in salesTable.Rows)
                {
                    //  Load Sale:
                    var saleId = int.Parse(Rs["SaleID"].ToString());

                    //get requires product from PluReqSale (ProdAmount)
                    //get discounted products from PluOutSale (DiscountedProduct)
                    //get Sale's attributes
                    _cmd            = new SqlCommand();
                    _cmd.Connection = _conn;
                    _cmd.Parameters.Add(new SqlParameter("@saleID", SqlDbType.Int)).Value = saleId;

                    //Requires
                    var reqs = new List <ProdAmountM>();
                    _cmd.CommandText = "select * from PluReqSale where SaleID = @saleID";
                    da = new SqlDataAdapter(_cmd);
                    dt = new DataTable();
                    da.Fill(dt);
                    foreach (DataRow Rq in dt.Rows)
                    {
                        reqs.Add(new ProdAmountM(Rq["pluID"].ToString(),
                                                 bool.Parse(Rq["isPluno"].ToString()), double.Parse(Rq["qty"].ToString())));
                    }

                    //Discounted
                    var outs = new List <DiscountedProductM>();
                    _cmd.CommandText = "select * from PluOutSale where SaleID = @saleID";
                    da = new SqlDataAdapter(_cmd);
                    dt = new DataTable();
                    da.Fill(dt);
                    foreach (DataRow Ro in dt.Rows)
                    {
                        var outID  = int.Parse(Ro["OutID"].ToString());
                        var gifted = new List <GiftedProductM>();

                        sql  = "select * from PluGiftedSale where OutID = @outID";
                        _cmd = new SqlCommand(sql, _conn);
                        _cmd.Parameters.Add("@outID", SqlDbType.Int).Value = outID;
                        da = new SqlDataAdapter(_cmd);
                        var tempDt = new DataTable();
                        da.Fill(tempDt);
                        foreach (DataRow Rg in tempDt.Rows)
                        {
                            gifted.Add(new GiftedProductM(Rg["pluID"].ToString(),
                                                          bool.Parse(Rg["isPluno"].ToString()), double.Parse(Rg["MultiUnits"].ToString()),
                                                          new DiscountM(double.Parse(Rg["offPrice"].ToString()),
                                                                        (DiscountTypes)int.Parse(Rg["offType"].ToString()))));
                        }

                        outs.Add(new DiscountedProductM(Ro["pluID"].ToString(), bool.Parse(Ro["isPluno"].ToString()),
                                                        double.Parse(Ro["MultiUnits"].ToString()), double.Parse(Ro["MaxRec"].ToString()),
                                                        new DiscountM(double.Parse(Ro["offPrice"].ToString()),
                                                                      (DiscountTypes)int.Parse(Ro["offType"].ToString())), gifted, outID));
                    }
                    //Attributes
                    var prop = new SalesPropertiesM(
                        double.Parse(Rs["MinTotalPrice"].ToString()), Rs["MaxTotalPrice"] as double?,
                        int.Parse(Rs["AllowMultiple"].ToString()), int.Parse(Rs["Recurrences"].ToString()));
                    var disc = new DiscountM(double.Parse(Rs["TotalOffPrice"].ToString()),
                                             (DiscountTypes)int.Parse(Rs["TotalOffType"].ToString()));

                    sales.Add(new SaleM(Rs["Title"].ToString(), (SaleTypes)int.Parse(Rs["SaleType"].ToString()), prop, reqs, outs,
                                        disc, int.Parse(Rs["GroupIndex"].ToString()), saleId));
                }

                sql  = "select g.*, e.ename, e.uid from SalesGroup as g inner join emp as e on g.empno = e.empno where g.GroupID= @groupID";
                _cmd = new SqlCommand(sql, _conn);
                _cmd.Parameters.Add(new SqlParameter("@groupID", SqlDbType.Int)).Value = groupID;
                da = new SqlDataAdapter(_cmd);
                dt = new DataTable();
                da.Fill(dt);
                if (dt.Rows.Count == 0)
                {
                    throw new InvalidConstraintException("No sale record found for the given GroupID(" + groupID + ").");
                }
                else if (dt.Rows.Count != 1)
                {
                    throw new InvalidConstraintException("More than one instance of sale record found for the given GroupID(" + groupID + ").");
                }
                DataRow Att = dt.Rows[0];

                var emp = new UserData(int.Parse(Att["empno"].ToString()), Att["ename"].ToString(), Att["uid"].ToString());
                return(new SalesGroupM(int.Parse(Att["GroupID"].ToString()), emp,
                                       DateTime.Parse(Att["DateCreated"].ToString()),
                                       bool.Parse(Att["isEnabled"].ToString()), sales));
            }
            catch (Exception ex)
            {
                ActivityLogService.Logger.LogError(ex);
                return(null);
            }
            finally
            {
                CloseConnection();
            }
        }
示例#4
0
 protected override void LoadEmpty()
 {
     Title           = "מוצר מוזל";
     SelectedProduct = null;
     Discount        = new DiscountM(15, DiscountTypes.Percentage);
 }