| | |
| | | using HStation.WinFrmUI.Assets; |
| | | using DevExpress.Utils.DragDrop; |
| | | using HStation.WinFrmUI.Assets; |
| | | using Yw; |
| | | |
| | | namespace HStation.WinFrmUI.Xhs.PumpProduct |
| | | { |
| | |
| | | this.dockManager1.Style = DevExpress.XtraBars.Docking2010.Views.DockingViewStyle.Light; |
| | | } |
| | | |
| | | private readonly List<AssetsPumpMainViewModel> _allBindingList = new(); |
| | | private List<AssetsPumpMainViewModel> _allBindingList = new(); |
| | | |
| | | private BLL.AssetsPumpMain _bll = null; |
| | | |
| | |
| | | { |
| | | var alllist = await _bll.GetByPumpSeriesID(obj); |
| | | _allBindingList.Clear(); |
| | | foreach (var item in alllist) |
| | | if (alllist != null) |
| | | { |
| | | _allBindingList.Add(new AssetsPumpMainViewModel(item)); |
| | | foreach (var item in alllist) |
| | | { |
| | | _allBindingList.Add(new AssetsPumpMainViewModel(item)); |
| | | } |
| | | } |
| | | } |
| | | else |
| | |
| | | { |
| | | var dlg = new AddPumpProductMainDlg(); |
| | | //系列ID |
| | | var id = this.AssetsPumpSeriesTreeListCtrl1.GetCurrentID(); |
| | | var id = this.AssetsPumpSeriesTreeListCtrl1.GetCurrentSeriesID(); |
| | | if (id <= 0) |
| | | { |
| | | return; |
| | |
| | | } |
| | | } |
| | | |
| | | private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | //批量导入 |
| | | private void BtnImportEx_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | //var model = this.gridView1.GetCurrentViewModel(_allBindingList); |
| | | //var dlg = new SelXhsPumpMainPhartDlg(); |
| | | //dlg.SetBandingData(model.UserID); |
| | | //dlg.ShowDialog(); |
| | | //树聚焦ID |
| | | var seriesId = this.AssetsPumpSeriesTreeListCtrl1.GetFocusID(out bool isGroup); |
| | | if (seriesId <= 0) |
| | | { |
| | | return; |
| | | } |
| | | var dlg = new ImportPumpExcel(); |
| | | dlg.SetBindingData(seriesId); |
| | | dlg.ReloadDataEvent += () => |
| | | { |
| | | AssetsPumpSeriesTreeListCtrl1_FocusedChangedEvent(seriesId, isGroup); |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | |
| | | private void barCkDrag_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | SetDragEnable(this.barCkDrag.Checked); |
| | | } |
| | | |
| | | //设置拖拽可用性 |
| | | private void SetDragEnable(bool allowArag) |
| | | { |
| | | var be = this.behaviorManager1.GetBehavior<DevExpress.Utils.DragDrop.DragDropBehavior>(this.gridView1); |
| | | be.Properties.AllowDrag = allowArag; |
| | | } |
| | | |
| | | //拖拽 |
| | | private async void dragDropEvents1_DragDrop(object sender, DevExpress.Utils.DragDrop.DragDropEventArgs e) |
| | | { |
| | | var indexs = e.Data as int[]; |
| | | if (indexs == null || indexs.Length < 1) |
| | | { |
| | | e.Handled = true; |
| | | return; |
| | | } |
| | | var sourceIndex = indexs[0]; |
| | | var sourceObj = this.gridView1.GetRow(sourceIndex) as AssetsPumpMainViewModel; |
| | | if (sourceObj == null) |
| | | { |
| | | e.Handled = true; |
| | | return; |
| | | } |
| | | |
| | | var destIndex = this.gridView1.GetRowHandleByCP(e.Location); |
| | | if (destIndex < 0) |
| | | { |
| | | e.Handled = true; |
| | | return; |
| | | } |
| | | |
| | | var destObj = this.gridView1.GetRow(destIndex) as AssetsPumpMainViewModel; |
| | | if (destObj == null) |
| | | { |
| | | e.Handled = true; |
| | | return; |
| | | } |
| | | |
| | | var sorters = new List<Yw.Vmo.Sorter>(); |
| | | |
| | | if (e.InsertType == InsertType.Before) |
| | | { |
| | | sorters.Add(new Yw.Vmo.Sorter() { ID = sourceObj.ID, SortCode = destObj.SortCode }); |
| | | _allBindingList.ForEach(x => |
| | | { |
| | | if (x.SortCode >= destObj.SortCode) |
| | | { |
| | | if (x != sourceObj) |
| | | { |
| | | sorters.Add(new Yw.Vmo.Sorter() { ID = x.ID, SortCode = x.SortCode + 1 }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | else if (e.InsertType == InsertType.After) |
| | | { |
| | | sorters.Add(new Yw.Vmo.Sorter() { ID = sourceObj.ID, SortCode = destObj.SortCode + 1 }); |
| | | _allBindingList.ForEach(x => |
| | | { |
| | | if (x.SortCode > destObj.SortCode) |
| | | { |
| | | if (x != sourceObj) |
| | | { |
| | | sorters.Add(new Yw.Vmo.Sorter() { ID = x.ID, SortCode = x.SortCode + 1 }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | e.Handled = true; |
| | | return; |
| | | } |
| | | |
| | | var bll = BLLFactory<HStation.BLL.AssetsPumpMain>.Instance; |
| | | var bol = await bll.UpdateSorter(sorters); |
| | | if (!bol) |
| | | { |
| | | e.Handled = true; |
| | | return; |
| | | } |
| | | |
| | | _allBindingList.ForEach(x => |
| | | { |
| | | var sorter = sorters.Find(t => t.ID == x.ID); |
| | | if (sorter != null) |
| | | { |
| | | x.SortCode = sorter.SortCode; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | //上移 |
| | | private void barBtnUp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | Up(); |
| | | } |
| | | |
| | | //下移 |
| | | private void barBtnDown_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | Down(); |
| | | } |
| | | |
| | | //上移 |
| | | private async void Up() |
| | | { |
| | | var vm = this.gridView1.GetCurrentViewModel(_allBindingList); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | var rowHandle = this.gridView1.FocusedRowHandle; |
| | | if (rowHandle == 0) |
| | | { |
| | | TipFormHelper.ShowWarn("上移失败!"); |
| | | return; |
| | | } |
| | | var current = this.gridView1.GetRow(rowHandle) as AssetsPumpMainViewModel; |
| | | if (current == null) |
| | | { |
| | | return; |
| | | } |
| | | var prevHandle = rowHandle - 1; |
| | | var prev = this.gridView1.GetRow(prevHandle) as AssetsPumpMainViewModel; |
| | | if (prev == null) |
| | | { |
| | | return; |
| | | } |
| | | var sorters = new List<Yw.Vmo.Sorter>(); |
| | | sorters.Add(new Yw.Vmo.Sorter() { ID = current.ID, SortCode = prev.SortCode }); |
| | | sorters.Add(new Yw.Vmo.Sorter() { ID = prev.ID, SortCode = current.SortCode }); |
| | | var bol = await BLLFactory<HStation.BLL.AssetsPumpMain>.Instance.UpdateSorter(sorters); |
| | | if (!bol) |
| | | { |
| | | TipFormHelper.ShowError("上移失败!"); |
| | | return; |
| | | } |
| | | var sortCode = current.SortCode; |
| | | current.SortCode = prev.SortCode; |
| | | prev.SortCode = sortCode; |
| | | _allBindingList = _allBindingList.OrderBy(x => x.SortCode).ToList(); |
| | | this.currentViewModelBindingSource.DataSource = _allBindingList; |
| | | this.currentViewModelBindingSource.ResetBindings(false); |
| | | this.gridView1.FocusedRowHandle = prevHandle; |
| | | } |
| | | |
| | | //下移 |
| | | private async void Down() |
| | | { |
| | | var vm = this.gridView1.GetCurrentViewModel(_allBindingList); |
| | | if (vm == null) |
| | | { |
| | | return; |
| | | } |
| | | var rowHandle = this.gridView1.FocusedRowHandle; |
| | | if (rowHandle == _allBindingList.Count - 1) |
| | | { |
| | | TipFormHelper.ShowWarn("下移失败!"); |
| | | return; |
| | | } |
| | | var current = this.gridView1.GetRow(rowHandle) as AssetsPumpMainViewModel; |
| | | if (current == null) |
| | | { |
| | | return; |
| | | } |
| | | var nextHandle = rowHandle + 1; |
| | | var next = this.gridView1.GetRow(nextHandle) as AssetsPumpMainViewModel; |
| | | if (next == null) |
| | | { |
| | | return; |
| | | } |
| | | var sorters = new List<Yw.Vmo.Sorter>(); |
| | | sorters.Add(new Yw.Vmo.Sorter() { ID = current.ID, SortCode = next.SortCode }); |
| | | sorters.Add(new Yw.Vmo.Sorter() { ID = next.ID, SortCode = current.SortCode }); |
| | | var bol = await BLLFactory<HStation.BLL.AssetsPumpMain>.Instance.UpdateSorter(sorters); |
| | | if (!bol) |
| | | { |
| | | TipFormHelper.ShowError("下移失败!"); |
| | | return; |
| | | } |
| | | var sortCode = current.SortCode; |
| | | current.SortCode = next.SortCode; |
| | | next.SortCode = sortCode; |
| | | _allBindingList = _allBindingList.OrderBy(x => x.SortCode).ToList(); |
| | | this.currentViewModelBindingSource.DataSource = _allBindingList; |
| | | this.currentViewModelBindingSource.ResetBindings(false); |
| | | this.gridView1.FocusedRowHandle = nextHandle; |
| | | } |
| | | |
| | | private void barBtnSearch_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | this.gridView1.OptionsFind.AlwaysVisible = !this.gridView1.OptionsFind.AlwaysVisible; |
| | | } |
| | | |
| | | //刷新 |
| | | private void barBtnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | var seriesId = this.AssetsPumpSeriesTreeListCtrl1.GetFocusID(out bool isGroup); |
| | | AssetsPumpSeriesTreeListCtrl1_FocusedChangedEvent(seriesId, isGroup); |
| | | } |
| | | } |
| | | } |