namespace Yw.WinFrmUI
|
{
|
/// <summary>
|
/// 添加文件
|
/// </summary>
|
public partial class AddBimfaceFileDlg : DevExpress.XtraEditors.XtraForm
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public AddBimfaceFileDlg()
|
{
|
InitializeComponent();
|
this.layoutControl1.SetupLayoutControl();
|
}
|
|
/// <summary>
|
/// 返回数据事件
|
/// </summary>
|
public event Action<long> ReloadDataEvent;
|
private Lazy<Yw.BLL.BimfaceFile> _bll = new(() => new BLL.BimfaceFile());
|
|
/// <summary>
|
/// 绑定数据
|
/// </summary>
|
public void SetBindingData()
|
{
|
InitialModelType();
|
InitialFileStatus();
|
InitialFormatType();
|
}
|
|
//初始化模型类型
|
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 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 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 bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(this.txtBimFaceFileID.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.txtBimFaceFileID, "必填项");
|
return false;
|
}
|
if (string.IsNullOrEmpty(this.txtFileName.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.txtFileName, "必填项");
|
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 async void btnOk_Click(object sender, EventArgs e)
|
{
|
if (!Valid())
|
{
|
return;
|
}
|
var dto = new Yw.Dto.AddBimfaceFileInput();
|
dto.BimfaceId = this.txtBimFaceFileID.Text.Trim();
|
dto.Name = this.txtFileName.Text.Trim();
|
dto.ModelType = (int)(eModelType)this.imgCmbBimfaceModelType.EditValue;
|
dto.FormatType = (int)(eFormatType)this.imgCmbFormatType.EditValue;
|
dto.FileStatus = (int)(eFileStatus)this.imgCmbFileStatus.EditValue;
|
dto.FileSuffix = this.txtExtension.Text.Trim();
|
dto.FileSize = this.txtFileSize.Text.Trim();
|
dto.Description = this.txtDescription.Text.Trim();
|
|
var id = await _bll.Value.Insert(dto);
|
if (id < 1)
|
{
|
XtraMessageBox.Show("添加失败!");
|
return;
|
}
|
|
this.ReloadDataEvent?.Invoke(id);
|
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
|
}
|
}
|