Exemplo n.º 1
0
        /// <summary>
        /// 编辑物品
        /// </summary>
        /// <param name="userFromCookie"></param>
        /// <param name="context"></param>
        private void EditGoods(DriveMgr.Model.User userFromCookie, HttpContext context)
        {
            if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("goods", "edit", userFromCookie.Id))
            {
                int id = Convert.ToInt32(context.Request.Params["id"]);
                DriveMgr.Model.GoodsModel goodsEdit = goodsBll.GetGoodsModel(id);
                string ui_goods_GoodsName_edit      = context.Request.Params["ui_goods_GoodsName_edit"] ?? "";
                int    ui_goods_GoodsCategory_edit  = Int32.Parse(context.Request.Params["ui_goods_GoodsCategory_edit"]);
                int    ui_goods_MinQuantity_edit    = Int32.Parse(context.Request.Params["ui_goods_MinQuantity_edit"]);
                int    ui_goods_MaxQuantity_edit    = Int32.Parse(context.Request.Params["ui_goods_MaxQuantity_edit"]);
                int    ui_goods_RealQuantity_edit   = Int32.Parse(context.Request.Params["ui_goods_RealQuantity_edit"]);
                string ui_goods_Specification_edit  = context.Request.Params["ui_goods_Specification_edit"] ?? "";
                string ui_goods_Remark_edit         = context.Request.Params["ui_goods_Remark_edit"] ?? "";

                goodsEdit.GoodsName       = ui_goods_GoodsName_edit.Trim();
                goodsEdit.GoodsCategoryID = ui_goods_GoodsCategory_edit;
                goodsEdit.MinQuantity     = ui_goods_MinQuantity_edit;
                goodsEdit.MaxQuantity     = ui_goods_MaxQuantity_edit;
                goodsEdit.RealQuantity    = ui_goods_RealQuantity_edit;
                goodsEdit.Specification   = ui_goods_Specification_edit.Trim();
                goodsEdit.Remark          = ui_goods_Remark_edit.Trim();

                goodsEdit.UpdatePerson = userFromCookie.UserId;
                goodsEdit.UpdateDate   = DateTime.Now;

                if (goodsBll.UpdateGoods(goodsEdit))
                {
                    userOperateLog.OperateInfo = "修改物品";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "修改成功,物品主键:" + goodsEdit.Id;
                    context.Response.Write("{\"msg\":\"修改成功!\",\"success\":true}");
                }
                else
                {
                    userOperateLog.OperateInfo = "修改物品";
                    userOperateLog.IfSuccess   = false;
                    userOperateLog.Description = "修改失败";
                    context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                }
            }
            else
            {
                userOperateLog.OperateInfo = "修改物品";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = "无权限,请联系管理员";
                context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
            }
            DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
        }
        private void AddEnterStoreHouseDetails(DriveMgr.Model.User userFromCookie, HttpContext context)
        {
            GoodsBLL           goodsBll           = new GoodsBLL();
            EnterStoreHouseBLL enterStoreHouseBLL = new EnterStoreHouseBLL();

            string enterDetail = "[" + context.Request.Params["enterDetailStr"].Trim(',') + "]";
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            List <EnterStoreHouseDetailsModel> enterStoreHouseDetailsModelList = serializer.Deserialize <List <EnterStoreHouseDetailsModel> >(enterDetail);

            EnterStoreHouseModel enterStoreHouseAdd = new EnterStoreHouseModel();

            enterStoreHouseAdd.EnterDate    = DateTime.Now;
            enterStoreHouseAdd.HandlePerson = userFromCookie.UserId;
            enterStoreHouseAdd.CreateDate   = DateTime.Now;
            enterStoreHouseAdd.CreatePerson = userFromCookie.UserId;
            enterStoreHouseAdd.UpdatePerson = userFromCookie.UserId;
            enterStoreHouseAdd.UpdateDate   = DateTime.Now;
            enterStoreHouseAdd.DeleteMark   = false;

            int enterStoreHouseID = enterStoreHouseBLL.AddEnterStoreHouse(enterStoreHouseAdd);

            foreach (EnterStoreHouseDetailsModel model in enterStoreHouseDetailsModelList)
            {
                EnterStoreHouseDetailsModel newEnterStoreHouseDetailsModel = new EnterStoreHouseDetailsModel();
                newEnterStoreHouseDetailsModel.GoodsID           = model.GoodsID;
                newEnterStoreHouseDetailsModel.EnterQuantity     = model.EnterQuantity;
                newEnterStoreHouseDetailsModel.EnterStoreHouseID = enterStoreHouseID;
                newEnterStoreHouseDetailsModel.DeleteMark        = false;
                if (enterStoreHouseDetailsBll.AddEnterStoreHouseDetails(newEnterStoreHouseDetailsModel))    //添加入库明细
                {
                    GoodsModel goodsModel = goodsBll.GetGoodsModel(newEnterStoreHouseDetailsModel.GoodsID.Value);
                    goodsModel.RealQuantity += newEnterStoreHouseDetailsModel.EnterQuantity;
                    goodsBll.UpdateGoods(goodsModel);    //更新物品数量
                }
            }

            context.Response.Write("{\"msg\":\"入库成功!\",\"success\":true}");
        }
        private void AddOutStoreHouseDetails(DriveMgr.Model.User userFromCookie, HttpContext context)
        {
            GoodsBLL         goodsBll         = new GoodsBLL();
            OutStoreHouseBLL outStoreHouseBLL = new OutStoreHouseBLL();

            string outDetailStr = "[" + context.Request.Params["outDetailStr"].Trim(',') + "]";
            JavaScriptSerializer             serializer = new JavaScriptSerializer();
            List <OutStoreHouseDetailsModel> outStoreHouseDetailsModelList = serializer.Deserialize <List <OutStoreHouseDetailsModel> >(outDetailStr);

            OutStoreHouseModel outStoreHouseAdd = new OutStoreHouseModel();

            outStoreHouseAdd.OutDate      = DateTime.Now;
            outStoreHouseAdd.HandlePerson = userFromCookie.UserId;
            outStoreHouseAdd.CreateDate   = DateTime.Now;
            outStoreHouseAdd.CreatePerson = userFromCookie.UserId;
            outStoreHouseAdd.UpdatePerson = userFromCookie.UserId;
            outStoreHouseAdd.UpdateDate   = DateTime.Now;
            outStoreHouseAdd.DeleteMark   = false;

            int outStoreHouseID = outStoreHouseBLL.AddOutStoreHouse(outStoreHouseAdd);

            foreach (OutStoreHouseDetailsModel model in outStoreHouseDetailsModelList)
            {
                OutStoreHouseDetailsModel newOutStoreHouseDetailsModel = new OutStoreHouseDetailsModel();
                newOutStoreHouseDetailsModel.GoodsID         = model.GoodsID;
                newOutStoreHouseDetailsModel.OutQuantity     = model.OutQuantity;
                newOutStoreHouseDetailsModel.OutStoreHouseID = outStoreHouseID;
                newOutStoreHouseDetailsModel.DeleteMark      = false;
                if (outStoreHouseDetailsBll.AddOutStoreHouseDetails(newOutStoreHouseDetailsModel))    //添加入库明细
                {
                    GoodsModel goodsModel = goodsBll.GetGoodsModel(newOutStoreHouseDetailsModel.GoodsID.Value);
                    goodsModel.RealQuantity -= newOutStoreHouseDetailsModel.OutQuantity;
                    goodsBll.UpdateGoods(goodsModel);    //更新物品数量
                }
            }

            context.Response.Write("{\"msg\":\"出库成功!\",\"success\":true}");
        }