Esempio n. 1
0
 public ActionResult Edit(MeiRongAcitivityConfig model)
 {
     if (model.Id != 0)
     {
         if (MeiRongAcitivityConfigManager.UpdateMeiRongAcitivityConfig(model))
         {
             CleanCache(model.ActivityId);
             CleanCahce();
             return(Json(true));
         }
         else
         {
             return(Json(false));
         }
     }
     else
     {
         int outId = 0;
         if (MeiRongAcitivityConfigManager.InsertMeiRongAcitivityConfig(model, ref outId))
         {
             CleanCahce();
             return(Json(true));
         }
         else
         {
             return(Json(false));
         }
     }
 }
Esempio n. 2
0
 public bool InsertMeiRongAcitivityConfig(MeiRongAcitivityConfig model, ref int id)
 {
     try
     {
         return(DALMeiRongAcitivityConfig.InsertMeiRongAcitivityConfig(model, ref id));
     }
     catch (Exception ex)
     {
         Logger.Log(Level.Error, ex, "InsertMeiRongAcitivityConfig");
         throw ex;
     }
 }
Esempio n. 3
0
 public bool UpdateMeiRongAcitivityConfig(MeiRongAcitivityConfig model)
 {
     try
     {
         return(DALMeiRongAcitivityConfig.UpdateMeiRongAcitivityConfig(model));
     }
     catch (Exception ex)
     {
         Logger.Log(Level.Error, ex, "UpdateMeiRongAcitivityConfig");
         throw ex;
     }
 }
Esempio n. 4
0
 public List <MeiRongAcitivityConfig> GetMeiRongAcitivityConfigList(MeiRongAcitivityConfig model, int pageSize, int pageIndex, out int recordCount)
 {
     try
     {
         return(DALMeiRongAcitivityConfig.GetMeiRongAcitivityConfig(model, pageSize, pageIndex, out recordCount));
     }
     catch (Exception ex)
     {
         Logger.Log(Level.Error, ex, "GetMeiRongAcitivityConfigList");
         throw ex;
     }
 }
Esempio n. 5
0
        public ActionResult List(MeiRongAcitivityConfig model, int pageIndex = 1, int pageSize = 15)
        {
            int    count  = 0;
            string strSql = string.Empty;

            var lists = MeiRongAcitivityConfigManager.GetMeiRongAcitivityConfigList(model, pageSize, pageIndex, out count);

            var list  = new OutData <List <MeiRongAcitivityConfig>, int>(lists, count);
            var pager = new PagerModel(pageIndex, pageSize)
            {
                TotalItem = count
            };

            return(View(new ListModel <MeiRongAcitivityConfig>(list.ReturnValue, pager)));
        }
Esempio n. 6
0
        public ActionResult Export(MeiRongAcitivityConfig model)
        {
            using (var stream = new MemoryStream(System.IO.File.ReadAllBytes(Server.MapPath(@"~/Content/Export/门店美容活动列表.xlsx"))))
            {
                int count        = 0;
                var list         = MeiRongAcitivityConfigManager.GetMeiRongAcitivityConfigList(model, int.MaxValue, 1, out count);
                var xssfWorkbook = new XSSFWorkbook(stream); //创建Workbook对象  2007+
                                                             // var hssfWorkbook = new HSSFWorkbook(stream)://2003
                if (list.Count > 0)
                {
                    var i     = 0;
                    var sheet = xssfWorkbook.GetSheetAt(0);

                    foreach (var item in list)
                    {
                        model.RegionList = MeiRongAcitivityConfigManager.GetRegionRelation(item.Id, 1);
                        string region = string.Empty;
                        if (model.RegionList != null && model.RegionList.Count > 0)
                        {
                            foreach (var regionItem in model.RegionList)
                            {
                                region += regionItem.ProvinceName + ":" + regionItem.CityName + ";";
                            }
                        }

                        var row = sheet.CreateRow((i++) + 1);
                        row.CreateCell(0).SetCellValue(item.Id);
                        row.CreateCell(1).SetCellValue(item.Name);
                        row.CreateCell(2).SetCellValue(region);
                        row.CreateCell(3).SetCellValue(item.CategoryName);
                        row.CreateCell(4).SetCellValue(item.MinShopQuantity);
                        row.CreateCell(5).SetCellValue(item.SignUpStartTime.Value.ToString() + "—" + item.SignUpEndTime.Value.ToString());
                        row.CreateCell(6).SetCellValue(item.PlanStartTime.ToString() + "—" + item.ActivityEndTime.ToString());
                        row.CreateCell(7).SetCellValue(item.MinPrice + "—" + item.MaxPrice);
                        row.CreateCell(8).SetCellValue(item.Status == 1 ? "启用" : "禁用");
                    }
                    Response.AppendHeader("Content-Disposition", "attachment;fileName=美容活动" + ".xlsx");
                    xssfWorkbook.Write(Response.OutputStream);
                    Response.End();
                }
            }
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Esempio n. 7
0
 public ActionResult Edit(int id = 0)
 {
     ViewBag.ProvinceList = MeiRongAcitivityConfigManager.GetRegion(0);
     ViewBag.ShopService  = MeiRongAcitivityConfigManager.GetShopCosmetologyServers(0);
     if (id == 0)
     {
         ViewBag.ZTreeJsonForCategory = SE_MDBeautyCategoryConfigController.SE_MDBeautyCategoryTreeJson("", true);
         MeiRongAcitivityConfig model = new MeiRongAcitivityConfig();
         model.PlanStartTime   = DateTime.Now;
         model.ActivityEndTime = DateTime.Now.AddDays(30);
         model.SignUpEndTime   = DateTime.Now.AddDays(30);
         model.SignUpStartTime = DateTime.Now;
         return(View(model));
     }
     else
     {
         MeiRongAcitivityConfig model = MeiRongAcitivityConfigManager.GetMeiRongAcitivityConfigById(id);
         model.RegionList             = MeiRongAcitivityConfigManager.GetRegionRelation(model.Id, 1);
         ViewBag.ZTreeJsonForCategory = SE_MDBeautyCategoryConfigController.SE_MDBeautyCategoryTreeJson(model.CategoryId.ToString(), true);
         return(View(model));
     }
 }
        public static bool UpdateMeiRongAcitivityConfig(MeiRongAcitivityConfig model)
        {
            const string sql          = @"UPDATE Tuhu_Groupon.dbo.ShopBeautyAcitivity SET                                      
                                         Name=@Name
                                        ,SignUpStartTime=@SignUpStartTime
                                        ,SignUpEndTime=@SignUpEndTime
                                        ,PlanStartTime=@PlanStartTime
                                        ,ActivityEndTime=@ActivityEndTime
                                        ,CategoryId=@CategoryId
                                                                           
                                        ,MinPrice=@MinPrice
                                        ,MaxPrice=@MaxPrice
                                        ,EverydayQuantity=@EverydayQuantity
                                        ,MinShopQuantity=@MinShopQuantity
                                        ,VehicleGrade=@VehicleGrade
                                        ,ApplicationVehicle=@ApplicationVehicle
                                        ,ShopType=@ShopType
                                        ,ShopGrade=@ShopGrade
                                        ,MeiRongAppraise=@MeiRongAppraise
                                        ,ActivityRequire=@ActivityRequire
                                        ,ActivityNotification=@ActivityNotification
	                                    ,Status=@Status
                                        ,UpdateTime=GETDATE()  
                                        ,UpdateName=@UpdateName                                                                 
                                 WHERE Id=@Id";
            var          sqlParameter = new SqlParameter[]
            {
                new SqlParameter("@ActivityEndTime", model.ActivityEndTime.Value),
                new SqlParameter("@ActivityNotification", model.ActivityNotification ?? string.Empty),
                new SqlParameter("@ActivityRequire", model.ActivityRequire ?? string.Empty),
                new SqlParameter("@PlanStartTime", model.PlanStartTime.Value),
                new SqlParameter("@CategoryId", model.CategoryId),
                new SqlParameter("@ApplicationVehicle", model.ApplicationVehicle),
                new SqlParameter("@CreateName", model.CreateName ?? string.Empty),
                new SqlParameter("@EverydayQuantity", model.EverydayQuantity),
                new SqlParameter("@MaxPrice", model.MaxPrice),
                new SqlParameter("@MeiRongAppraise", model.MeiRongAppraise),
                new SqlParameter("@MinPrice", model.MinPrice),
                new SqlParameter("@MinShopQuantity", model.MinShopQuantity),
                new SqlParameter("@Name", model.Name),

                new SqlParameter("@ShopGrade", model.ShopGrade),
                new SqlParameter("@ShopType", model.ShopType),
                new SqlParameter("@SignUpEndTime", model.SignUpEndTime.Value),
                new SqlParameter("@SignUpStartTime", model.SignUpStartTime.Value),
                new SqlParameter("@Status", model.Status),
                new SqlParameter("@UpdateName", model.UpdateName ?? string.Empty),
                new SqlParameter("@VehicleGrade", model.VehicleGrade),
                new SqlParameter("@Id", model.Id),
            };
            List <RegionRelation>      region  = JsonConvert.DeserializeObject <List <RegionRelation> >(model.Region);
            List <ShopServiceRelation> service = JsonConvert.DeserializeObject <List <ShopServiceRelation> >(model.ShopServices);

            string strConn          = ConfigurationManager.ConnectionStrings["Tuhu_Groupon"].ConnectionString;
            string connectionString = SecurityHelp.IsBase64Formatted(strConn) ? SecurityHelp.DecryptAES(strConn) : strConn;

            SqlConnection conn = new SqlConnection(connectionString);

            conn.Open();
            SqlTransaction tran = conn.BeginTransaction();

            try
            {
                SqlHelper.ExecuteNonQuery(tran, CommandType.Text, sql, sqlParameter);
                DeleteRegionRelation(model.Id, tran);
                DeleteShopServiceRelation(model.Id, tran);
                foreach (var item in region)
                {
                    item.Type       = 1;
                    item.ActivityId = model.Id;
                    InsertRegionRelation(item, tran);
                }
                foreach (var item in service)
                {
                    item.Type       = 1;
                    item.ActivityId = model.Id;
                    InsertShopServiceRelation(item, tran);
                }
                tran.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                return(false);

                throw ex;
            }
            finally
            {
                tran.Dispose();
            }
        }
        public static List <MeiRongAcitivityConfig> GetMeiRongAcitivityConfig(MeiRongAcitivityConfig model, int pageSize, int pageIndex, out int recordCount)
        {
            string sql      = @"SELECT  *
                            FROM    ( SELECT DISTINCT   A.[Id] ,
                                                [Name] ,
                                                [SignUpStartTime] ,
                                                [SignUpEndTime] ,
                                                [ActivityStartTime] ,
                                                [ActivityEndTime] ,
                                                [CategoryId] ,                                          
                                                [MinPrice] ,
                                                [MaxPrice] ,
                                                [EverydayQuantity] ,
                                                [MinShopQuantity] ,
                                                [VehicleGrade] ,
                                                [ApplicationVehicle] ,
                                                [ShopType] ,
                                                [ShopGrade] ,
                                                [MeiRongAppraise] ,
                                                [ActivityRequire] ,
                                                [ActivityNotification] ,
                                                [Status] ,
                                                A.[CreateTime] ,
                                                [UpdateTime] ,
                                                [CreateName] ,
                                                [UpdateName], CategoryName,ShowName,PlanStartTime
                                      FROM      [Tuhu_Groupon].[dbo].[ShopBeautyAcitivity] AS A WITH(NOLOCK)
                                                LEFT JOIN  Tuhu_Groupon.dbo.SE_MDBeautyCategoryConfig AS B WITH(NOLOCK)  ON B.Id = A.CategoryId 
                                                LEFT JOIN Tuhu_Groupon..RegionRelation AS C ON C.ActivityId = A.Id
		                              WHERE 
                                        ( @Id = 0
                                            OR ( @Id <> 0
                                                AND A.Id = @Id
                                                )
                                        )AND
                                        ( @Name = ''
                                            OR ( @Name <> ''
                                                AND Name = @Name
                                                )
                                        )AND                                       
                                        ( @CategoryId = -1
                                            OR ( @CategoryId <> -1
                                                AND CategoryId = @CategoryId
                                                )
                                        )AND                                  
                                        ( @Status = -1
                                            OR ( @Status <> -1
                                                AND Status = @Status
                                                )
                                        )
                                        AND                                  
                                        ( @CityId = -1
                                            OR ( @CityId <> -1
                                                AND C.CityId = @CityId
                                                )
                                        )
                                        AND                                  
                                        ( @ProvinceId = -1
                                            OR ( @ProvinceId <> -1
                                                AND  C.ProvinceId = @ProvinceId
                                                )
                                        )
                                    ) AS PG
                            ORDER BY PG.[UpdateTime] DESC
                                    OFFSET ( @PageIndex - 1 ) * @PageSize ROWS  FETCH NEXT @PageSize ROWS
                                    ONLY 
                                ";
            string sqlCount = @" SELECT COUNT(0)
                                 FROM   ( SELECT  DISTINCT
                                                    A.[Id] ,
                                                    COUNT(0) AS CountNum
                                          FROM      [Tuhu_Groupon].[dbo].[ShopBeautyAcitivity] AS A WITH ( NOLOCK )
                                                    LEFT JOIN Tuhu_Groupon.dbo.SE_MDBeautyCategoryConfig AS B
                                                    WITH ( NOLOCK ) ON B.Id = A.CategoryId
                                                    LEFT JOIN Tuhu_Groupon..RegionRelation AS C ON C.ActivityId = A.Id
                                          WHERE     ( @Id = 0
                                                      OR ( @Id <> 0
                                                           AND A.Id = @Id
                                                         )
                                                    )
                                                    AND ( @Name = ''
                                                          OR ( @Name <> ''
                                                               AND Name = @Name
                                                             )
                                                        )
                                                    AND ( @CategoryId = -1
                                                          OR ( @CategoryId <> -1
                                                               AND CategoryId = @CategoryId
                                                             )
                                                        )
                                                    AND ( @Status = -1
                                                          OR ( @Status <> -1
                                                               AND Status = @Status
                                                             )
                                                        )
                                                    AND ( @CityId = -1
                                                          OR ( @CityId <> -1
                                                               AND C.CityId = @CityId
                                                             )
                                                        )
                                                    AND ( @ProvinceId = -1
                                                          OR ( @ProvinceId <> -1
                                                               AND C.ProvinceId = @ProvinceId
                                                             )
                                                        )   GROUP BY A.Id
                                        ) AS CountNUN";

            var sqlParameters = new SqlParameter[]
            {
                new SqlParameter("@PageSize", pageSize),
                new SqlParameter("@PageIndex", pageIndex),
                new SqlParameter("@Id", model.Id),
                new SqlParameter("@Status", model.Status),
                new SqlParameter("@ProvinceId", model.StrProvince ?? "-1"),
                new SqlParameter("@CityId", model.StrCity ?? "-1"),
                new SqlParameter("@CategoryId", model.CategoryId),
                new SqlParameter("@Name", model.Name ?? string.Empty)
            };

            recordCount = (int)SqlHelper.ExecuteScalar(connOnRead, CommandType.Text, sqlCount, sqlParameters);
            return(SqlHelper.ExecuteDataTable(connOnRead, CommandType.Text, sql, sqlParameters).ConvertTo <MeiRongAcitivityConfig>().ToList());
        }
        public static bool InsertMeiRongAcitivityConfig(MeiRongAcitivityConfig model, ref int id)
        {
            const string sql = @"  INSERT INTO Tuhu_Groupon.dbo.[ShopBeautyAcitivity]
                                              (  
                                               [Name]
                                              ,[SignUpStartTime]
                                              ,[SignUpEndTime]
                                              ,[PlanStartTime]
                                              ,[ActivityEndTime]
                                              ,[CategoryId]
                                           
                                              ,[MinPrice]
                                              ,[MaxPrice]
                                              ,[EverydayQuantity]
                                              ,[MinShopQuantity]
                                              ,[VehicleGrade]
                                              ,[ApplicationVehicle]
                                              ,[ShopType]
                                              ,[ShopGrade]
                                              ,[MeiRongAppraise]
                                              ,[ActivityRequire]
                                              ,[ActivityNotification]
	                                          ,[Status]
                                              ,[CreateTime]
                                              ,[UpdateTime]
                                              ,[CreateName]
                                              ,[UpdateName]                                            
                                              ,[ActivityId]
                                              )
                                      VALUES  ( 
                                               @Name
                                              ,@SignUpStartTime
                                              ,@SignUpEndTime
                                              ,@PlanStartTime
                                              ,@ActivityEndTime
                                              ,@CategoryId
                                                                                    
                                              ,@MinPrice
                                              ,@MaxPrice
                                              ,@EverydayQuantity
                                              ,@MinShopQuantity
                                              ,@VehicleGrade
                                              ,@ApplicationVehicle
                                              ,@ShopType
                                              ,@ShopGrade
                                              ,@MeiRongAppraise
                                              ,@ActivityRequire
                                              ,@ActivityNotification
	                                          ,@Status
                                              ,GETDATE()
                                              ,GETDATE()
                                              ,@CreateName
                                              ,@UpdateName                                          
                                              ,NEWID()                                        
                                              )SELECT @@IDENTITY";

            var sqlParameter = new SqlParameter[]
            {
                new SqlParameter("@ActivityEndTime", model.ActivityEndTime.Value),
                new SqlParameter("@ActivityNotification", model.ActivityNotification ?? string.Empty),
                new SqlParameter("@ActivityRequire", model.ActivityRequire ?? string.Empty),
                new SqlParameter("@PlanStartTime", model.PlanStartTime.Value),
                new SqlParameter("@CategoryId", model.CategoryId),
                new SqlParameter("@ApplicationVehicle", model.ApplicationVehicle),
                new SqlParameter("@CreateName", model.CreateName ?? string.Empty),
                new SqlParameter("@EverydayQuantity", model.EverydayQuantity),
                new SqlParameter("@MaxPrice", model.MaxPrice),
                new SqlParameter("@MeiRongAppraise", model.MeiRongAppraise),
                new SqlParameter("@MinPrice", model.MinPrice),
                new SqlParameter("@MinShopQuantity", model.MinShopQuantity),
                new SqlParameter("@Name", model.Name),

                new SqlParameter("@ShopGrade", model.ShopGrade),
                new SqlParameter("@ShopType", model.ShopType),
                new SqlParameter("@SignUpEndTime", model.SignUpEndTime.Value),
                new SqlParameter("@SignUpStartTime", model.SignUpStartTime.Value),
                new SqlParameter("@Status", model.Status),
                new SqlParameter("@UpdateName", model.UpdateName ?? string.Empty),
                new SqlParameter("@VehicleGrade", model.VehicleGrade),
            };

            List <RegionRelation>      region  = JsonConvert.DeserializeObject <List <RegionRelation> >(model.Region);
            List <ShopServiceRelation> service = JsonConvert.DeserializeObject <List <ShopServiceRelation> >(model.ShopServices);

            string strConn          = ConfigurationManager.ConnectionStrings["Tuhu_Groupon"].ConnectionString;
            string connectionString = SecurityHelp.IsBase64Formatted(strConn) ? SecurityHelp.DecryptAES(strConn) : strConn;

            SqlConnection conn = new SqlConnection(connectionString);

            conn.Open();
            SqlTransaction tran = conn.BeginTransaction();

            try
            {
                id = Convert.ToInt32(SqlHelper.ExecuteScalar(tran, CommandType.Text, sql, sqlParameter));

                DeleteRegionRelation(model.Id, tran);
                DeleteShopServiceRelation(model.Id, tran);
                foreach (var item in region)
                {
                    item.Type       = 1;
                    item.ActivityId = id;
                    InsertRegionRelation(item, tran);
                }
                foreach (var item in service)
                {
                    item.Type       = 1;
                    item.ActivityId = id;
                    InsertShopServiceRelation(item, tran);
                }
                tran.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                return(false);

                throw ex;
            }
            finally
            {
                tran.Dispose();
            }
        }