Exemplo n.º 1
0
        public Models.PromotionResultDo GetPromotionList(Models.PromotionCriteriaDo criteria)
        {
            Models.PromotionResultDo result = new Models.PromotionResultDo();

            db.CreateCommand(new Utils.SQL.SQLCommandHandler((Utils.SQL.ASQLDbCommand command) =>
            {
                command.CommandText = "[dbo].[sp_Get_PromotionList]";
                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.AddParameter(typeof(string), "PromotionTemplateID", criteria.PromotionTemplateID);
                command.AddParameter(typeof(string), "PromotionNumber", criteria.PromotionNumber);
                command.AddParameter(typeof(decimal), "PromotionValue", criteria.PromotionValue);
                command.AddParameter(typeof(string), "BrandCode", criteria.BrandCode);
                command.AddParameter(typeof(DateTime), "CreateDateFrom", criteria.CreateDateFrom);
                command.AddParameter(typeof(DateTime), "CreateDateTo", criteria.CreateDateTo);
                command.AddParameter(typeof(DateTime), "StartDate", criteria.StartDate);
                command.AddParameter(typeof(DateTime), "EndDate", criteria.EndDate);
                command.AddParameter(typeof(DateTime), "PrintDateFrom", criteria.PrintDateFrom);
                command.AddParameter(typeof(DateTime), "PrintDateTo", criteria.PrintDateTo);
                command.AddParameter(typeof(DateTime), "UsedDateFrom", criteria.UsedDateFrom);
                command.AddParameter(typeof(DateTime), "UsedDateTo", criteria.UsedDateTo);
                command.AddParameter(typeof(bool), "IsUsed", criteria.IsUsed);
                command.AddParameter(typeof(bool), "IsExpired", criteria.IsExpired);
                command.AddParameter(typeof(bool), "IsVoid", criteria.IsVoid);
                command.AddParameter(typeof(bool), "IsActive", criteria.IsActive);
                command.AddParameter(typeof(DateTime), "CurrentDate", criteria.CurrentDate);

                Utils.SQL.ISQLDbParameter output   = command.AddSearchParameter(criteria);
                Utils.SQL.ISQLDbParameter ovoucher = command.AddOutputParameter(typeof(int), "TotalPromotion");

                result.Rows = command.ToList <Models.PromotionFSDo>();
                result.TotalRecordParameter(output);
            }));

            return(result);
        }
Exemplo n.º 2
0
        public Models.PromotionResultDo GetPromotionTemplateList(Models.PromotionCriteriaDo criteria)
        {
            Models.PromotionResultDo result = new Models.PromotionResultDo();

            db.CreateCommand(new Utils.SQL.SQLCommandHandler((Utils.SQL.ASQLDbCommand command) =>
            {
                command.CommandText = "[dbo].[sp_Get_PromotionTemplateList]";
                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.AddParameter(typeof(string), "PromotionName", criteria.PromotionName);
                command.AddParameter(typeof(string), "PromotionNumber", criteria.PromotionNumber);
                command.AddParameter(typeof(decimal), "PromotionValue", criteria.PromotionValue);
                command.AddParameter(typeof(string), "BrandCode", criteria.BrandCode);
                command.AddParameter(typeof(DateTime), "CreateDateFrom", criteria.CreateDateFrom);
                command.AddParameter(typeof(DateTime), "CreateDateTo", criteria.CreateDateTo);
                command.AddParameter(typeof(DateTime), "StartDate", criteria.StartDate);
                command.AddParameter(typeof(DateTime), "EndDate", criteria.EndDate);
                command.AddParameter(typeof(DateTime), "PrintDateFrom", criteria.PrintDateFrom);
                command.AddParameter(typeof(DateTime), "PrintDateTo", criteria.PrintDateTo);
                command.AddParameter(typeof(DateTime), "UsedDateFrom", criteria.UsedDateFrom);
                command.AddParameter(typeof(DateTime), "UsedDateTo", criteria.UsedDateTo);
                command.AddParameter(typeof(bool), "IsUsed", criteria.IsUsed);
                command.AddParameter(typeof(bool), "IsExpired", criteria.IsExpired);
                command.AddParameter(typeof(bool), "IsVoid", criteria.IsVoid);
                command.AddParameter(typeof(bool), "IsActive", criteria.IsActive);
                command.AddParameter(typeof(DateTime), "CurrentDate", criteria.CurrentDate);

                Utils.SQL.ISQLDbParameter output      = command.AddSearchParameter(criteria);
                Utils.SQL.ISQLDbParameter tpromotion  = command.AddOutputParameter(typeof(int), "TotalPromotion");
                Utils.SQL.ISQLDbParameter tfpromotion = command.AddOutputParameter(typeof(int), "TotalFilterPromotion");

                System.Collections.IList[] dbls = command.ToList(typeof(Models.PromotionFSDo), typeof(Models.PromotionBrandDo));
                if (dbls != null)
                {
                    List <Models.PromotionFSDo> voucher         = dbls[0] as List <Models.PromotionFSDo>;
                    List <Models.PromotionBrandDo> voucherbrand = dbls[1] as List <Models.PromotionBrandDo>;
                    if (voucher != null)
                    {
                        result.Rows = voucher;

                        if (voucherbrand != null)
                        {
                            foreach (Models.PromotionFSDo p in result.Rows)
                            {
                                p.Brands = voucherbrand.FindAll(x => x.PromotionTemplateID == p.PromotionTemplateID);
                            }
                        }
                        if (tpromotion != null)
                        {
                            result.TotalPromotion = (int)tpromotion.Value;
                        }
                        if (tfpromotion != null)
                        {
                            result.TotalFilterPromotion = (int)tfpromotion.Value;
                        }

                        result.TotalRecordParameter(output);
                    }
                }
            }));

            return(result);
        }