예제 #1
0
        /// <summary>
        /// 添加物品
        /// </summary>
        /// <param name="userFromCookie"></param>
        /// <param name="context"></param>
        private void AddGoods(DriveMgr.Model.User userFromCookie, HttpContext context)
        {
            if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("goods", "add", userFromCookie.Id))
            {
                string ui_goods_GoodsName_add     = context.Request.Params["ui_goods_GoodsName_add"] ?? "";
                int    ui_goods_GoodsCategory_add = Int32.Parse(context.Request.Params["ui_goods_GoodsCategory_add"]);
                int    ui_goods_MinQuantity_add   = Int32.Parse(context.Request.Params["ui_goods_MinQuantity_add"]);
                int    ui_goods_MaxQuantity_add   = Int32.Parse(context.Request.Params["ui_goods_MaxQuantity_add"]);
                int    ui_goods_RealQuantity_add  = Int32.Parse(context.Request.Params["ui_goods_RealQuantity_add"]);
                string ui_goods_Specification_add = context.Request.Params["ui_goods_Specification_add"] ?? "";
                string ui_goods_Remark_add        = context.Request.Params["ui_goods_Remark_add"] ?? "";

                DriveMgr.Model.GoodsModel goodsAdd = new Model.GoodsModel();
                goodsAdd.GoodsName       = ui_goods_GoodsName_add.Trim();
                goodsAdd.GoodsCategoryID = ui_goods_GoodsCategory_add;
                goodsAdd.MinQuantity     = ui_goods_MinQuantity_add;
                goodsAdd.MaxQuantity     = ui_goods_MaxQuantity_add;
                goodsAdd.RealQuantity    = ui_goods_RealQuantity_add;
                goodsAdd.Specification   = ui_goods_Specification_add.Trim();
                goodsAdd.Remark          = ui_goods_Remark_add.Trim();

                goodsAdd.CreateDate   = DateTime.Now;
                goodsAdd.CreatePerson = userFromCookie.UserId;
                goodsAdd.UpdatePerson = userFromCookie.UserId;
                goodsAdd.UpdateDate   = DateTime.Now;

                if (!goodsBll.IsExistGoods(goodsAdd.GoodsName))
                {
                    if (goodsBll.AddGoods(goodsAdd))
                    {
                        userOperateLog.OperateInfo = "添加物品";
                        userOperateLog.IfSuccess   = true;
                        userOperateLog.Description = "添加成功,物品:" + ui_goods_GoodsName_add.Trim();
                        context.Response.Write("{\"msg\":\"添加成功!\",\"success\":true}");
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "添加物品";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "添加失败";
                        context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                    }
                }
                else
                {
                    context.Response.Write("{\"msg\":\"该物品已经存在!\",\"success\":true}");
                }
            }
            else
            {
                userOperateLog.OperateInfo = "添加物品";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = "无权限,请联系管理员";
                context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
            }
            DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
        }