using Mapster;
|
using System.ComponentModel;
|
using Yw.Dto;
|
|
namespace HStation.WinFrmUI.Basic
|
{
|
public partial class SetSysPropChoiceDlg : DevExpress.XtraEditors.XtraForm
|
{
|
public SetSysPropChoiceDlg()
|
{
|
InitializeComponent();
|
}
|
|
private Yw.BLL.SysPropChoice _bll = null;
|
|
private List<SysPropChoiceViewModel> _allBindingList = null;
|
|
public async void SetBindingData(long PropID)
|
{
|
_bll = new Yw.BLL.SysPropChoice();
|
var alllist = await _bll.GetByPropID(PropID);
|
_allBindingList = new List<SysPropChoiceViewModel>();
|
foreach (var item in alllist)
|
{
|
_allBindingList.Add(new SysPropChoiceViewModel(item));
|
}
|
this.sysPropChoiceViewModelBindingSource.DataSource = _allBindingList;
|
this.sysPropChoiceViewModelBindingSource.ResetBindings(false);
|
}
|
|
//完成
|
private async void BtnOk_Click(object sender, EventArgs e)
|
{
|
var AddSysPropChoices = new List<AddSysPropChoiceInput>();
|
foreach (var item in _allBindingList)
|
{
|
AddSysPropChoices.Add(item.Adapt<SysPropChoiceViewModel, AddSysPropChoiceInput>());
|
}
|
if (await _bll.Inserts(AddSysPropChoices))
|
{
|
MessageBoxHelper.ShowSuccess("设置成功!");
|
}
|
else
|
{
|
MessageBoxHelper.ShowError("设置失败!");
|
}
|
}
|
|
//删除
|
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.sysPropChoiceViewModelBindingSource.DataSource = _allBindingList;
|
this.sysPropChoiceViewModelBindingSource.ResetBindings(false);
|
}
|
}
|
}
|