using HStation.WinFrmUI.Assets;
|
|
namespace HStation.WinFrmUI.Xhs.PumpProduct
|
{
|
public partial class PumpProductMainPage : DocumentPage
|
{
|
public PumpProductMainPage()
|
{
|
InitializeComponent();
|
this.PageTitle.Caption = "水泵管理";
|
this.PageTitle.HeaderSvgImage = this.svgImage32[0];
|
this.PageTitle.SvgImageSize = new Size(24, 24);
|
this.gridView1.SetNormalView();
|
this.gridView1.RegistCustomDrawRowIndicator();
|
this.AssetsPumpSeriesTreeListCtrl1.FocusedChangedEvent += AssetsPumpSeriesTreeListCtrl1_FocusedChangedEvent;
|
this.AssetsPumpSeriesTreeListCtrl1.AddAssetsPumpMain += BtnAdd_ItemClickAsync;
|
this.dockManager1.Style = DevExpress.XtraBars.Docking2010.Views.DockingViewStyle.Light;
|
}
|
|
private readonly List<AssetsPumpMainViewModel> _allBindingList = new();
|
|
private BLL.AssetsPumpMain _bll = null;
|
|
public override void InitialDataSource()
|
{
|
_bll = new BLL.AssetsPumpMain();
|
this.AssetsPumpSeriesTreeListCtrl1.SetBindingData();
|
this.currentViewModelBindingSource.DataSource = _allBindingList;
|
this.currentViewModelBindingSource.ResetBindings(false);
|
}
|
|
private async void SetBindingData()
|
{
|
_allBindingList.Clear();
|
_bll = new BLL.AssetsPumpMain();
|
var alllist = await _bll.GetAll();
|
foreach (var item in alllist)
|
{
|
_allBindingList.Add(new AssetsPumpMainViewModel(item));
|
}
|
}
|
|
//聚焦切换
|
private async void AssetsPumpSeriesTreeListCtrl1_FocusedChangedEvent(long obj, bool isgroup)
|
{
|
_allBindingList.Clear();
|
if (isgroup)
|
{
|
var alllist = await _bll.GetByPumpSeriesID(obj);
|
_allBindingList.Clear();
|
foreach (var item in alllist)
|
{
|
_allBindingList.Add(new AssetsPumpMainViewModel(item));
|
}
|
}
|
else
|
{
|
var idlist = await new BLL.AssetsPumpGroupAndMainMapping().GetByGroupID(obj);
|
var alllist = await _bll.GetByIds(idlist);
|
if (alllist != null)
|
{
|
_allBindingList.Clear();
|
foreach (var item in alllist)
|
{
|
_allBindingList.Add(new AssetsPumpMainViewModel(item));
|
}
|
}
|
}
|
this.currentViewModelBindingSource.ResetBindings(false);
|
}
|
|
//增加
|
private async void BtnAdd_ItemClickAsync(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var dlg = new AddPumpProductMainDlg();
|
//系列ID
|
var id = this.AssetsPumpSeriesTreeListCtrl1.GetCurrentID();
|
if (id <= 0)
|
{
|
return;
|
}
|
var groupid = this.AssetsPumpSeriesTreeListCtrl1.GetCurrentGroupID();
|
Vmo.AssetsPumpGroupAndMainMapVmo map = null;
|
if (groupid > 0)
|
{
|
map = new Vmo.AssetsPumpGroupAndMainMapVmo();
|
map.GroupID = groupid;
|
}
|
var AssetsPumpSeries = await new BLL.AssetsPumpSeries().GetByID(id);
|
if (AssetsPumpSeries == null)
|
return;
|
dlg.SetBindingData(AssetsPumpSeries);
|
dlg.ReloadDataEvent += async (main) =>
|
{
|
var id = await _bll.InsertEx(main, map);
|
if (id > 0)
|
{
|
var model = await _bll.GetByID(id);
|
_allBindingList.Add(new AssetsPumpMainViewModel(model));
|
this.currentViewModelBindingSource.ResetBindings(false);
|
return true;
|
}
|
return false;
|
};
|
dlg.ShowDialog();
|
}
|
|
//修改
|
private async void BtnEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var currentVm = this.gridView1.GetCurrentViewModel(_allBindingList);
|
if (currentVm == null)
|
{
|
MessageBoxHelper.ShowWarning("请选择数据行!");
|
return;
|
}
|
var dlg = new EditPumpProductMainDlg();
|
var model = await new BLL.AssetsPumpMain().GetByID(currentVm.ID);
|
if (model == null)
|
return;
|
dlg.SetBindingData(model);
|
dlg.ReloadDataEvent += async (rhs) =>
|
{
|
if (await _bll.Update(rhs))
|
{
|
currentVm.Reset(rhs);
|
this.currentViewModelBindingSource.ResetBindings(false);
|
return true;
|
}
|
return false;
|
};
|
dlg.ShowDialog();
|
}
|
|
//删除
|
private async void BtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var currentVm = this.gridView1.GetCurrentViewModel(_allBindingList);
|
if (currentVm == null)
|
{
|
MessageBoxHelper.ShowWarning("请选择数据行!");
|
return;
|
}
|
if (MessageBoxHelper.IsClickOk($"确认删除数据行?", "提示"))
|
return;
|
var groupresult = await _bll.DeleteMapByMainID(currentVm.ID);
|
if (groupresult)
|
{
|
_allBindingList.Remove(currentVm);
|
this.currentViewModelBindingSource.ResetBindings(false);
|
MessageBoxHelper.ShowSuccess($"删除成功!");
|
}
|
else
|
{
|
MessageBoxHelper.ShowError($"删除失败!");
|
return;
|
}
|
}
|
|
//泵曲线编辑
|
private async void barBtnEditPumpCurve_ItemClickAsync(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var currentVm = this.gridView1.GetCurrentViewModel(_allBindingList);
|
if (currentVm == null)
|
{
|
MessageBoxHelper.ShowWarning("请选择数据行!");
|
return;
|
}
|
var guid = new PageGuid()
|
{
|
Function = "泵型号曲线",
|
TagName = currentVm.ID.ToString(),
|
Modular = ""
|
};
|
if (!IsExistPage(guid, true))
|
{
|
var model = await _bll.GetByID(currentVm.ID);
|
if (model == null)
|
{
|
MessageBoxHelper.ShowWarning($"{currentVm.Name}:AssetsPumpMainDto is null!");
|
return;
|
}
|
var page = new PumpChartMainPage();
|
page.SetBindingData(currentVm.Model);
|
page.PageTitle.Caption = guid.Function;
|
page.PageGuid = guid;
|
CreatePage(page, guid);
|
}
|
}
|
|
#region 右击菜单功能列表
|
|
//泵产品编辑
|
private void BarBtnEidtPumpPart_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var currentVm = this.gridView1.GetCurrentViewModel(_allBindingList);
|
if (currentVm == null)
|
{
|
MessageBoxHelper.ShowWarning("请选择数据行!");
|
return;
|
}
|
var dlg = new EditPumpPartPropDlg();
|
// var AssetsPumpMain = currentVm.Model as Vmo.AssetsPumpMainVmo;
|
dlg.SetBindingData(currentVm.Model);
|
dlg.ReloadEvent += async (part, content, map) =>
|
{
|
var bll = new BLL.AssetsPumpPartMain();
|
var id = await bll.InsertEx(part, content, map);
|
if (id > 0)
|
{
|
return true;
|
}
|
return false;
|
};
|
|
dlg.ShowDialog();
|
}
|
|
//查看泵信息
|
private void BarBtnPumpinformation_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var dlg = new ViewPumpInformationDlg();
|
dlg.ShowDialog();
|
}
|
|
#endregion 右击菜单功能列表
|
|
//表格右击菜单
|
private void gridView1_MouseUp(object sender, MouseEventArgs e)
|
{
|
if (e.Button == MouseButtons.Right)
|
{
|
if (this.gridView1.GetCurrentViewModel(_allBindingList) != null)
|
{
|
Point screenPoint = Cursor.Position;
|
popupPump.ShowPopup(screenPoint);
|
}
|
}
|
}
|
|
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
//var model = this.gridView1.GetCurrentViewModel(_allBindingList);
|
//var dlg = new SelXhsPumpMainPhartDlg();
|
//dlg.SetBandingData(model.UserID);
|
//dlg.ShowDialog();
|
}
|
}
|
}
|