コード例 #1
0
        public static void UpdateFlashSalesProduct(SqlConnection connection, FlashSalesProduct flashSalesProduct)
        {
            var sqlParamters = new[]
            {
                new SqlParameter("@PKID", flashSalesProduct.PKID),
                new SqlParameter("@PID", flashSalesProduct.PID),
                new SqlParameter("@Position", flashSalesProduct.Position),
                new SqlParameter("@PromotionPrice", flashSalesProduct.PromotionPrice),
                new SqlParameter("@MarketPrice", flashSalesProduct.MarketPrice),
                new SqlParameter("@PromotionNum", flashSalesProduct.PromotionNum),
                new SqlParameter("@MaxNum", flashSalesProduct.MaxNum),
                new SqlParameter("@NumLeft", flashSalesProduct.NumLeft),
                new SqlParameter("@ProductID", flashSalesProduct.FlashSalesProductPara.ProductID),
                new SqlParameter("@VariantID", flashSalesProduct.FlashSalesProductPara.VariantID),
                new SqlParameter("@DisplayName", flashSalesProduct.FlashSalesProductPara.DisplayName),
                new SqlParameter("@CP_Vehicle", flashSalesProduct.FlashSalesProductPara.CP_Vehicle),
                new SqlParameter("@Price", flashSalesProduct.FlashSalesProductPara.Price),
                new SqlParameter("@Description", flashSalesProduct.FlashSalesProductPara.Description),
                new SqlParameter("@DefinitionName", flashSalesProduct.FlashSalesProductPara.DefinitionName),
                new SqlParameter("@Image_filename", flashSalesProduct.FlashSalesProductPara.Image_filename),
                new SqlParameter("@Image_filename_2", flashSalesProduct.FlashSalesProductPara.Image_filename_2),
                new SqlParameter("@Image_filename_3", flashSalesProduct.FlashSalesProductPara.Image_filename_3),
                new SqlParameter("@Image_filename_4", flashSalesProduct.FlashSalesProductPara.Image_filename_4),
                new SqlParameter("@Image_filename_5", flashSalesProduct.FlashSalesProductPara.Image_filename_5),
                new SqlParameter("@Variant_Image_filename_1", flashSalesProduct.FlashSalesProductPara.Variant_Image_filename_1),
                new SqlParameter("@Variant_Image_filename_2", flashSalesProduct.FlashSalesProductPara.Variant_Image_filename_2),
                new SqlParameter("@Variant_Image_filename_3", flashSalesProduct.FlashSalesProductPara.Variant_Image_filename_3),
                new SqlParameter("@Variant_Image_filename_4", flashSalesProduct.FlashSalesProductPara.Variant_Image_filename_4)
            };

            SqlHelper.ExecuteNonQuery(connection, CommandType.Text, @"UPDATE Marketing.dbo.tbl_FlashSalesProduct SET PID=@PID,Position=@Position,PromotionPrice=@PromotionPrice,MarketPrice=@MarketPrice,PromotionNum=@PromotionNum,MaxNum=@MaxNum,NumLeft=@NumLeft,
ProductID=@ProductID,VariantID=@VariantID,DisplayName=@DisplayName,CP_Vehicle=@CP_Vehicle,Price=@Price,Description=@Description,Image_filename=@Image_filename,Image_filename_2=@Image_filename_2,Image_filename_3=@Image_filename_3,Image_filename_4=@Image_filename_4,
Image_filename_5=@Image_filename_5,Variant_Image_filename_1=@Variant_Image_filename_1,Variant_Image_filename_2=@Variant_Image_filename_2,Variant_Image_filename_3=@Variant_Image_filename_3,Variant_Image_filename_4=@Variant_Image_filename_4
WHERE PKID=@PKID", sqlParamters);
        }
コード例 #2
0
        public static void AddFlashSalesProduct(SqlConnection connection, FlashSalesProduct flashSalesProduct)
        {
            var sqlParamters = new[]
            {
                new SqlParameter("@PKID", flashSalesProduct.PKID),
                new SqlParameter("@FlashSalesID", flashSalesProduct.FlashSalesID),
                new SqlParameter("@PID", flashSalesProduct.PID),
                new SqlParameter("@Position", flashSalesProduct.Position),
                new SqlParameter("@PromotionPrice", flashSalesProduct.PromotionPrice),
                new SqlParameter("@MarketPrice", flashSalesProduct.MarketPrice),
                new SqlParameter("@PromotionNum", flashSalesProduct.PromotionNum),
                new SqlParameter("@MaxNum", flashSalesProduct.MaxNum),
                new SqlParameter("@NumLeft", flashSalesProduct.NumLeft),
                new SqlParameter("@Status", flashSalesProduct.Status),
                new SqlParameter("@IsHotSale", flashSalesProduct.IsHotSale),
                new SqlParameter("@ProductID", flashSalesProduct.FlashSalesProductPara.ProductID),
                new SqlParameter("@VariantID", flashSalesProduct.FlashSalesProductPara.VariantID),
                new SqlParameter("@DisplayName", flashSalesProduct.FlashSalesProductPara.DisplayName),
                new SqlParameter("@CP_Vehicle", flashSalesProduct.FlashSalesProductPara.CP_Vehicle),
                new SqlParameter("@Price", flashSalesProduct.FlashSalesProductPara.Price),
                new SqlParameter("@Description", flashSalesProduct.FlashSalesProductPara.Description),
                new SqlParameter("@DefinitionName", flashSalesProduct.FlashSalesProductPara.DefinitionName),
                new SqlParameter("@Image_filename", flashSalesProduct.FlashSalesProductPara.Image_filename),
                new SqlParameter("@Image_filename_2", flashSalesProduct.FlashSalesProductPara.Image_filename_2),
                new SqlParameter("@Image_filename_3", flashSalesProduct.FlashSalesProductPara.Image_filename_3),
                new SqlParameter("@Image_filename_4", flashSalesProduct.FlashSalesProductPara.Image_filename_4),
                new SqlParameter("@Image_filename_5", flashSalesProduct.FlashSalesProductPara.Image_filename_5),
                new SqlParameter("@Variant_Image_filename_1", flashSalesProduct.FlashSalesProductPara.Variant_Image_filename_1),
                new SqlParameter("@Variant_Image_filename_2", flashSalesProduct.FlashSalesProductPara.Variant_Image_filename_2),
                new SqlParameter("@Variant_Image_filename_3", flashSalesProduct.FlashSalesProductPara.Variant_Image_filename_3),
                new SqlParameter("@Variant_Image_filename_4", flashSalesProduct.FlashSalesProductPara.Variant_Image_filename_4)
            };

            SqlHelper.ExecuteNonQuery(connection, CommandType.Text,
                                      @"insert into Marketing.dbo.tbl_FlashSalesProduct(FlashSalesID,PID,Position,PromotionPrice,MarketPrice,PromotionNum,MaxNum,NumLeft,Status,IsHotSale,
ProductID,VariantID,DisplayName,CP_Vehicle,Price,Description,DefinitionName,Image_filename,Image_filename_2,Image_filename_3,Image_filename_4,Image_filename_5,Variant_Image_filename_1,Variant_Image_filename_2,Variant_Image_filename_3,Variant_Image_filename_4) values
                 (@FlashSalesID,@PID,@Position,@PromotionPrice,@MarketPrice,@PromotionNum,@MaxNum,@NumLeft,@Status,@IsHotSale,
@ProductID,@VariantID,@DisplayName,@CP_Vehicle,@Price,@Description,@DefinitionName,@Image_filename,@Image_filename_2,@Image_filename_3,@Image_filename_4,@Image_filename_5,@Variant_Image_filename_1,@Variant_Image_filename_2,@Variant_Image_filename_3,@Variant_Image_filename_4)"
                                      , sqlParamters);
        }
コード例 #3
0
 public void AddFlashSalesProduct(FlashSalesProduct flashSalesProduct)
 {
     handler.AddFlashSalesProduct(flashSalesProduct);
 }
コード例 #4
0
 public void UpdateFlashSalesProduct(FlashSalesProduct flashSalesProduct)
 {
     handler.UpdateFlashSalesProduct(flashSalesProduct);
 }
コード例 #5
0
        public void AddFlashSalesProduct(FlashSalesProduct flashSalesProduct)
        {
            Action <SqlConnection> action = (connection) => DalFlashSales.AddFlashSalesProduct(connection, flashSalesProduct);

            dbManager.Execute(action);
        }
コード例 #6
0
 public ActionResult AllOperate(string opstr, int?Cate)
 {
     try
     {
         if (string.IsNullOrEmpty(opstr) || !Cate.HasValue)
         {
             return(Json(new { IsSuccess = false, ReturnStr = "输入的参数不能为空" }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             string[] _Oparr = opstr.Split('*');
             foreach (string Paras in _Oparr)
             {
                 try
                 {
                     if (!string.IsNullOrEmpty(Paras))
                     {
                         string[] _Para = Paras.Split(',');
                         if (_Para.Length == 8)
                         {
                             int     _PKID           = int.Parse(_Para[0]);
                             string  _PID            = _Para[1];
                             byte    _Position       = byte.Parse(_Para[2]);
                             decimal _PromotionPrice = decimal.Parse(_Para[3]);
                             decimal _MarketPrice    = decimal.Parse(_Para[4]);
                             int     _PromotionNum   = int.Parse(_Para[5]);
                             int     _MaxNum         = int.Parse(_Para[6]);
                             int     _NumLeft        = int.Parse(_Para[7]);
                             if (!string.IsNullOrEmpty(_PID))
                             {
                                 //删除
                                 if (Cate == 1)
                                 {
                                     manager.DeleteFlashSalesProduct(_PKID);
                                 }
                                 //保存
                                 else if (Cate == 2)
                                 {
                                     FlashSalesProduct _FlashSalesProduct = new FlashSalesProduct
                                     {
                                         PKID                  = _PKID,
                                         PID                   = _PID,
                                         Position              = _Position,
                                         PromotionPrice        = _PromotionPrice,
                                         MarketPrice           = _MarketPrice,
                                         PromotionNum          = _PromotionNum,
                                         MaxNum                = _MaxNum,
                                         NumLeft               = _NumLeft,
                                         FlashSalesProductPara = _PImanager.GetFlashSalesProductParaByPID(_PID)
                                     };
                                     manager.UpdateFlashSalesProduct(_FlashSalesProduct);
                                 }
                             }
                         }
                     }
                 }
                 catch { }
             }
         }
         return(Json(new { IsSuccess = true, ReturnStr = Cate.Value == 1 ? "批量删除成功" : "批量保存成功" }, JsonRequestBehavior.AllowGet));
     }
     catch
     {
         return(Json(new { IsSuccess = false, ReturnStr = "保存失败" }, JsonRequestBehavior.AllowGet));
     }
 }
コード例 #7
0
 public ActionResult OperateProduct(int?FlashSalesID, int?PKID, string PID, byte?Position, byte?Status, int?Cate, decimal?PromotionPrice, int?PromotionNum, decimal?MarketPrice, int?MaxNum, int?NumLeft, bool?IsHotSale)
 {
     try
     {
         if (!FlashSalesID.HasValue || !Cate.HasValue)
         {
             return(Json("请确保活动编号和操作类型不为空", JsonRequestBehavior.AllowGet));
         }
         else
         {
             int _PKID = PKID.GetValueOrDefault(0);
             //删除产品
             if (Cate == 1)
             {
                 manager.DeleteFlashSalesProduct(_PKID);
             }
             //设置为已禁止
             else if (Cate == 2)
             {
                 manager.ChangeStatus(_PKID, Status.GetValueOrDefault(0));
             }
             //设置为已禁止
             else if (Cate == 5)
             {
                 manager.ChangeIsHotSale(_PKID, IsHotSale ?? false);
             }
             //保存产品
             else if (Cate == 3 || Cate == 4)
             {
                 int _FlashSalesID = FlashSalesID.GetValueOrDefault(0);
                 FlashSalesProduct _FlashSalesProduct = new FlashSalesProduct
                 {
                     PKID                  = _PKID,
                     FlashSalesID          = _FlashSalesID,
                     PID                   = PID,
                     Position              = Position.GetValueOrDefault(0),
                     Status                = Status.GetValueOrDefault(0),
                     PromotionPrice        = PromotionPrice.GetValueOrDefault(0),
                     PromotionNum          = PromotionNum.GetValueOrDefault(0),
                     MarketPrice           = MarketPrice.GetValueOrDefault(0),
                     MaxNum                = MaxNum.GetValueOrDefault(0),
                     NumLeft               = NumLeft.GetValueOrDefault(0),
                     FlashSalesProductPara = _PImanager.GetFlashSalesProductParaByPID(PID)
                 };
                 if (_FlashSalesProduct.FlashSalesProductPara != null)
                 {
                     if (Cate == 3)
                     {
                         //修改产品
                         manager.UpdateFlashSalesProduct(_FlashSalesProduct);
                     }
                     else
                     {
                         //新增产品
                         if (!Position.HasValue || !Status.HasValue)
                         {
                             return(Json("排序顺序和状态不能为空", JsonRequestBehavior.AllowGet));
                         }
                         else
                         {
                             manager.AddFlashSalesProduct(_FlashSalesProduct);
                         }
                     }
                 }
                 else
                 {
                     return(Json("该产品不存在,请重新选择", JsonRequestBehavior.AllowGet));
                 }
             }
             return(Json("OK", JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         return(Json("保存失败" + (Cate.HasValue && (Cate.Value == 3 || Cate.Value == 4) ? "请确认产品编号不要重复和顺序号为两位内整数" : "") + ex.Message.Replace("'", ""), JsonRequestBehavior.AllowGet));
     }
 }