public static bool UpdateVehicleMountedCouponConfig(VehicleMountedCouponConfig model)
        {
            const string sql          = @"UPDATE Configuration.dbo.SE_VehicleMountedCouponConfig SET                                      
                                        Channel=@Channel
                                        ,Versions=@Versions
                                        ,Region=@Region
                                        ,Status=@Status
                                        ,Images=@Images
                                        ,Coupons=@Coupons
                                        ,UpdateTime=GETDATE()
                                        ,UpdateName=@UpdateName 
                                        ,Location=@Location
                                        ,Name=@Name
                                        ,CouponQuantity=@CouponQuantity
                                        ,Type=@Type                                                                 
                                 WHERE Id=@Id";
            var          sqlParameter = new SqlParameter[]
            {
                new SqlParameter("@Channel", model.Channel ?? string.Empty),
                new SqlParameter("@Coupons", model.Coupons ?? string.Empty),
                new SqlParameter("@Images", model.Images ?? string.Empty),
                new SqlParameter("@Region", model.Region ?? string.Empty),
                new SqlParameter("@Versions", model.Versions ?? string.Empty),
                new SqlParameter("@Status", model.Status),
                new SqlParameter("@Id", model.Id),
                new SqlParameter("@UpdateName", model.UpdateName ?? string.Empty),
                new SqlParameter("@Location", model.Location),
                new SqlParameter("@Name", model.Name),
                new SqlParameter("@CouponQuantity", model.CouponQuantity),
                new SqlParameter("@Type", model.Type)
            };

            return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, sqlParameter) > 0);
        }
        public static bool InsertVehicleMountedCouponConfig(VehicleMountedCouponConfig model, ref int id)
        {
            const string sql = @"  INSERT INTO Configuration.dbo.[SE_VehicleMountedCouponConfig]
                                              (                                               
                                               [Channel]
                                              ,[Versions]
                                              ,[Region]
                                              ,[Status]
                                              ,[Images]
                                              ,[Coupons]
                                              ,[CreateTime]
                                              ,[UpdateTime]
                                              ,[CreateName]
                                              ,[UpdateName]
                                              ,[ActivityId]
                                              ,[Location]
                                              ,[Name]
                                              ,[CouponQuantity]
                                              ,[Type]
                                              )
                                      VALUES  (                                          
                                               @Channel
                                              ,@Versions
                                              ,@Region
                                              ,@Status
                                              ,@Images
                                              ,@Coupons
                                              ,GETDATE()
                                              ,GETDATE() 
                                              ,@CreateName
                                              ,@UpdateName  
                                              ,NEWID()
                                              ,@Location
                                              ,@Name
                                              ,@CouponQuantity 
                                              ,@Type                              
                                              )SELECT @@IDENTITY";

            var sqlParameter = new SqlParameter[]
            {
                new SqlParameter("@Channel", model.Channel ?? string.Empty),
                new SqlParameter("@Coupons", model.Coupons ?? string.Empty),
                new SqlParameter("@Images", model.Images ?? string.Empty),
                new SqlParameter("@Region", model.Region ?? string.Empty),
                new SqlParameter("@Versions", model.Versions ?? string.Empty),
                new SqlParameter("@Status", model.Status),
                new SqlParameter("@CreateName", model.CreateName ?? string.Empty),
                new SqlParameter("@UpdateName", model.UpdateName ?? string.Empty),
                new SqlParameter("@Location", model.Location),
                new SqlParameter("@Name", model.Name),
                new SqlParameter("@CouponQuantity", model.CouponQuantity),
                new SqlParameter("@Type", model.Type)
            };

            id = Convert.ToInt32(SqlHelper.ExecuteScalar(conn, CommandType.Text, sql, sqlParameter));
            return(id > 0);
        }
Ejemplo n.º 3
0
 public bool InsertVehicleMountedCouponConfig(VehicleMountedCouponConfig model, ref int id)
 {
     try
     {
         return(DALVehicleMountedCouponConfig.InsertVehicleMountedCouponConfig(model, ref id));
     }
     catch (Exception ex)
     {
         Logger.Log(Level.Error, ex, "InsertVehicleMountedCouponConfig");
         throw ex;
     }
 }
Ejemplo n.º 4
0
 public bool UpdateVehicleMountedCouponConfig(VehicleMountedCouponConfig model)
 {
     try
     {
         return(DALVehicleMountedCouponConfig.UpdateVehicleMountedCouponConfig(model));
     }
     catch (Exception ex)
     {
         Logger.Log(Level.Error, ex, "UpdateVehicleMountedCouponConfig");
         throw ex;
     }
 }
Ejemplo n.º 5
0
 public List <VehicleMountedCouponConfig> GetVehicleMountedCouponConfigList(VehicleMountedCouponConfig model, int pageSize, int pageIndex, out int recordCount)
 {
     try
     {
         return(DALVehicleMountedCouponConfig.GetVehicleMountedCouponConfig(model, pageSize, pageIndex, out recordCount));
     }
     catch (Exception ex)
     {
         Logger.Log(Level.Error, ex, "GetVehicleMountedCouponConfigList");
         throw ex;
     }
 }
 public ActionResult Edit(VehicleMountedCouponConfig model)
 {
     if (model.Id != 0)
     {
         model.UpdateName = User.Identity.Name;
         return(Json(VehicleMountedCouponConfigManager.UpdateVehicleMountedCouponConfig(model)));
     }
     else
     {
         model.CreateName = User.Identity.Name;
         model.UpdateName = User.Identity.Name;
         int outId = 0;
         return(Json(VehicleMountedCouponConfigManager.InsertVehicleMountedCouponConfig(model, ref outId)));
     }
 }
        public ActionResult List(VehicleMountedCouponConfig model, int pageIndex = 1, int pageSize = 15)
        {
            int    count  = 0;
            string strSql = string.Empty;

            var lists = VehicleMountedCouponConfigManager.GetVehicleMountedCouponConfigList(model, pageSize, pageIndex, out count);

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

            return(View(new ListModel <VehicleMountedCouponConfig>(list.ReturnValue, pager)));
        }
        public ActionResult Edit(int id = 0)
        {
            ViewBag.ProvinceList = MeiRongAcitivityConfigManager.GetRegion(0);

            if (id == 0)
            {
                VehicleMountedCouponConfig model = new VehicleMountedCouponConfig();
                model.CreateTime = DateTime.Now;
                model.UpdateTime = DateTime.Now;
                model.Region     = "[{'ProvinceName':'','CityName':''}]";
                model.Status     = true;
                return(View(model));
            }
            else
            {
                VehicleMountedCouponConfig model = VehicleMountedCouponConfigManager.GetVehicleMountedCouponConfigById(id);
                model.RegionList = JsonConvert.DeserializeObject <List <RegionModel> >(model.Region);
                return(View(model));
            }
        }
        public static List <VehicleMountedCouponConfig> GetVehicleMountedCouponConfig(VehicleMountedCouponConfig model, int pageSize, int pageIndex, out int recordCount)
        {
            string sql      = @"SELECT  *
                            FROM    ( SELECT   [Id]
                                              ,[Channel]
                                              ,[Versions]
                                              ,[Region]
                                              ,[Status]
                                              ,[Images]
                                              ,[Coupons]
                                              ,[CreateTime]
                                              ,[UpdateTime]
                                              ,[ActivityId]
                                              ,[Location]
                                              ,[Name]
                                              ,[CouponQuantity]
                                              ,[Type]
                                      FROM    [Configuration].[dbo].[SE_VehicleMountedCouponConfig]                                      
		                              WHERE 1=1                                       
                                    ) AS PG
                            ORDER BY PG.[UpdateTime] DESC
                                    OFFSET ( @PageIndex - 1 ) * @PageSize ROWS  FETCH NEXT @PageSize ROWS
                                    ONLY 
                                ";
            string sqlCount = @"SELECT Count(0)
                                FROM    [Configuration].[dbo].[SE_VehicleMountedCouponConfig] AS A WITH (NOLOCK) 
                             ";

            var sqlParameters = new SqlParameter[]
            {
                new SqlParameter("@PageSize", pageSize),
                new SqlParameter("@PageIndex", pageIndex),
            };

            recordCount = (int)SqlHelper.ExecuteScalar(connOnRead, CommandType.Text, sqlCount, sqlParameters);
            return(SqlHelper.ExecuteDataTable(connOnRead, CommandType.Text, sql, sqlParameters).ConvertTo <VehicleMountedCouponConfig>().ToList());
        }