Ejemplo n.º 1
0
        /// <summary>
        /// 当物品新增时,在记录表中添加一条物品状态为“正常”的记录,用作统计功能
        /// </summary>
        /// <param name="goods">物品对象</param>
        /// <param name="userid">录入人</param>
        /// <returns></returns>
        public string AddGoodsRecordWhenNewGoodsAdd(B_Goods goods, string userid)
        {
            var tran = Utility.Database.BeginDbTransaction();
            B_GoodsStatusRecord goodsRecordInfor = new B_GoodsStatusRecord();
            goodsRecordInfor.goodsId = goods.id;//物品Id
            goodsRecordInfor.recordDate = DateTime.Now.ToString();//录入时间
            goodsRecordInfor.recordMan = userid;//录入人名称
            goodsRecordInfor.originalGoodsStatus = goods.wpzt;//原来物品状态
            goodsRecordInfor.originalProtectMan = goods.bgry;//原来保管人员
            goodsRecordInfor.originalUseDepartment = goods.sybm;//原来使用部门
            goodsRecordInfor.isDelete = 0;

            goodsRecordInfor.useDepartment = goods.sybm;//使用部门
            goodsRecordInfor.goodsStatus = "1";//物品状态为正常状态
            goodsRecordInfor.protectMan = goods.bgry;//保管人员
            goodsRecordInfor.statusRemark = "新增记录";//备注
            Utility.Database.Insert(goodsRecordInfor, tran);
            Utility.Database.Commit(tran);
            return Utility.JsonMsg(true, "保存数据成功");
        }
Ejemplo n.º 2
0
 public string DeleteGoods(string id, string userid)
 {
     var tran = Utility.Database.BeginDbTransaction();
     StringBuilder strinBuilder = new StringBuilder();
     try
     {
         //int i = GetGoodsRecordExistById(id);
         //if (i > 0) throw new Exception("此物品还有状态记录,无法删除,请将此物品的状态记录删除后,再做次操作。");
         //strinBuilder.AppendFormat("update B_Goods set isDelete = 1,deleteMan='{0}',deleteDate='{1}' where id={2}", userid, DateTime.Now, id);
         //Utility.Database.ExecuteNonQuery(strinBuilder.ToString(), tran);
         //先删除记录表的相关内容
         DeleteGoodsRecordListByGoodsId(id);
         B_Goods goods = new B_Goods();
         goods.Condition.Add("id=" + id);
         Utility.Database.Delete(goods);
         Utility.Database.Commit(tran);
         return Utility.JsonMsg(true, "删除除数据成功");
     }
     catch (Exception e)
     {
         Utility.Database.Rollback(tran);
         return Utility.JsonMsg(false, "册除数据失败!异常信息: " + e.Message);
     }
 }
Ejemplo n.º 3
0
 public string GetGoodsModel(string content)
 {
     B_Goods model = new B_Goods();
     return JsonConvert.SerializeObject( model);
 }
Ejemplo n.º 4
0
        public string SaveGoods(string JsonData, string userName, string userid)
        {
            var tran = Utility.Database.BeginDbTransaction();
            try
            {
                StringBuilder validateTip = new StringBuilder();//验证提示

                B_Goods goods = JsonConvert.DeserializeObject<B_Goods>(JsonData);

                //验证
                if (goods.zclb == "" || goods.zclb == null)
                {//资产类别
                    validateTip.Append("\r\n请选择资产类别!");
                }

                if (goods.zcmc == "" || goods.zcmc == null)//资产名称
                {
                    validateTip.Append("\r\n资产名称不能为空!");
                }

                if (goods.sybm == "" || goods.sybm == null)//资产名称
                {
                    validateTip.Append("\r\n使用部门不能为空!");
                }
                if (goods.bgry == "" || goods.bgry == null)//资产名称
                {
                    validateTip.Append("\r\n保管人员不能为空!");
                }
                if (validateTip.Length > 0) throw new Exception(validateTip.ToString());

                if (goods.id == 0 || goods.id == null)
                {
                    //新增
                    goods.zcbh = GetGoodsNo();//资产编号
                    goods.recordMan = userid;
                    goods.recordDate = DateTime.Now.ToString();
                    goods.isDelete = 0;//删除状态设置为未删除
                    goods.wpzt = "1";
                    goods.originalDep = goods.sybm;//原始的使用部门
                    goods.originalProtectman = goods.bgry;//原始的保管人员
                    Utility.Database.Insert(goods, tran);
                    Utility.Database.Commit(tran);
                    B_Goods model = new B_Goods();
                    model = GetGoodsById(goods.zcbh);
                    //添加一条记录
                    AddGoodsRecordWhenNewGoodsAdd(model, userid);
                    return JsonConvert.SerializeObject( model);
                }
                else
                {
                    goods.Condition.Add("ID=" + goods.id);
                    //修改
                    Utility.Database.Update<B_Goods>(goods, tran);
                    Utility.Database.Commit(tran);
                    return Utility.JsonMsg(true, "保存数据成功");
                }
            }
            catch (Exception e)
            {
                Utility.Database.Rollback(tran);
                return Utility.JsonMsg(false, "保存数据失败!异常信息: " + e.Message); ;//将对象转为json字符串并返回到客户端
            }
        }
Ejemplo n.º 5
0
 public string GetData(string content)
 {
     GetDataModel model = new GetDataModel();
     B_Goods goodsEnt = new B_Goods();
     B_GoodsStatusRecord goodStatusRecordEnt = new B_GoodsStatusRecord();
     model.dataEdit = Utility.Database.QueryObject<B_Goods>(goodsEnt);
     model.dataGoodsStatusRecordEdit = Utility.Database.QueryObject<B_GoodsStatusRecord>(goodStatusRecordEnt);
     return JsonConvert.SerializeObject( model);
 }