/// <summary> /// 添加库位信息 /// </summary> /// <param name="inputDto">库位信息</param> /// <returns></returns> public ReturnInfo AddWhStorageLocation(WHStorageLocationInputDto inputDto) { //验证 ReturnInfo rInfo = new ReturnInfo(); StringBuilder sb = new StringBuilder(); sb.Append(Helper.BasicValidate(inputDto).ToString()); if (sb.Length == 0) { bool isExist = _wHStorageLocationRepository.IsExist(inputDto.WAREID, inputDto.STID, inputDto.SLID); if (isExist) { rInfo.IsSuccess = false; rInfo.ErrorInfo = "已经存在!"; return(rInfo); } var whStorageLocation = Mapper.Map <WHStorageLocationInputDto, WHStorageLocation>(inputDto); whStorageLocation.CREATEDATE = DateTime.Now; whStorageLocation.MODIFYDATE = DateTime.Now; try { _unitOfWork.RegisterNew(whStorageLocation); bool result = _unitOfWork.Commit(); rInfo.IsSuccess = result; rInfo.ErrorInfo = sb.ToString(); return(rInfo); } catch (Exception ex) { _unitOfWork.Rollback(); sb.Append(ex.Message); rInfo.IsSuccess = false; rInfo.ErrorInfo = sb.ToString(); return(rInfo); } } else { rInfo.IsSuccess = false; rInfo.ErrorInfo = sb.ToString(); return(rInfo); } }
/// <summary> /// 更新库位 /// </summary> /// <param name="inputDto">库位信息</param> /// <returns></returns> public ReturnInfo UpdateWhStorageLocation(WHStorageLocationInputDto inputDto) { ReturnInfo RInfo = new ReturnInfo(); StringBuilder sb = new StringBuilder(); string ValidateInfo = Helper.BasicValidate(inputDto).ToString(); sb.Append(ValidateInfo); if (sb.Length == 0) { try { WHStorageLocation wareHouse = _wHStorageLocationRepository.GetById(inputDto.WAREID, inputDto.STID, inputDto.SLID).FirstOrDefault(); if (wareHouse != null) { wareHouse.NAME = inputDto.NAME; wareHouse.MAXVOLUME = inputDto.MAXVOLUME; wareHouse.MAXCAPACITY = inputDto.MAXCAPACITY; wareHouse.MANAGER = inputDto.MANAGER; wareHouse.MODIFYUSER = inputDto.MODIFYUSER; wareHouse.MODIFYDATE = DateTime.Now; _unitOfWork.RegisterDirty(wareHouse); } bool result = _unitOfWork.Commit(); RInfo.IsSuccess = result; RInfo.ErrorInfo = sb.ToString(); return(RInfo); } catch (Exception ex) { _unitOfWork.Rollback(); sb.Append(ex.Message); RInfo.IsSuccess = false; RInfo.ErrorInfo = sb.ToString(); return(RInfo); } } else { RInfo.IsSuccess = false; RInfo.ErrorInfo = sb.ToString(); return(RInfo); } }
/// <summary> /// 提交操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Press(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(txtSLID.Text)) { throw new Exception("库位编号不能为空"); } if (String.IsNullOrEmpty(txtSLName.Text)) { throw new Exception("库位名称不能为空"); } if (String.IsNullOrEmpty(btnManager.Text)) { throw new Exception("负责人不能为空"); } WHStorageLocationInputDto inputDto = new WHStorageLocationInputDto { SLID = txtSLID.Text, WAREID = txtWareID.Text, STID = txtSTID.Text, NAME = txtSLName.Text, MANAGER = btnManager.Tag.ToString(), MAXVOLUME = txtMAXVOLUME.Text, MAXCAPACITY = txtMAXCAPACITY.Text, MODIFYUSER = Client.Session["UserID"].ToString() }; if (isCreate) { inputDto.CREATEUSER = Client.Session["UserID"].ToString(); inputDto.STATUS = 0; //添加 ReturnInfo rInfo = autofacConfig.wareHouseService.AddWhStorageLocation(inputDto); if (rInfo.IsSuccess) { this.Close(); Toast("创建库位成功"); //刷新页面数据 ((frmWHStorageLocation)Form).Bind(); } else { throw new Exception(rInfo.ErrorInfo); } } else if (isEdit) { //编辑 ReturnInfo rInfo = autofacConfig.wareHouseService.UpdateWhStorageLocation(inputDto); if (rInfo.IsSuccess) { this.Close(); Toast("编辑库位成功"); //刷新页面数据 ((frmWHStorageLocation)Form).Bind(); } else { throw new Exception(rInfo.ErrorInfo); } } } catch (Exception ex) { Form.Toast(ex.Message); } }