/// <summary> /// 编辑库存产品 /// </summary> /// <param name="pdt"></param> /// <param name="sn"></param> /// <param name="userId"></param> /// <returns></returns> public bool EditIvtProduct(ivt_warehouse_product pdt, string sn, long userId) { ivt_warehouse_product product = dal.FindById(pdt.id); ivt_warehouse_product productOld = dal.FindById(pdt.id); if (product == null) { return(false); } product.reference_number = pdt.reference_number; product.bin = pdt.bin; product.quantity_minimum = pdt.quantity_minimum; product.quantity_maximum = pdt.quantity_maximum; product.quantity = pdt.quantity; product.update_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); product.update_user_id = userId; string desc = OperLogBLL.CompareValue <ivt_warehouse_product>(productOld, product); if (!string.IsNullOrEmpty(desc)) { dal.Update(product); OperLogBLL.OperLogUpdate(desc, product.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM, "修改库存产品"); } if (product.quantity != productOld.quantity) // 修改库存数量记录库存转移 { var transferDal = new ivt_transfer_dal(); var trsf = new ivt_transfer(); trsf.id = dal.GetNextIdCom(); trsf.create_time = Tools.Date.DateHelper.ToUniversalTimeStamp(); trsf.create_user_id = userId; trsf.update_time = trsf.create_time; trsf.update_user_id = userId; trsf.quantity = product.quantity - productOld.quantity; trsf.type_id = (int)DicEnum.INVENTORY_TRANSFER_TYPE.MANUAL; trsf.product_id = product.product_id; trsf.from_warehouse_id = (long)product.warehouse_id; trsf.notes = ""; transferDal.Insert(trsf); OperLogBLL.OperLogAdd <ivt_transfer>(trsf, trsf.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM_TRANSFER, "新增库存转移"); } //OperLogBLL.OperLogUpdate<ivt_warehouse_product>(product, productOld, product.id, userId, DicEnum.OPER_LOG_OBJ_CATE.INVENTORY_ITEM, "修改库存产品"); string sql = $"update ivt_warehouse_product_sn set delete_user_id={userId},delete_time={Tools.Date.DateHelper.ToUniversalTimeStamp()} where warehouse_product_id={product.id}"; dal.ExecuteSQL(sql); SaveProductSn(sn, product.id, userId); return(true); }
public ERROR_CODE DeleteInventory(long id, long user_id) { var user = UserInfoBLL.GetUserInfo(user_id); if (user == null) { // 查询不到用户,用户丢失 return(ERROR_CODE.USER_NOT_FIND); } ivt_warehouse_product_dal inv_dal = new ivt_warehouse_product_dal(); var inv = inv_dal.FindNoDeleteById(id); if (inv == null) { return(ERROR_CODE.ERROR); } inv.delete_user_id = user_id; inv.delete_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); if (!inv_dal.Update(inv)) { return(ERROR_CODE.ERROR); } //操作日志 var add_log = new sys_oper_log() { user_cate = "用户", user_id = (int)user.id, name = user.name, phone = user.mobile == null ? "" : user.mobile, oper_time = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now), oper_object_cate_id = (int)OPER_LOG_OBJ_CATE.WAREHOUSE_PRODUCT, // oper_object_id = inv.id, // 操作对象id oper_type_id = (int)OPER_LOG_TYPE.DELETE, oper_description = _dal.AddValue(inv), remark = "删除产品库存信息" }; // 创建日志 new sys_oper_log_dal().Insert(add_log); // 插入日志 return(ERROR_CODE.SUCCESS); }