using DevExpress.XtraEditors.Controls; namespace HStation.WinFrmUI.Assets { public partial class AddAssetsThreelinkMainDlg : DevExpress.XtraEditors.XtraForm { public AddAssetsThreelinkMainDlg() { InitializeComponent(); this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; } private Vmo.AssetsThreelinkMainVmo _ThreeLinkVmo = null; public async void SetBindingData(long SeriesID) { _ThreeLinkVmo = new Vmo.AssetsThreelinkMainVmo(); _ThreeLinkVmo.SeriesID = SeriesID; var allCaliber = await new Yw.BLL.SysDictData().GetByTypeCode("1"); if (allCaliber != null) { foreach (var item in allCaliber) { var imageItem = new ImageComboBoxItem(item.Name, item.ID); TextEditCaliber.Properties.Items.Add(imageItem); } } var allMaterial = await new Yw.BLL.SysDictData().GetByTypeCode("3"); if (allMaterial != null) { foreach (var item in allMaterial) { var imageItem = new ImageComboBoxItem(item.Name, item.ID); TextEditMaterial.Properties.Items.Add(imageItem); } } TextEditCaliber.SelectedIndex = 0; TextEditMaterial.SelectedIndex = 0; } public event Func> ReloadDataEvent = null; //数据验证 private bool Valid() { this.dxErrorProvider1.ClearErrors(); if (string.IsNullOrEmpty(TextEditName.Text.Trim())) { this.dxErrorProvider1.SetError(this.TextEditName, "必填项"); return false; } if (string.IsNullOrEmpty(TextEditCoefficient.Text.Trim())) { this.dxErrorProvider1.SetError(this.TextEditCoefficient, "必填项"); return false; } return true; } //完成 private async void BtnOk_ClickAsync(object sender, EventArgs e) { if (!(Valid())) return; _ThreeLinkVmo.Description = DescriptionTextEdit.Text.Trim(); _ThreeLinkVmo.Name = TextEditName.Text.Trim(); _ThreeLinkVmo.KeyWord = TextEditKeyWorld.Text.Trim(); if (TextEditMaterial.Text != "默认") { _ThreeLinkVmo.MaterialName = TextEditMaterial.Text.Trim(); } if (double.TryParse(TextEditCaliber.Text, out double caliber)) { _ThreeLinkVmo.Caliber = caliber; } if (double.TryParse(TextEditCoefficient.Text, out double coefficient)) { _ThreeLinkVmo.Coefficient = coefficient; } if (double.TryParse(textEditRunThroughCoefficient.Text, out double runThrough)) { _ThreeLinkVmo.Coefficient = runThrough; } if (double.TryParse(textEditBranchThroughCoefficient.Text, out double branchThough)) { _ThreeLinkVmo.Coefficient = branchThough; } if (await this.ReloadDataEvent.Invoke(_ThreeLinkVmo)) { TipFormHelper.ShowSucceed("添加成功!"); } else { TipFormHelper.ShowError("添加失败!"); } this.DialogResult = DialogResult.OK; this.Close(); } } }