private void txtChangeCount_LostFocus(object sender, RoutedEventArgs e) { TextBox txt = sender as TextBox; if (null != txt && !txt.IsReadOnly) { int getInputChangeCount = 0; if (string.IsNullOrEmpty(txt.Text.Trim())) { Window.Alert(ResCostChangeNew.InfoMsg_ChangeCountNull); return; } CostChangeItemInfoVM getSelectedItemVM = txt.DataContext as CostChangeItemInfoVM; if (int.TryParse(txt.Text.Trim(), out getInputChangeCount)) { if (getInputChangeCount <= getSelectedItemVM.AvaliableQty && getInputChangeCount >= 0) { getSelectedItemVM.ChangeCount = getInputChangeCount.ToString(); CalcTotalDiffAmt(); } else { Window.Alert(ResCostChangeNew.InfoMsg_ChangeCountError); return; } } } }
private void txtNewPrice_LostFocus(object sender, RoutedEventArgs e) { TextBox txt = sender as TextBox; if (null != txt && !txt.IsReadOnly) { decimal getInputNewPrice = 0m; if (string.IsNullOrEmpty(txt.Text.Trim())) { Window.Alert(ResCostChangeNew.InfoMsg_NewPriceNull); return; } CostChangeItemInfoVM getSelectedItemVM = txt.DataContext as CostChangeItemInfoVM; if (decimal.TryParse(txt.Text.Trim(), out getInputNewPrice)) { if (getInputNewPrice > 0) { getSelectedItemVM.NewPrice = getInputNewPrice.ToString(); CalcTotalDiffAmt(); } else { Window.Alert(ResCostChangeNew.InfoMsg_NewPriceError); return; } } } }
/// <summary> /// 加载成本变价单信息 /// </summary> private void LoadCostChangeInfo() { serviceFacade.LoadCostChangeInfo(CostChangeSysNo, (obj, args) => { if (args.FaultsHandle() || args.Result == null) { return; } ChangeInfoVM = EntityConverter <CostChangeInfo, CostChangeInfoVM> .Convert(args.Result, (s, t) => { t.CCSysNo = s.SysNo; t.CompanyCode = s.CompanyCode; t.CostChangeBasicInfo.VendorSysNo = s.CostChangeBasicInfo.VendorSysNo; t.CostChangeBasicInfo.PMSysNo = s.CostChangeBasicInfo.PMSysNo; t.CostChangeBasicInfo.Memo = s.CostChangeBasicInfo.Memo; t.CostChangeBasicInfo.AuditMemo = s.CostChangeBasicInfo.AuditMemo; t.CostChangeBasicInfo.Status = s.CostChangeBasicInfo.Status; t.CostChangeBasicInfo.TotalDiffAmt = s.CostChangeBasicInfo.TotalDiffAmt; t.CostChangeItems = new List <CostChangeItemInfoVM>(); foreach (var item in s.CostChangeItems) { CostChangeItemInfoVM itemVM = item.Convert <CostChangeItemsInfo, CostChangeItemInfoVM>(); t.CostChangeItems.Add(itemVM); } }); this.DataContext = ChangeInfoVM; SetAccessControl(); this.gridItemListInfo.Bind(); this.lblTotalDiffAmt.Text = string.Format("变价总金额:{0}元", ChangeInfoVM.CostChangeBasicInfo.TotalDiffAmt); //ShowActionButton(consignSettleVM.Status.Value); }); }
private void btnAddItem_Click(object sender, RoutedEventArgs e) { if (!newChangeInfoVM.CostChangeBasicInfo.VendorSysNo.HasValue) { Window.Alert(ResCostChangeNew.AlertMsg_VendorEmpty); return; } if (!newChangeInfoVM.CostChangeBasicInfo.PMSysNo.HasValue) { Window.Alert(ResCostChangeNew.AlertMsg_PMEmpty); return; } CostChangeItemsQuery newCtrl = new CostChangeItemsQuery(newChangeInfoVM.CostChangeBasicInfo.VendorSysNo.Value, newChangeInfoVM.CostChangeBasicInfo.PMSysNo.Value); newCtrl.DialogHandler = Window.ShowDialog(ResCostChangeNew.Button_AddItem, newCtrl, (obj, args) => { if (args.DialogResult == DialogResultType.OK && args.Data != null) { List <CostItemInfoVM> IstAddedVM = new List <CostItemInfoVM>(); IstAddedVM = args.Data as List <CostItemInfoVM>; if (IstAddedVM.Count > 0) { CostChangeItemInfoVM existItemVM; foreach (CostItemInfoVM itemVM in IstAddedVM) { existItemVM = newChangeInfoVM.CostChangeItems.SingleOrDefault(i => i.ProductSysNo == itemVM.ProductSysNo.Value && i.POSysNo == itemVM.POSysNo.Value); if (existItemVM == null)//如不在列表中 { CostChangeItemInfoVM changeItem = new CostChangeItemInfoVM() { ItemSysNo = 0, ProductSysNo = itemVM.ProductSysNo.Value, ProductID = itemVM.ProductID, ProductName = itemVM.ProductName, POSysNo = itemVM.POSysNo.Value, OldPrice = itemVM.Cost.Value, NewPrice = itemVM.Cost.Value.ToString(), AvaliableQty = itemVM.AvaliableQty.Value, ChangeCount = "0", CompanyCode = itemVM.CompanyCode, IsCheckedItem = false, ItemActionStatus = ItemActionStatus.Add }; newChangeInfoVM.CostChangeItems.Add(changeItem); } } this.gridProductsListInfo.Bind(); } } }); }