From ad8f813f5eddd66740b4e09801e4ea02ddf70a4a Mon Sep 17 00:00:00 2001
From: duheng <2784771470@qq.com>
Date: 星期三, 19 二月 2025 15:58:22 +0800
Subject: [PATCH] 继续优化报表

---
 WinFrmUI/Yw.WinFrmUI.Bimface.Core/02-file/EditBimfaceFileDlg.cs |  123 +++++++++++++++++++++++++++++++++-------
 1 files changed, 100 insertions(+), 23 deletions(-)

diff --git a/WinFrmUI/Yw.WinFrmUI.Bimface.Core/02-file/EditBimfaceFileDlg.cs b/WinFrmUI/Yw.WinFrmUI.Bimface.Core/02-file/EditBimfaceFileDlg.cs
index 4f372ff..22ccb09 100644
--- a/WinFrmUI/Yw.WinFrmUI.Bimface.Core/02-file/EditBimfaceFileDlg.cs
+++ b/WinFrmUI/Yw.WinFrmUI.Bimface.Core/02-file/EditBimfaceFileDlg.cs
@@ -1,4 +1,6 @@
-锘縩amespace Yw.WinFrmUI
+锘縰sing Mapster;
+
+namespace Yw.WinFrmUI
 {
     /// <summary>
     /// 缂栬緫妯″瀷鏂囦欢
@@ -12,49 +14,124 @@
         }
 
         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();
         }
 
 

--
Gitblit v1.9.3