| | |
| | | namespace Yw.WinFrmUI |
| | | using Mapster; |
| | | |
| | | namespace Yw.WinFrmUI |
| | | { |
| | | /// <summary> |
| | | /// 编辑模型文件 |
| | |
| | | } |
| | | |
| | | public event Action<long> ReloadDataEvent; |
| | | private Yw.Dto.UpdateBimfaceFileInput _updateModel = null; |
| | | private Lazy<Yw.BLL.BimfaceFile> _bll = new(() => new Yw.BLL.BimfaceFile()); |
| | | private Yw.Vmo.BimfaceFileVmo _updateModel = null; |
| | | |
| | | /// <summary> |
| | | /// 绑定数据 |
| | | /// </summary> |
| | | //public void SetBindingData(Model.BimFile4Update rhs) |
| | | //{ |
| | | // _updateModel = rhs; |
| | | // this.txtName.EditValue = rhs.FileName; |
| | | // this.txtDescription.EditValue = rhs.Description; |
| | | //} |
| | | public void SetBindingData(BimfaceFileMgrViewModel vm) |
| | | { |
| | | InitialModelType(); |
| | | InitialFormatType(); |
| | | InitialFileStatus(); |
| | | _updateModel = vm.Adapt<BimfaceFileMgrViewModel, Yw.Vmo.BimfaceFileVmo>(); |
| | | this.txtBimfaceId.EditValue = vm.BimfaceId; |
| | | this.txtName.EditValue = vm.Name; |
| | | this.imgCmbBimfaceModelType.EditValue = vm.ModelType; |
| | | this.imgCmbFormatType.EditValue = vm.FormatType; |
| | | this.imgCmbFileStatus.EditValue = vm.FileStatus; |
| | | this.txtFileSize.EditValue = vm.FileSize; |
| | | this.txtExtension.EditValue = vm.FileSuffix; |
| | | this.txtDescription.EditValue = vm.Description; |
| | | } |
| | | |
| | | //初始化模型类型 |
| | | private void InitialModelType() |
| | | { |
| | | this.imgCmbBimfaceModelType.Properties.BeginUpdate(); |
| | | this.imgCmbBimfaceModelType.Properties.Items.Clear(); |
| | | this.imgCmbBimfaceModelType.Properties.Items.AddEnum(typeof(eModelType), false); |
| | | this.imgCmbBimfaceModelType.EditValue = eModelType.File; |
| | | this.imgCmbBimfaceModelType.Properties.EndUpdate(); |
| | | this.imgCmbBimfaceModelType.Enabled = false; |
| | | } |
| | | |
| | | //初始化文件格式 |
| | | private void InitialFormatType() |
| | | { |
| | | this.imgCmbFormatType.Properties.BeginUpdate(); |
| | | this.imgCmbFormatType.Properties.Items.Clear(); |
| | | this.imgCmbFormatType.Properties.Items.AddEnum(typeof(eFormatType), false); |
| | | this.imgCmbFormatType.EditValue = eFormatType.d3; |
| | | this.imgCmbFormatType.Properties.EndUpdate(); |
| | | } |
| | | |
| | | //初始化文件状态 |
| | | private void InitialFileStatus() |
| | | { |
| | | this.imgCmbFileStatus.Properties.BeginUpdate(); |
| | | this.imgCmbFileStatus.Properties.Items.Clear(); |
| | | this.imgCmbFileStatus.Properties.Items.AddEnum(typeof(eFileStatus), false); |
| | | this.imgCmbFileStatus.EditValue = eFileStatus.ConvertSucceed; |
| | | this.imgCmbFileStatus.Properties.EndUpdate(); |
| | | } |
| | | |
| | | //验证 |
| | | private bool Valid() |
| | | { |
| | | this.dxErrorProvider1.ClearErrors(); |
| | | if (string.IsNullOrEmpty(this.txtBimfaceId.Text.Trim())) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.txtBimfaceId, "必填项"); |
| | | return false; |
| | | } |
| | | if (string.IsNullOrEmpty(this.txtName.Text.Trim())) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.txtName, "必填项"); |
| | | return false; |
| | | } |
| | | if (string.IsNullOrEmpty(this.txtExtension.Text.Trim())) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.txtExtension, "必填项"); |
| | | return false; |
| | | } |
| | | if (string.IsNullOrEmpty(this.imgCmbBimfaceModelType.Text.Trim())) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.imgCmbBimfaceModelType, "必选项"); |
| | | return false; |
| | | } |
| | | if (string.IsNullOrEmpty(this.imgCmbFormatType.Text.Trim())) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.imgCmbFormatType, "必选项"); |
| | | return false; |
| | | } |
| | | if (string.IsNullOrEmpty(this.imgCmbFileStatus.Text.Trim())) |
| | | { |
| | | this.dxErrorProvider1.SetError(this.imgCmbFileStatus, "必选项"); |
| | | return false; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | //确定 |
| | | private void btnOk_Click(object sender, EventArgs e) |
| | | private async void btnOk_Click(object sender, EventArgs e) |
| | | { |
| | | //if (!Valid()) |
| | | // return; |
| | | //_updateModel.FileName = this.txtName.Text.Trim(); |
| | | //_updateModel.Description = this.txtDescription.Text.Trim(); |
| | | if (!Valid()) |
| | | { |
| | | return; |
| | | } |
| | | _updateModel.BimfaceId = this.txtBimfaceId.Text.Trim(); |
| | | _updateModel.Name = this.txtName.Text.Trim(); |
| | | _updateModel.ModelType = (int)(eModelType)this.imgCmbBimfaceModelType.EditValue; |
| | | _updateModel.FormatType = (int)(eFormatType)this.imgCmbFormatType.EditValue; |
| | | _updateModel.FileStatus = (int)(eFileStatus)this.imgCmbFileStatus.EditValue; |
| | | _updateModel.FileSuffix = this.txtExtension.Text.Trim(); |
| | | _updateModel.FileSize = this.txtFileSize.Text.Trim(); |
| | | _updateModel.Description = this.txtDescription.Text.Trim(); |
| | | |
| | | //if (!new BLL.BimFile().Update(_updateModel)) |
| | | //{ |
| | | // XtraMessageBox.Show("更新失败!"); |
| | | // return; |
| | | //} |
| | | if (!await BLLFactory<Yw.BLL.BimfaceFile>.Instance.Update(_updateModel)) |
| | | { |
| | | XtraMessageBox.Show("更新失败!"); |
| | | return; |
| | | } |
| | | |
| | | //if (this.ReloadDataEvent != null) |
| | | // this.ReloadDataEvent(_updateModel); |
| | | //this.DialogResult = DialogResult.OK; |
| | | //this.Close(); |
| | | if (this.ReloadDataEvent != null) |
| | | { |
| | | this.ReloadDataEvent(_updateModel.ID); |
| | | } |
| | | this.DialogResult = DialogResult.OK; |
| | | this.Close(); |
| | | } |
| | | |
| | | |