protected override void SubscribeEvent() { View.Loading += View_Loading; View.Save += async() => await SaveAsync(); View.SelectionNomenclature += () => { JournalsForm journal = new JournalsForm(); JournalsPresenter <Nomenclature> presenter = new JournalsPresenter <Nomenclature>(journal, new NomenclatureJournal(journal.Grid, TypeNomernclature.Good)); journal.ShowDialog(); if (presenter.Info != null) { NomenclatureModel nomenclature = (NomenclatureModel)presenter.Info; _numberNomenclature = nomenclature.Number; View.Nomenclature = nomenclature.ShortName; View.Price = nomenclature.Price; CalculateSum(); } }; View.CalculateSum += CalculateSum; }
internal override async Task <object> GetInfo() { NomenclatureModel nomenclature = null; try { using (var context = new DbSSContext()) { var result = await context.Nomenclature.Where(n => n.Number == Item.Number).Select(n => new { n.Number, n.ShortName, n.Price }).FirstAsync(); nomenclature = new NomenclatureModel { Number = result.Number, ShortName = result.ShortName, Price = result.Price }; } } catch (Exception ex) { ShowError(ex.Message); } return(nomenclature); }
public Nomenclature(NomenclatureModel nomenclatureModel) { Uid = nomenclatureModel.Uid; Name = nomenclatureModel.Name; Artikul = nomenclatureModel.Artikul; BaseUnit = nomenclatureModel.BaseUnit; NomenclaturesKind = nomenclatureModel.NomenclaturesKind; }
public NomenclatureItemPage(INavigation Navigation = null, NomenclatureModel nomenclature = null) { InitializeComponent(); var vm = new NomenclatureItemViewModel(nomenclature); vm.Navigation = Navigation; BindingContext = vm; CurrentPageChanged += CurrentPageChangedFoo; }
protected override void SubscribeEvent() { View.Loading += View_Loading; View.Save += async() => await SaveAsync(); View.SelectionNomenclature += () => { JournalsForm journal = new JournalsForm(); JournalsPresenter <Nomenclature> presenter = new JournalsPresenter <Nomenclature>(journal, new NomenclatureJournal(journal.Grid, TypeNomernclature.Work)); journal.ShowDialog(); if (presenter.Info != null) { NomenclatureModel nomenclature = (NomenclatureModel)presenter.Info; _numberNomenclature = nomenclature.Number; View.Nomenclature = nomenclature.ShortName; View.NormOfTime = nomenclature.Price; } }; View.SelectionWorkingHour += () => { JournalsForm journal = new JournalsForm(); JournalsPresenter <WorkingHour> presenter = new JournalsPresenter <WorkingHour>(journal, new WorkingHourJournal(journal.Grid)); journal.ShowDialog(); if (presenter.Info != null) { WorkingHourModel workingHour = (WorkingHourModel)presenter.Info; _workingHourID = workingHour.ID; _price = workingHour.Price; View.NameWorkingHour = workingHour.Name; View.PriceWorkingHour = GetPriceText(workingHour.Price); CalculateSum(); } }; View.CalculateSum += CalculateSum; }
protected override async Task SaveAsync() { try { var number = View.Number; var shortName = View.ShortName; var fullName = View.FullName; var type = View.Type; var vendorCode = View.VendorCode; var price = View.Price; var descriprion = View.Descriprion; if (string.IsNullOrWhiteSpace(shortName)) { throw new ArgumentNullException(null, "Вы не ввели краткое наименование номенклатуры!"); } if (_codeUnit == null) { throw new ArgumentNullException(null, "Вы не выбрали единицу измерения номенклатуры!"); } using (var context = new DbSSContext()) { if (Identifier != null) { await context.Nomenclature.Where(n => n.Number == (int)Identifier).UpdateAsync(n => new NomenclatureModel { ShortName = shortName, FullName = GetNullValue(fullName), Type = type, Code_unit = (int)_codeUnit, VendorCode = GetNullValue(vendorCode), Price = price, Descriprion = GetNullValue(descriprion) }); } else { NomenclatureModel insertNomenclatureInfo = new NomenclatureModel() { Number = number, ShortName = shortName, FullName = GetNullValue(fullName), Type = type, Code_unit = (int)_codeUnit, VendorCode = GetNullValue(vendorCode), Price = price, Descriprion = GetNullValue(descriprion) }; context.Nomenclature.Add(insertNomenclatureInfo); await context.SaveChangesAsync(); Identifier = insertNomenclatureInfo.Number; } } View.Close(); } catch (Exception ex) { ShowError(ex.Message); } }