/// <summary> /// 手动盘点 /// </summary> /// <param name="assetId">资产id</param> /// <param name="stockId">盘点id</param> /// <param name="result">盘点结果</param> /// <param name="method">盘点方式,1扫码盘点|2手动盘点</param> /// <param name="checkor">盘点人</param> /// <returns></returns> public Result DirectCheck(int assetId, int stockId, int result, int method, string checkor) { var util = MySearchUtil.New() .AndEqual("IsDel", false) .AndEqual("IsFinish", false) .AndEqual("StockId", stockId) .AndEqual("AssetId", assetId); var item = _db.Load <StockItem>(util); if (item == null) { return(ResultUtil.Do(ResultCodes.验证失败, "请求的资产未记录在本次盘点内")); } if (item.CheckResult > 0) { return(ResultUtil.Do(ResultCodes.验证失败, "该资产已经盘点")); } const string sql = @" UPDATE [Asset_StockItem] SET CheckAt=GETDATE(),Checkor=@Checkor,CheckResult=@Result, CheckMethod=@Method,UpdateAt=GETDATE(),Updator=@Checkor WHERE Id=@Id; UPDATE [Asset_Asset] SET LastCheckTime=GETDATE() WHERE Id=@AssetId;"; var row = _db.Execute(sql, new { Checkor = checkor, Result = result, Method = method, item.Id, item.AssetId }); return(row > 0 ? ResultUtil.Success() : ResultUtil.Do(ResultCodes.数据库操作失败, "操作失败")); }
/// <summary> /// 修改 /// </summary> /// <param name="entity"></param> /// <param name="user"></param> /// <returns></returns> public Result <int> Update(Account entity, IAppUser user) { try { var error = Validate(entity); if (!string.IsNullOrWhiteSpace(error)) { return(ResultUtil.Do(ResultCodes.验证失败, 0, error)); } entity.BeforeUpdate(user); var row = _db.Update(entity); if (row <= 0) { return(ResultUtil.Do(ResultCodes.数据库操作失败, 0, "数据写入失败")); } _db.Execute(@"UPDATE [Asset_Asset] SET DeptId=@DeptId WHERE AccountId=@AccountId", new { AccountId = entity.Id, DeptId = entity.DeptId }); return(ResultUtil.Success(entity.Id)); } catch (Exception ex) { return(ResultUtil.Exception(ex, 0)); } }
/// <summary> /// 设置申请为接受状态 /// </summary> /// <param name="id">申请id</param> /// <param name="userId">实施人ID</param> /// <param name="userName">实施人姓名</param> /// <returns></returns> public Result Receive(int id, string userId, string userName) { const string sql = "UPDATE [Asset_ServiceApply] SET [State]='已接受',ReceiveAt=GETDATE(),ServiceManId=@UserId,ServiceManName=@UserName WHERE Id=@Id"; var row = _db.Execute(sql, new { Id = id, UserId = userId, UserName = userName }); return(row > 0 ? ResultUtil.Success() : ResultUtil.Do(ResultCodes.数据库操作失败, "数据库操作失败")); }
public Result ChangePw(int id, string oldPw, string newPw) { var entity = Load(id); if (entity == null || entity.IsDel) { return(ResultUtil.Do(ResultCodes.验证失败, "请求的用户不存在或已删除")); } if (AESEncriptUtil.Decrypt(entity.Pw) != oldPw) { return(ResultUtil.Do(ResultCodes.验证失败, "原始密码不正确")); } entity.Pw = AESEncriptUtil.Encrypt(newPw); const string sql = "UPDATE Base_User SET Pw=@Pw WHERE Id=@Id"; var row = _db.Execute(sql, new { Id = id, entity.Pw }); return(row > 0 ? ResultUtil.Success() : ResultUtil.Do(ResultCodes.数据库操作失败)); }