| | |
| | | using HStation.WinFrmUI.Xhs.PumpProduct; |
| | | using DevExpress.XtraEditors; |
| | | using HStation.WinFrmUI.Xhs.PumpProduct; |
| | | using Mapster; |
| | | |
| | | namespace HStation.WinFrmUI |
| | |
| | | { |
| | | InitializeComponent(); |
| | | this.gridView1.Columns["PropGroupName"].Group(); |
| | | ListBoxPart.DisplayMember = "Name"; |
| | | ListBoxPart.ValueMember = "ID"; |
| | | } |
| | | |
| | | private BLL.PumpPartMain _bll = null; |
| | | private List<PropGroupChoiceViewModel> _proplist = null; |
| | | |
| | | private List<CurrentPartMainViewModel> _allBindingList = new List<CurrentPartMainViewModel>(); |
| | | |
| | | private AddPumpMainAndPartMapDto _partmap = null; |
| | |
| | | public event Func<AddPumpPartMainDto, List<AddPumpPropContentDto>, AddPumpMainAndPartMapDto, Task<bool>> ReloadEvent; |
| | | |
| | | //数据绑定 |
| | | public async void SetBindingData(long pumpID) |
| | | public async void SetBindingData(PumpMainDto pumpMain) |
| | | { |
| | | _bll = new BLL.PumpPartMain(); |
| | | var alllist = await _bll.GetByPumpMainID(pumpID); |
| | | var series = await new BLL.PumpSeries().GetByID(alllist.First().SeriesID); |
| | | var allpartlist = await _bll.GetByPumpMainID(pumpMain.ID); //获取所有产品 |
| | | var series = await new BLL.PumpSeries().GetByID(pumpMain.PumpSeriesID); //获取系列 |
| | | _pumpPart = new AddPumpPartMainDto(); |
| | | _seriesID = series.ID; |
| | | _pumpPart.SeriesID = _seriesID; |
| | | foreach (var item in alllist) |
| | | if (allpartlist != null) |
| | | { |
| | | var model = new CurrentPartMainViewModel(item); |
| | | _allBindingList.Add(model); |
| | | foreach (var item in allpartlist) |
| | | { |
| | | var model = new CurrentPartMainViewModel(item); |
| | | _allBindingList.Add(model); |
| | | } |
| | | } |
| | | _catalogID = series.CatalogID; |
| | | _proplist = new List<PropGroupChoiceViewModel>(); |
| | | _partmap = new AddPumpMainAndPartMapDto(); |
| | | _partmap.PumpID = pumpID; |
| | | _partmap.PumpID = pumpMain.ID; |
| | | _partmap.SeriesID = _seriesID; |
| | | this.treeListPart.DataSource = _allBindingList; |
| | | this.treeListPart.RefreshDataSource(); |
| | | this.ListBoxPart.DataSource = _allBindingList; |
| | | this.ListBoxPart.Refresh(); |
| | | this.propGroupChoiceViewModelBindingSource.DataSource = _proplist; |
| | | this.propGroupChoiceViewModelBindingSource.ResetBindings(false); |
| | | } |
| | | |
| | | //分类选择变换 |
| | | private async void SetPropSelectedValue(CurrentPartMainViewModel viewmodel) |
| | | private async void SetPropSelectedValue(CurrentPartMainViewModel partmain) |
| | | { |
| | | this.gridView1.ExpandAllGroups(); |
| | | this.TextEditNo.Text = viewmodel.NO.Trim(); |
| | | this.TextEditProductCode.Text = viewmodel.Code.Trim(); |
| | | this.TextEditProductName.Text = viewmodel.Name.Trim(); |
| | | var model = await _bll.GetByID(partmain.ID); |
| | | if (model == null) return; |
| | | this.TextEditNo.Text = partmain.NO.Trim(); |
| | | this.TextEditProductCode.Text = partmain.Code.Trim(); |
| | | this.TextEditProductName.Text = partmain.Name.Trim(); |
| | | _proplist.Clear(); |
| | | var bll = new Yw.BLL.SysPropStruct(); |
| | | var catlog = await bll.GetByCatalogID(_catalogID); |
| | |
| | | } |
| | | } |
| | | var propbll = new BLL.PumpPartPropContent(); |
| | | var alllist = await propbll.GetByPumpPartID(viewmodel.ID); |
| | | var alllist = await propbll.GetByPumpPartID(model.ID); |
| | | _allPropList = alllist; |
| | | foreach (var item in alllist) |
| | | { |
| | |
| | | } |
| | | |
| | | //产品列表聚焦改变 |
| | | private void treeListPart_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) |
| | | private void ListBoxPart_SelectedIndexChanged(object sender, EventArgs e) |
| | | { |
| | | var vm = this.treeListPart.GetCurrentViewModel(_allBindingList); |
| | | if (vm == null) return; |
| | | var vm = this.ListBoxPart.GetCurrentViewModel(_allBindingList); |
| | | if (vm == null) |
| | | return; |
| | | SetPropSelectedValue(vm); |
| | | } |
| | | |
| | | //确认编辑 |
| | | private async void BtnOk_Click(object sender, EventArgs e) |
| | | { |
| | | var vm = this.treeListPart.GetCurrentViewModel(_allBindingList); |
| | | if (vm == null) return; |
| | | var vm = this.ListBoxPart.GetCurrentViewModel(_allBindingList); |
| | | if (vm == null) |
| | | return; |
| | | var updatepart = new UpdatePumpPartMainDto(); |
| | | updatepart.ID = vm.ID; |
| | | updatepart.Name = TextEditProductName.Text; |
| | |
| | | if (await _bll.UpdateEx(updatepart, update)) |
| | | { |
| | | vm.Reset(updatepart); |
| | | this.treeListPart.Refresh(); |
| | | this.ListBoxPart.Refresh(); |
| | | MessageBoxHelper.ShowSuccess("修改成功!"); |
| | | } |
| | | else |
| | |
| | | } |
| | | |
| | | //左侧树右击菜单事件 |
| | | private void treeListPart_MouseUp(object sender, MouseEventArgs e) |
| | | private void ListBoxPart_MouseUp(object sender, MouseEventArgs e) |
| | | { |
| | | if (e.Button == MouseButtons.Right) |
| | | { |
| | | if (this.gridView1.GetCurrentViewModel(_allBindingList) != null) |
| | | { |
| | | Point screenPoint = Cursor.Position; |
| | | popupPumpPartMenu.ShowPopup(screenPoint); |
| | | } |
| | | Point screenPoint = Cursor.Position; |
| | | popupPumpPartMenu.ShowPopup(screenPoint); |
| | | } |
| | | } |
| | | |
| | |
| | | var pumppart = await _bll.GetByID(id); |
| | | |
| | | _allBindingList.Add(new CurrentPartMainViewModel(pumppart)); |
| | | this.treeListPart.RefreshDataSource(); |
| | | this.ListBoxPart.Refresh(); |
| | | MessageBoxHelper.ShowSuccess("添加成功!"); |
| | | } |
| | | else |
| | |
| | | MessageBoxHelper.ShowError("添加失败!"); |
| | | } |
| | | } |
| | | |
| | | #region 菜单功能 |
| | | |
| | | //添加产品 |
| | | private void BarBtnAddPumpPart_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | } |
| | | |
| | | // 删除产品 |
| | | private async void BarBtnDeletePart_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) |
| | | { |
| | | var vm = this.ListBoxPart.GetCurrentViewModel(_allBindingList); |
| | | if (vm == null) |
| | | return; |
| | | if (!MessageBoxHelper.IsClickOk("确定删除数据行")) |
| | | { |
| | | if (await _bll.DeleteEx(vm.ID)) |
| | | { |
| | | _allBindingList.Remove(vm); |
| | | this.ListBoxPart.Refresh(); |
| | | MessageBoxHelper.ShowSuccess("删除成功!"); |
| | | } |
| | | else |
| | | { |
| | | MessageBoxHelper.ShowError("删除失败!"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion 菜单功能 |
| | | } |
| | | } |