コード例 #1
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <SalesProductModel> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            List <SalesProductModel> modelList = new List <SalesProductModel>();
            int rowsCount = ds.Tables[0].Rows.Count;

            if (rowsCount > 0)
            {
                SalesProductModel model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new SalesProductModel();
                    if (ds.Tables[0].Rows[n]["ProductId"].ToString() != "")
                    {
                        model.ProductId = int.Parse(ds.Tables[0].Rows[n]["ProductId"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["SaleType"].ToString() != "")
                    {
                        model.SaleType = int.Parse(ds.Tables[0].Rows[n]["SaleType"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["SiteId"].ToString() != "")
                    {
                        model.SiteId = int.Parse(ds.Tables[0].Rows[n]["SiteId"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["timestamp"].ToString() != "")
                    {
                        model.TimeStamp = Convert.ToDateTime(ds.Tables[0].Rows[n]["timestamp"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
コード例 #2
0
        /// <summary>
        /// 添加广告促销商品
        /// </summary>
        /// <param name="model">广告促销商品对象</param>
        /// <returns></returns>
        /// <remarks>added by jimmy,2015-7-8</remarks>
        public ResultModel Add(SalesProductModel model)
        {
            var result  = new ResultModel();
            var prodcut = _database.Db.ProductRule.Find(_database.Db.ProductRule.ProductId == model.productId && _database.Db.ProductRule.SalesRuleId == 2);

            if (prodcut == null)
            {
                result.IsValid  = false;
                result.Messages = new List <string>()
                {
                    "The promotion is not there, please fill in the number of other promotional items"
                };                                                                                                                          //该促销商品不存在,请填写别的促销商品编号
            }
            else
            {
                if (_database.Db.SalesProduct.Find(_database.Db.SalesProduct.ProductId == model.productId) != null)
                {
                    result.IsValid  = false;
                    result.Messages = new List <string>()
                    {
                        "The promotion product already exists, can not repeat the addition!"
                    };                                                                                                            //该促销商品已经存在,不能重复添加!
                }
                else
                {
                    result.Data = _database.Db.SalesProduct.Insert(model);
                }
            };
            return(result);
        }
コード例 #3
0
        //------------------------------
        public Task <string> Update(SalesProductModel aModel)
        {
            try
            {
                string msg = "";
                // const string query = @"INSERT INTO SalesProductList (ProductCategory,ProductID,ProductName,Unit,UnitPrice,RackName,RowNumber,StoreName,ReminderStock) VALUES(@ProductCategory,@ProductID,@ProductName,@Unit,@UnitPrice,@RackName,@RowNumber,@StoreName,@ReminderStock) ";
                const string query = @"UPDATE SalesProductList SET ProductCategoryId=@ProductCategoryId,ProductName=@ProductName,Unit=@Unit,UnitPrice=@UnitPrice,RackId=@RackId,RowId=@RowId,StoreId=@StoreId,ReminderStock=@ReminderStock,SubSubPNOId=@SubSubPNOId WHERE IdNo=@IdNo";

                Con.Open();
                var cmd = new SqlCommand(query, Con);
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@IdNo", aModel.IdNo);
                cmd.Parameters.AddWithValue("@ProductCategoryId", aModel.ProductCategoryId);
                cmd.Parameters.AddWithValue("@ProductID", aModel.ProductID);
                cmd.Parameters.AddWithValue("@ProductName", aModel.ProductName);
                cmd.Parameters.AddWithValue("@Unit", aModel.Unit);
                cmd.Parameters.AddWithValue("@UnitPrice", aModel.UnitPrice);
                cmd.Parameters.AddWithValue("@RackId", aModel.RackId);
                cmd.Parameters.AddWithValue("@RowId", aModel.RowId);
                cmd.Parameters.AddWithValue("@StoreId", aModel.StoreId);
                cmd.Parameters.AddWithValue("@ReminderStock", aModel.ReminderStock);
                cmd.Parameters.AddWithValue("@SubSubPNOId", aModel.SubSubPNOId);
                cmd.ExecuteNonQuery();
                Con.Close();
                return(Task.FromResult("Update successful"));
            }
            catch (Exception exception)
            {
                if (Con.State == ConnectionState.Open)
                {
                    Con.Close();
                }
                return(Task.FromResult(exception.Message));
            }
        }
コード例 #4
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public SalesProductModel ReaderBind(IDataReader dataReader)
        {
            SalesProductModel model = new SalesProductModel();
            object            ojb;

            ojb = dataReader["ProductId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ProductId = (int)ojb;
            }
            ojb = dataReader["SaleType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.SaleType = (int)ojb;
            }
            ojb = dataReader["SiteId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.SiteId = (int)ojb;
            }
            ojb = dataReader["timestamp"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.TimeStamp = Convert.ToDateTime(ojb);
            }
            return(model);
        }
コード例 #5
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(SalesProductModel model)
        {
            DbCommand dbCommand = dbw.GetStoredProcCommand("UP_pdSalesProduct_Update");

            dbw.AddInParameter(dbCommand, "ProductId", DbType.Int32, model.ProductId);
            dbw.AddInParameter(dbCommand, "SaleType", DbType.Byte, model.SaleType);
            dbw.AddInParameter(dbCommand, "SiteId", DbType.Int32, model.SiteId);
            dbw.ExecuteNonQuery(dbCommand);
        }
コード例 #6
0
        public bool AddProduct(SalesProductModel data)
        {
            ProductDBModel datas = new ProductDBModel();

            datas.GetConnectionString(connection.server(),
                                      connection.database(), connection.username(), connection.password()); //1

            return(datas.AddProduct(data));
        }
コード例 #7
0
 public ActionResult Create(SalesProductModel model)
 {
     if (ModelState.IsValid)
     {
         var userName    = UserInfo.CurrentUserName;
         var resultModel = new ResultModel();
         if (model.SalesProductId != 0)
         {
             model.UpdateBy = userName;
             model.UpdateDT = DateTime.Now;
             var resultUp = _salesProductService.Update(model);
             if (resultUp.IsValid)
             {
                 resultModel.IsValid  = true;
                 resultModel.Messages = new List <string> {
                     "Change promotion item success"
                 };
             }
             else
             {
                 resultModel.IsValid  = false;
                 resultModel.Messages = new List <string> {
                     resultUp.Messages[0]
                 };
             }
             var opera = string.Format("修改广告促销商品参数:SalesProductId={0},操作结果:{1}", model.SalesProductId, resultModel.IsValid ? "成功" : "失败");
             LogPackage.InserAC_OperateLog(opera, "广告管理--首页促销商品");
         }
         else
         {
             model.SalesProductId = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
             model.CreateBy       = userName;
             model.CreateDT       = DateTime.Now;
             model.UpdateBy       = userName;
             model.UpdateDT       = DateTime.Now;
             model.Sorts          = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
             var result = _salesProductService.Add(model);
             if (result.IsValid)
             {
                 resultModel.IsValid  = true;
                 resultModel.Messages = new List <string> {
                     "Add promotion item success"
                 };
             }
             else
             {
                 resultModel.IsValid  = false;
                 resultModel.Messages = new List <string> {
                     result.Messages[0]
                 };
             }
         }
         return(Json(resultModel, JsonRequestBehavior.AllowGet));
     }
     return(PartialView(model));
 }
コード例 #8
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public void Add(SalesProductModel model)
        {
            DbCommand dbCommand = dbw.GetStoredProcCommand("UP_pdSalesProduct_ADD");

            dbw.AddInParameter(dbCommand, "ProductId", DbType.Int32, model.ProductId);
            dbw.AddInParameter(dbCommand, "SaleType", DbType.Byte, model.SaleType);
            dbw.AddInParameter(dbCommand, "SiteId", DbType.Int32, model.SiteId);
            dbw.AddInParameter(dbCommand, "timestamp", DbType.DateTime, model.TimeStamp);
            dbw.ExecuteNonQuery(dbCommand);
        }
コード例 #9
0
        public async Task <HttpResponseMessage> Save_SalesProduct([FromBody] SalesProductModel aModel)
        {
            var formate = RequestFormat.JsonFormaterString();

            try
            {
                if (string.IsNullOrEmpty(aModel.ProductName))
                {
                    return(Request.CreateResponse(HttpStatusCode.OK,
                                                  new Confirmation {
                        Output = "error", Msg = "Name is Null"
                    }));
                }
                else
                {
                    if (_gt.FncSeekRecordNew("PartyInfo", "Id=" + aModel.IdNo + "") == false)
                    {
                        if (_gt.FncSeekRecordNew("PartyInfo", "Name='" + aModel.ProductName + "'") == true)
                        {
                            return(Request.CreateResponse(HttpStatusCode.OK,
                                                          new Confirmation {
                                Output = "error", Msg = "Name Already Exist"
                            }, formate));
                        }
                        else
                        {
                            string msg = await _gt.Save(aModel);

                            return(Request.CreateResponse(HttpStatusCode.OK,
                                                          new Confirmation {
                                Output = "success", Msg = msg
                            }, formate));
                        }
                    }

                    else
                    {
                        string msg = await _gt.Update(aModel);

                        return(Request.CreateResponse(HttpStatusCode.OK,
                                                      new Confirmation {
                            Output = "success", Msg = msg
                        }, formate));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.OK,
                                              new Confirmation {
                    Output = "error",
                }, formate));
            }
        }
コード例 #10
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SalesProductModel GetModel(int ProductId, int SaleType, int SiteId)
        {
            DbCommand dbCommand = dbr.GetStoredProcCommand("UP_pdSalesProduct_GetModel");

            dbr.AddInParameter(dbCommand, "ProductId", DbType.Int32, ProductId);
            dbr.AddInParameter(dbCommand, "SaleType", DbType.Byte, SaleType);
            dbr.AddInParameter(dbCommand, "SiteId", DbType.Int32, SiteId);

            SalesProductModel model = null;

            using (IDataReader dataReader = dbr.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
コード例 #11
0
        /// <summary>
        /// 更新广告促销商品
        /// </summary>
        /// <param name="model">广告促销商品对象</param>
        /// <returns>返回true时,表示更新成功;反之,表示更新失败</returns>
        /// <remarks>added by jimmy,2015-7-8</remarks>
        public ResultModel Update(SalesProductModel model)
        {
            var result  = new ResultModel();
            var prodcut = _database.Db.ProductRule.FindByProductId(model.productId);
            var sp      = _database.Db.SalesProduct;

            if (prodcut == null)
            {
                result.IsValid  = false;
                result.Messages = new List <string>()
                {
                    "The promotion is not there, please fill in the number of other promotional items"
                };                                                                                                                          //该促销商品不存在,请填写别的促销商品编号
            }
            else
            {
                result.Data = sp.UpdateBySalesProductId(SalesProductId: model.SalesProductId, productId: model.productId, PlaceCode: model.PlaceCode, IdentityStatus: model.IdentityStatus,
                                                        PicAddress: model.PicAddress, UpdateBy: model.UpdateBy, UpdateDT: model.UpdateDT);
            };
            return(result);
        }
コード例 #12
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ProductController controller = new ProductController();

            SalesProductModel model = new SalesProductModel();
            ProductDBModel    db    = new ProductDBModel();

            model.Name         = txtProductName.Text;
            model.Serialnumber = Convert.ToInt32(txtSerialnumber.Text);
            model.Quantity     = Convert.ToInt32(txtQuantity.Text);
            model.Unitprice    = Convert.ToInt32(txtPricePerUnit.Text);
            model.Description  = txtDescription.Text;
            model.DateImport   = dtpDateImport.Text;

            //true mean visible, have to use another
            if (db.CheckVisibleName(model.Name))
            {
                MessageBox.Show("Name visible");
            }
            else
            {
                if (db.CheckVisibleSerialnumber(model.Serialnumber.ToString()))
                {
                    MessageBox.Show("Serialnumber visible");
                }
                else
                {
                    if (controller.AddProduct(model))
                    {
                        MessageBox.Show("insert successful");
                    }
                    else
                    {
                        MessageBox.Show("insert invalide");
                    }
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// 加载数据
        /// </summary>
        /// <param name="id">对象系统Id</param>
        /// <returns></returns>
        public ActionResult Create(long?id)
        {
            SalesProductModel model = null;

            if (id.HasValue)
            {
                List <SalesProductModel> result = _salesProductService.GetSalesProductById(id.Value).Data;

                if (result != null && result.Count > 0)
                {
                    model           = result[0];
                    ViewBag.ImgUrl  = model.PicAddress;
                    ViewBag.ShowImg = imagePath + model.PicAddress;

                    //获取商品的信息
                    AddProductModel _addProductModel = _productService.GetSKU_ProductById(model.productId, ACultureHelper.GetLanguageID).Data;
                    if (_addProductModel != null)
                    {
                        model.HKPrice           = ToolUtil.Round(_addProductModel.HKPrice, 2);
                        model.ProductName       = _addProductModel.ProductName;
                        model.SalePrice         = ToolUtil.Round(model.HKPrice * model.Discount, 2);
                        model.SKU_ProductModels = _addProductModel.SKU_ProductModels;
                    }
                }
            }
            else
            {
                model       = new SalesProductModel();
                model.Sorts = 1;
            }
            // DrowList(model);



            return(PartialView(model));
        }
コード例 #14
0
        //------------------------------
        public Task <string> Save(SalesProductModel aModel)
        {
            try
            {
                string msg = "";

                int    pid = Convert.ToInt32(GetMaxId("SalesProductList", "ProductID"));
                string str = Convert.ToString(pid);

                const string query = @"INSERT INTO SalesProductList (ProductCategoryId,ProductID,ProductName,Unit,UnitPrice,RackId,RowId,StoreId,ReminderStock,SubSubPNOId) VALUES(@ProductCategoryId,@ProductID,@ProductName,@Unit,@UnitPrice,@RackId,@RowId,@StoreId,@ReminderStock,@SubSubPNOId) ";
                Con.Open();
                var cmd = new SqlCommand(query, Con);
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@ProductCategoryId", aModel.ProductCategoryId);
                cmd.Parameters.AddWithValue("@ProductID", aModel.ProductID);
                cmd.Parameters.AddWithValue("@ProductName", aModel.ProductName);
                cmd.Parameters.AddWithValue("@Unit", aModel.Unit);
                cmd.Parameters.AddWithValue("@UnitPrice", aModel.UnitPrice);
                cmd.Parameters.AddWithValue("@RackId", aModel.RackId);
                cmd.Parameters.AddWithValue("@RowId", aModel.RowId);
                cmd.Parameters.AddWithValue("@StoreId", aModel.StoreId);
                cmd.Parameters.AddWithValue("@ReminderStock", aModel.ReminderStock);
                cmd.Parameters.AddWithValue("@SubSubPNOId", aModel.SubSubPNOId);
                cmd.ExecuteNonQuery();
                Con.Close();
                return(Task.FromResult("Save successful"));
            }
            catch (Exception exception)
            {
                if (Con.State == ConnectionState.Open)
                {
                    Con.Close();
                }
                return(Task.FromResult(exception.Message));
            }
        }
コード例 #15
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(SalesProductModel model)
 {
     dal.Add(model);
 }
コード例 #16
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(SalesProductModel model)
 {
     dal.Update(model);
 }
コード例 #17
0
 public static SalesProduct ToEntity(this SalesProductModel model)
 {
     return(Mapper.Map <SalesProduct>(model));
 }