using DevExpress.XtraEditors.Controls;
|
using DevExpress.XtraEditors.Repository;
|
|
namespace HStation.WinFrmUI.Assets
|
{
|
public partial class AddAssetsPackageMainDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public AddAssetsPackageMainDlg()
|
{
|
InitializeComponent();
|
this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon;
|
}
|
|
private Vmo.AssetsPackageMainVmo _EquipmentVmo = null;
|
|
public event Func<Vmo.AssetsPackageMainVmo, List<PumpAccountViewModel>, Task<bool>> ReloadDataEvent = null;
|
|
private List<PumpAccountViewModel> _allBindingList;
|
|
public async void SetBindingData(long SeriesID)
|
{
|
var pumpAllList = await new BLL.AssetsPumpMain().GetAll();
|
this.repositoryItemTreeListLookUpEdit1.DataSource = pumpAllList;
|
_allBindingList = new List<PumpAccountViewModel>();
|
this.pumpAccountViewModelBindingSource.DataSource = _allBindingList;
|
_EquipmentVmo = new Vmo.AssetsPackageMainVmo();
|
_EquipmentVmo.SeriesID = SeriesID;
|
var bll = new Yw.BLL.SysCatalog();
|
var alllist = await bll.GetAll();
|
foreach (var item in alllist)
|
{
|
var imageItem = new ImageComboBoxItem(item.Name, item.ID);
|
textEditCatalog.Properties.Items.Add(imageItem);
|
}
|
}
|
|
//删除
|
private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
|
{
|
if (_allBindingList == null || _allBindingList.Count < 1)
|
return;
|
var row = this.gridView1.GetCurrentViewModel(_allBindingList);
|
if (row == null)
|
return;
|
if (e.Column == this.ColDelete)
|
_allBindingList.Remove(row);
|
this.pumpAccountViewModelBindingSource.DataSource = _allBindingList;
|
this.pumpAccountViewModelBindingSource.ResetBindings(false);
|
}
|
|
//数据验证
|
private bool Valid()
|
{
|
this.dxErrorProvider1.ClearErrors();
|
if (string.IsNullOrEmpty(textEditName.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.textEditName, "必填项");
|
return false;
|
}
|
if (string.IsNullOrEmpty(textEditReserveCount.Text.Trim()))
|
{
|
this.dxErrorProvider1.SetError(this.textEditReserveCount, "必填项");
|
return false;
|
}
|
|
return true;
|
}
|
|
//完成
|
private async void BtnOk_ClickAsync(object sender, EventArgs e)
|
{
|
if (!(Valid()))
|
return;
|
_EquipmentVmo.Description = DescriptionTextEdit.Text.Trim();
|
_EquipmentVmo.Name = textEditName.Text.Trim();
|
_EquipmentVmo.NO = textEditNo.Text.Trim();
|
if (int.TryParse(this.textEditReserveCount.Text, out int equipmentCount))
|
{
|
_EquipmentVmo.PumpCount = equipmentCount;
|
}
|
if (long.TryParse(textEditCatalog.EditValue?.ToString() ?? "", out long catalogID))
|
{
|
_EquipmentVmo.CatalogID = catalogID;
|
}
|
if (await this.ReloadDataEvent.Invoke(_EquipmentVmo, _allBindingList))
|
{
|
TipFormHelper.ShowSucceed("添加成功!");
|
}
|
else
|
{
|
TipFormHelper.ShowError("添加失败!");
|
}
|
this.DialogResult = DialogResult.OK;
|
this.Close();
|
}
|
}
|
}
|