public async void GetSelectStock(BillTypeEnum btype, Action <PopData> call) { var _dialogView = new PopRadioButtonPage("选择库存", "", async() => { var results = await _wareHousesService.GetWareHousesAsync(btype, force: this.ForceRefresh); if (results != null && results.Any()) { var popDatas = results?.Select(s => { return(new PopData { Id = s?.Id ?? 0, Column = s?.Name }); })?.ToList(); return(popDatas); } else { return(null); } }); _dialogView.Completed += (sender, result) => { try { if (result != null) { call?.Invoke(result); } } catch (Exception ex) { Crashes.TrackError(ex); } }; await PopupNavigation.Instance.PushAsync(_dialogView); }
public async Task <PopData> GetRadioButtonResultAsync(string title, string message, Func <Task <List <PopData> > > func) { var tcs = new TaskCompletionSource <PopData>(TaskCreationOptions.AttachedToParent); try { //单选框视图 IPopupNavigation var _dialogView = new PopRadioButtonPage(title, message, func); _dialogView.Completed += async(sender, e) => { try { if (PopupNavigation.Instance?.PopupStack?.Count > 0) { await PopupNavigation.Instance.PopAllAsync(); } tcs.TrySetResult(e); } catch (Exception ex) { } }; if (_dialogView != null) { await PopupNavigation.Instance.PushAsync(_dialogView); } } catch (InvalidOperationException) { tcs.TrySetResult(new PopData()); } catch (Exception) { tcs.TrySetResult(new PopData()); } return(await tcs.Task); }
public override void OnNavigatedTo(INavigationParameters parameters) { base.OnNavigatedTo(parameters); if (CompanySetting != null && CompanySetting.OpenBillMakeDate == 2 && (ReferencePage.Equals("SaleBillPage") || ReferencePage.Equals("SaleOrderBillPage"))) { IsEditPrduceDate = true; } else { IsEditPrduceDate = false; } //获取选择的商品回传 if (parameters.ContainsKey("Products")) { parameters.TryGetValue("Products", out List <ProductModel> products); //类型标识 int pId = 0; //枚举标识 int pTId = 0; var pArry = Settings.DefaultPricePlan.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries).Select(p => int.Parse(p)).ToList(); if (pArry.Count > 0) { pId = pArry[0]; pTId = pArry[1]; } //层次价格 products.ForEach(product => { var sprice = product.SmallProductPrices; var bprice = product.BigProductPrices; switch (pTId) { case (int)PriceType.ProductCost: { //进价 if (sprice != null) { product.SmallPriceUnit.Price = sprice.PurchasePrice ?? 0; } if (bprice != null) { product.BigPriceUnit.Price = bprice.PurchasePrice ?? 0; } } break; case (int)PriceType.CostPrice: { //成本价 if (sprice != null) { product.SmallPriceUnit.Price = sprice.CostPrice ?? 0; } if (bprice != null) { product.BigPriceUnit.Price = bprice.CostPrice ?? 0; } } break; case (int)PriceType.WholesalePrice: { //批发价格 if (sprice != null) { product.SmallPriceUnit.Price = sprice.TradePrice ?? 0; } if (bprice != null) { product.BigPriceUnit.Price = bprice.TradePrice ?? 0; } } break; case (int)PriceType.RetailPrice: { //零售价格 if (sprice != null) { product.SmallPriceUnit.Price = sprice.RetailPrice ?? 0; } if (bprice != null) { product.BigPriceUnit.Price = bprice.RetailPrice ?? 0; } } break; case (int)PriceType.LowestPrice: { //最低售价 if (sprice != null) { product.SmallPriceUnit.Price = sprice.FloorPrice ?? 0; } if (bprice != null) { product.BigPriceUnit.Price = bprice.FloorPrice ?? 0; } } break; case (int)PriceType.CustomPlan: { //方案价格 var price = product.ProductTierPrices.Where(s => s.PriceTypeId == pTId && s.PricesPlanId == pId).FirstOrDefault(); if (price != null) { product.SmallPriceUnit.Price = price.SmallUnitPrice ?? 0; product.BigPriceUnit.Price = price.BigUnitPrice ?? 0; } } break; case (int)PriceType.LastedPrice: { //上次价格 var price = product.ProductTierPrices.Where(s => s.PriceTypeId == pTId).FirstOrDefault(); if (price != null) { product.SmallPriceUnit.Price = price.SmallUnitPrice ?? 0; product.BigPriceUnit.Price = price.BigUnitPrice ?? 0; } } break; } product.RemarkSelected = ReactiveCommand.Create <UProduct>(async e => { var _dialogView = new PopRadioButtonPage("选择备注", "", async() => { var _settingService = App.Resolve <ISettingService>(); var result = await _settingService.GetRemarkConfigListSetting(); var popDatas = result?.Select(s => { return(new PopData { Id = s.Key, Column = s.Value, Selected = false }); })?.ToList(); return(popDatas); }); _dialogView.Completed += (sender, result) => { try { if (result != null) { RemarkConfig.Id = result.Id; RemarkConfig.Name = result.Column; e.Remark = result.Column; } } catch (Exception ex) { Crashes.TrackError(ex); } }; await PopupNavigation.Instance.PushAsync(_dialogView); }); }); ProductSeries = new ObservableCollection <ProductModel>(products); } }
public async void CalcSmallPrice(int porductId) { try { var product = ProductSeries.Where(p => p.Id == porductId).Select(p => p).FirstOrDefault(); var _dialogView = new PopRadioButtonPage("选择价格", "", () => { var popDatas = new List <PopData>(); if (product != null) { var tierprices = product.ProductTierPrices; if (tierprices != null) { #region //默认条件 int pId = 0; int pTId = 0; var pArry = Settings.DefaultPricePlan.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries).Select(p => int.Parse(p)).ToList(); if (pArry.Count > 0) { pId = pArry[0]; pTId = pArry[1]; } switch (pTId) { case (int)PriceType.ProductCost: { var price = tierprices.FirstOrDefault(s => s.PriceTypeId == 0); popDatas.Add(new PopData() { Id = (int)PriceType.ProductCost, Column = "进价", Column1 = price?.SmallUnitPrice.ToString(), Column1Enable = true, Data = price?.SmallUnitPrice ?? 0 }); } break; case (int)PriceType.CostPrice: { //成本价 var price = tierprices.FirstOrDefault(s => s.PriceTypeId == 5); popDatas.Add(new PopData() { Id = (int)PriceType.CostPrice, Column = "成本价", Column1 = price?.SmallUnitPrice.ToString(), Column1Enable = true, Data = price?.SmallUnitPrice ?? 0 }); } break; case (int)PriceType.WholesalePrice: { //批发价格 var price = tierprices.FirstOrDefault(s => s.PriceTypeId == 1); popDatas.Add(new PopData() { Id = (int)PriceType.WholesalePrice, Column = "批发价格", Column1 = price?.SmallUnitPrice.ToString(), Column1Enable = true, Data = price?.SmallUnitPrice ?? 0 }); } break; case (int)PriceType.RetailPrice: { //零售价格 var price = tierprices.FirstOrDefault(s => s.PriceTypeId == 2); popDatas.Add(new PopData() { Id = (int)PriceType.RetailPrice, Column = "零售价格", Column1 = price?.SmallUnitPrice.ToString(), Column1Enable = true, Data = price?.SmallUnitPrice ?? 0 }); } break; case (int)PriceType.LowestPrice: { //最低售价 var price = tierprices.FirstOrDefault(s => s.PriceTypeId == 3); popDatas.Add(new PopData() { Id = (int)PriceType.LowestPrice, Column = "最低售价", Column1 = price?.SmallUnitPrice.ToString(), Column1Enable = true, Data = price?.SmallUnitPrice ?? 0 }); } break; case (int)PriceType.CustomPlan: { //方案价格 int i = 0; foreach (var price in tierprices.Where(s => new int[] { (int)PriceType.CustomPlan }.Contains(s.PriceTypeId)).ToList()) { popDatas.Add(new PopData() { Id = (int)PriceType.CustomPlan + i, Column = price?.PriceTypeName, Column1 = price?.SmallUnitPrice.ToString(), Column1Enable = true, Data = price?.SmallUnitPrice ?? 0 }); i++; } } break; case (int)PriceType.LastedPrice: { //上次价格 var price = product.ProductTierPrices.Where(s => s.PriceTypeId == (int)PriceType.LastedPrice).FirstOrDefault(); if (price != null) { popDatas.Add(new PopData() { Id = (int)PriceType.CustomPlan, Column = "上次价格", Column1 = price?.SmallUnitPrice.ToString(), Column1Enable = true, Data = price?.SmallUnitPrice ?? 0 }); } } break; } #endregion } } return(Task.FromResult(popDatas)); }); _dialogView.Completed += (sender, result) => { if (result != null) { product.SmallPriceUnit.Price = (decimal)(result?.Data ?? decimal.Zero); product.SmallPriceUnit.Amount = (decimal)(result?.Data ?? decimal.Zero) * product?.SmallPriceUnit?.Quantity ?? 0; } }; await PopupNavigation.Instance.PushAsync(_dialogView); } catch (Exception ex) { Crashes.TrackError(ex); } }
public override void OnNavigatedTo(INavigationParameters parameters) { base.OnNavigatedTo(parameters); try { if (CompanySetting != null && CompanySetting.OpenBillMakeDate == 2 && (ReferencePage.Equals("SaleBillPage") || ReferencePage.Equals("SaleOrderBillPage"))) { IsEditPrduceDate = true; } else { IsEditPrduceDate = false; } //编辑商品回传 if (parameters.ContainsKey("Product")) { //商品 parameters.TryGetValue("Product", out ProductModel p); if (p != null) { p.RemarkSelected2 = ReactiveCommand.Create <ProductModel>(async e => { var _dialogView = new PopRadioButtonPage("选择备注", "", async() => { var _settingService = App.Resolve <ISettingService>(); var result = await _settingService.GetRemarkConfigListSetting(); var popDatas = result?.Select(s => { return(new PopData { Id = s.Key, Column = s.Value, Selected = false }); })?.ToList(); return(popDatas); }); _dialogView.Completed += (sender, result) => { try { if (result != null) { p.Remark = result.Column; } } catch (Exception ex) { Crashes.TrackError(ex); } }; await PopupNavigation.Instance.PushAsync(_dialogView); }); //当前仓库名称 p.CurWareHouseName = WareHouse.Name; //库存量转化 p.UsableQuantityConversion = p.FormatQuantity(p.UsableQuantity ?? 0); p.CurrentQuantityConversion = p.FormatQuantity(p.CurrentQuantity ?? 0); p.OrderQuantityConversion = p.FormatQuantity(p.OrderQuantity ?? 0); p.LockQuantityConversion = p.FormatQuantity(p.LockQuantity ?? 0); Product = p; this.OldProductQuantity = p.Quantity; } //项目 if (ReferencePage.Equals("SaleOrderBillPage")) { parameters.TryGetValue("Item", out SaleReservationItemModel item); if (item != null) { // } } else if (ReferencePage.Equals("ExchangeBillPage")) { parameters.TryGetValue("Item", out ExchangeItemModel item); if (item != null) { // } } else if (ReferencePage.Equals("PurchaseOrderBillPage")) { parameters.TryGetValue("Item", out PurchaseItemModel item); if (item != null) { // } } else if (ReferencePage.Equals("ReturnBillPage")) { parameters.TryGetValue("Item", out ReturnItemModel item); if (item != null) { // } } else if (ReferencePage.Equals("ReturnOrderBillPage")) { parameters.TryGetValue("Item", out ReturnReservationItemModel item); if (item != null) { // } } else if (ReferencePage.Equals("SaleOrderBillPage")) { parameters.TryGetValue("Item", out SaleReservationItemModel item); if (item != null) { // } } } } catch (Exception ex) { Crashes.TrackError(ex); } }