Beispiel #1
0
        public Models.UpdatePromotionResultDo CreatePromotionTemplate(Models.PromotionDo entity)
        {
            Models.UpdatePromotionResultDo result = new Models.UpdatePromotionResultDo();

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

                command.AddParameter(typeof(string), "NameLC", entity.PromotionName);
                command.AddParameter(typeof(string), "NameEN", entity.PromotionName);
                command.AddParameter(typeof(string), "PromotionType", entity.PromotionType);
                command.AddParameter(typeof(int), "Qty", entity.Qty);
                command.AddParameter(typeof(bool), "FlagActivate", entity.FlagActivate);

                command.AddParameter(typeof(DateTime), "StartDate", entity.StartDate);
                command.AddParameter(typeof(DateTime), "EndDate", entity.EndDate);

                string brandXml = Utils.ConvertUtil.ConvertToXml_Store <Models.PromotionBrandDo>(entity.Brands);
                command.AddParameter(typeof(string), "BrandXML", brandXml);
                command.AddParameter(typeof(string), "DiscountFor", entity.DiscountFor);
                command.AddParameter(typeof(string), "DiscountType", entity.DiscountType);
                command.AddParameter(typeof(decimal), "CashValue", entity.CashValue);

                command.AddParameter(typeof(DateTime), "CreateDate", entity.CreateDate);
                command.AddParameter(typeof(string), "CreateUser", entity.CreateUser);

                result.Promotion = command.ToList <Models.PromotionDo>()[0];
            }));

            return(result);
        }
Beispiel #2
0
        public Models.PromotionDo GetPromotionTemplate(Models.PromotionCriteriaDo criteria)
        {
            Models.PromotionDo result = null;

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

                command.AddParameter(typeof(int), "PromotionTemplateID", criteria.PromotionTemplateID);

                System.Collections.IList[] dbls = command.ToList(
                    typeof(Models.PromotionDo), typeof(Models.PromotionBrandDo));
                if (dbls != null)
                {
                    List <Models.PromotionDo> dbvs       = dbls[0] as List <Models.PromotionDo>;
                    List <Models.PromotionBrandDo> dbvbs = dbls[1] as List <Models.PromotionBrandDo>;
                    if (dbvs != null)
                    {
                        if (dbvs.Count > 0)
                        {
                            result        = dbvs[0];
                            result.Brands = dbvbs;
                        }
                    }
                }
            }));

            return(result);
        }
Beispiel #3
0
        public Models.PromotionDo UpdatePromotionTemplate(Models.PromotionDo entity)
        {
            Models.PromotionDo result = null;

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

                command.AddParameter(typeof(int), "PromotionTemplateID", entity.PromotionTemplateID);
                command.AddParameter(typeof(string), "NameLC", entity.NameLC);
                command.AddParameter(typeof(string), "NameEN", entity.NameLC);
                command.AddParameter(typeof(string), "PromotionType", entity.PromotionType);
                command.AddParameter(typeof(int), "Qty", entity.Qty);
                command.AddParameter(typeof(DateTime), "StartDate", entity.StartDate);
                command.AddParameter(typeof(DateTime), "EndDate", entity.EndDate);
                command.AddParameter(typeof(bool), "FlagActivate", entity.FlagActivate);

                string brandXml = Utils.ConvertUtil.ConvertToXml_Store <Models.PromotionBrandDo>(entity.Brands);
                command.AddParameter(typeof(string), "BrandXML", brandXml);
                command.AddParameter(typeof(string), "DiscountFor", entity.DiscountFor);
                command.AddParameter(typeof(string), "DiscountType", entity.DiscountType);
                command.AddParameter(typeof(decimal), "CashValue", entity.CashValue);



                command.AddParameter(typeof(DateTime), "UpdateDate", entity.UpdateDate);
                command.AddParameter(typeof(string), "UpdateUser", entity.UpdateUser);

                System.Collections.IList[] dbls = command.ToList(
                    typeof(Models.PromotionDo), typeof(Models.PromotionBrandDo));
                if (dbls != null)
                {
                    List <Models.PromotionDo> dbps       = dbls[0] as List <Models.PromotionDo>;
                    List <Models.PromotionBrandDo> dbvbs = dbls[1] as List <Models.PromotionBrandDo>;
                    if (dbps != null)
                    {
                        if (dbps.Count > 0)
                        {
                            result        = dbps[0];
                            result.Brands = dbvbs;
                        }
                    }
                }
            }));

            return(result);
        }
Beispiel #4
0
        public void UpdateStatusPromotion(Models.PromotionDo entity)
        {
            db.CreateCommand(new Utils.SQL.SQLCommandHandler((Utils.SQL.ASQLDbCommand command) =>
            {
                command.CommandText = "[dbo].[sp_Update_Status_Promotion]";
                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.AddParameter(typeof(int), "PromotionTemplateID", entity.PromotionTemplateID);
                string promotionXml = Utils.ConvertUtil.ConvertToXml_Store <Models.PromotionAtivateDo>(entity.Promotions);
                command.AddParameter(typeof(string), "PromotionXML", promotionXml);
                command.AddParameter(typeof(string), "TypeStatus", entity.TypeStatus);

                command.AddParameter(typeof(DateTime), "UpdateDate", entity.UpdateDate);
                command.AddParameter(typeof(string), "UpdateUser", entity.UpdateUser);

                command.ExecuteScalar();
            }));
        }
Beispiel #5
0
        public void GeneratePromotion(Models.PromotionDo entity)
        {
            db.CreateCommand(new Utils.SQL.SQLCommandHandler((Utils.SQL.ASQLDbCommand command) =>
            {
                command.CommandText = "[dbo].[sp_Generate_Promotion]";
                command.CommandType = System.Data.CommandType.StoredProcedure;

                command.AddParameter(typeof(int), "PromotionTemplateID", entity.PromotionTemplateID);
                command.AddParameter(typeof(string), "PromotionType", entity.PromotionType);
                command.AddParameter(typeof(int), "Qty", entity.Qty);
                command.AddParameter(typeof(DateTime), "StartDate", entity.StartDate);
                command.AddParameter(typeof(DateTime), "EndDate", entity.EndDate);
                command.AddParameter(typeof(bool), "FlagActivate", entity.FlagActivate);

                command.AddParameter(typeof(DateTime), "CreateDate", entity.CreateDate);
                command.AddParameter(typeof(string), "CreateUser", entity.CreateUser);

                command.ExecuteScalar();
            }));
        }