| | |
| | | |
| | | private List<CurrentPartMainViewModel> _allBindingList = new List<CurrentPartMainViewModel>(); |
| | | |
| | | private AddPumpMainAndPartMapDto _partmap = null; |
| | | private Vmo.PumpMainAndPartMap _partmap = null; |
| | | |
| | | private AddPumpPartMainDto _pumpPart = null; |
| | | private Vmo.PumpPartMain _pumpPart = null; |
| | | |
| | | private long _catalogID; //分类ID |
| | | |
| | | private long _seriesID; //系列ID |
| | | |
| | | private List<PumpPropContentDto> _allPropList = null; |
| | | private List<Vmo.PumpPropContent> _allPropList = null; |
| | | |
| | | //回调事件 |
| | | public event Func<AddPumpPartMainDto, List<AddPumpPropContentDto>, AddPumpMainAndPartMapDto, Task<bool>> ReloadEvent; |
| | | public event Func<Vmo.PumpPartMain, List<Vmo.PumpPropContent>, Vmo.PumpMainAndPartMap, Task<bool>> ReloadEvent; |
| | | |
| | | //数据绑定 |
| | | public async void SetBindingData(PumpMainDto pumpMain) |
| | | public async void SetBindingData(Vmo.PumpMain pumpMain) |
| | | { |
| | | _bll = new BLL.PumpPartMain(); |
| | | var allpartlist = await _bll.GetByPumpMainID(pumpMain.ID); //获取所有产品 |
| | | var series = await new BLL.PumpSeries().GetByID(pumpMain.PumpSeriesID); //获取系列 |
| | | _pumpPart = new AddPumpPartMainDto(); |
| | | _pumpPart = new Vmo.PumpPartMain(); |
| | | _seriesID = series.ID; |
| | | _pumpPart.SeriesID = _seriesID; |
| | | if (allpartlist != null) |
| | |
| | | } |
| | | _catalogID = series.CatalogID; |
| | | _proplist = new List<PropGroupChoiceViewModel>(); |
| | | _partmap = new AddPumpMainAndPartMapDto(); |
| | | _partmap = new Vmo.PumpMainAndPartMap(); |
| | | _partmap.PumpID = pumpMain.ID; |
| | | _partmap.SeriesID = _seriesID; |
| | | this.ListBoxPart.DataSource = _allBindingList; |
| | |
| | | var vm = this.ListBoxPart.GetCurrentViewModel(_allBindingList); |
| | | if (vm == null) |
| | | return; |
| | | var updatepart = new UpdatePumpPartMainDto(); |
| | | var updatepart = new Vmo.PumpPartMain(); |
| | | updatepart.ID = vm.ID; |
| | | updatepart.Name = TextEditProductName.Text; |
| | | updatepart.NO = TextEditNo.Text; |
| | | updatepart.Code = TextEditProductCode.Text; |
| | | updatepart.SeriesID = _seriesID; |
| | | var updateproplist = new List<UpdatePumpPropContentDto>(); |
| | | var update = _allPropList.Select(x => x.Adapt<PumpPropContentDto, UpdatePumpPropContentDto>()).ToList(); |
| | | // var update = _allPropList.Select(x => x.Adapt<PumpPropContentDto, UpdatePumpPropContentDto>()).ToList(); |
| | | foreach (var item in _proplist) |
| | | { |
| | | update.Find(x => x.PropID == item.ID).PropValue = item.Value; |
| | | _allPropList.Find(x => x.PropID == item.ID).PropValue = item.Value; |
| | | } |
| | | if (await _bll.UpdateEx(updatepart, update)) |
| | | if (await _bll.UpdateEx(updatepart, _allPropList)) |
| | | { |
| | | vm.Reset(updatepart); |
| | | this.ListBoxPart.Refresh(); |
| | |
| | | _pumpPart.Name = TextEditProductName.Text; |
| | | _pumpPart.NO = TextEditNo.Text; |
| | | _pumpPart.Code = TextEditProductCode.Text; |
| | | var PumpPropContent = new List<AddPumpPropContentDto>(); |
| | | var PumpPropContent = new List<Vmo.PumpPropContent>(); |
| | | foreach (var item in _proplist) |
| | | { |
| | | PumpPropContent.Add(new AddPumpPropContentDto { PropID = item.ID, PropValue = item.Value, SeriesID = _pumpPart.SeriesID, MainID = _partmap.PumpID }); |
| | | PumpPropContent.Add(new Vmo.PumpPropContent { PropID = item.ID, PropValue = item.Value, SeriesID = _pumpPart.SeriesID, MainID = _partmap.PumpID }); |
| | | } |
| | | var id = await _bll.InsertEx(_pumpPart, PumpPropContent, _partmap); |
| | | if (id > 0) |