/// <summary> /// 创建/更新PO单关联发票 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, RoutedEventArgs e) { if (vm.VendorSysNo == null) { Window.Alert(ResInvoiceInputMaintain.Msg_ValidateVendor); return; } if (vm.POItemList.Count == 0) { Window.Alert(ResInvoiceInputMaintain.Msg_NoPOItems); return; } if (vm.InvoiceItemList.Count == 0) { Window.Alert(ResInvoiceInputMaintain.Msg_NoInvItems); return; } if (vm.DiffTaxTreatmentType == null) { Window.Alert(ResInvoiceInputMaintain.Msg_NeedDiffCal); return; } if (!Compare(vm, lastVM)) { Window.Alert(ResInvoiceInputMaintain.Msg_NeedReDiffCal); return; } //只录入选中的单据 vm.POItemList = vm.POItemList.Where(p => p.IsChecked).ToList(); vm.InvoiceItemList = vm.InvoiceItemList.Where(p => p.IsChecked).ToList(); APInvoiceInfo data = vm.ConvertVM <InvoiceInputMaintainVM, APInvoiceInfo>(); data.CompanyCode = CPApplication.Current.CompanyCode; if (vm.SysNo > 0) { facade.UpdateApInvoiceInfo(data, (obj, args) => { Window.Alert(ResInvoiceInputMaintain.Msg_UpdateSuccess); }); } else { facade.CreateAPInvoice(data, (obj, args) => { Window.Alert(ResInvoiceInputMaintain.Msg_CreateSuccess); //vm.SysNo = args.Result.SysNo.Value; //vm.Status = APInvoiceMasterStatus.Origin; vm = new InvoiceInputMaintainVM(); this.Window.Refresh(); SetControlStatus(); }); } }
/// <summary> /// 录入InvoiceItem /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HyperlinkButton_InputInvoiceItem_Click(object sender, RoutedEventArgs e) { if (!ValidateInvInput()) { if (this.vm.ItemInvoiceAmt == null) { this.Text_ItemInvoiceAmt.Focus(); } return; } if (!vm.VendorSysNo.HasValue) { this.Text_InvoiceItemsStatistic.Foreground = RedBrush; this.Text_InvoiceItemsStatistic.Text = ResInvoiceInputMaintain.Msg_Tips + ResInvoiceInputMaintain.Msg_ValidateVendor; //Window.Alert(ResInvoiceInputMaintain.Msg_ValidateVendor); return; } APInvoiceItemInputEntity request = new APInvoiceItemInputEntity(); request.ItemsNoList = vm.InvoiceItemNoList; request.InvoiceDate = vm.InvoiceDate; request.InvoiceAmt = vm.ItemInvoiceAmt; request.VendorSysNo = vm.VendorSysNo; request.VendorName = vm.VendorName; request.CompanyCode = CPApplication.Current.CompanyCode; request.InvoiceItemList = vm.ConvertVM <InvoiceInputMaintainVM, APInvoiceInfo>().InvoiceItemList; facade.InputInvoiceItem(request, (obj, args) => { APInvoiceInfo info = new APInvoiceInfo(); info.InvoiceItemList = args.Result.invoiceItemList; InvoiceInputMaintainVM resultVM = info.Convert <APInvoiceInfo, InvoiceInputMaintainVM>(); vm.InvoiceItemList = resultVM.InvoiceItemList; if (!string.IsNullOrEmpty(args.Result.ErrorMsg)) { //Window.Alert(args.Result.ErrorMsg); this.Text_InvoiceItemsStatistic.Foreground = RedBrush; this.Text_InvoiceItemsStatistic.Text = args.Result.ErrorMsg; } else { this.Text_InvoiceItemsStatistic.Text = string.Empty; } if (vm.POItemList.Count > 0 && vm.InvoiceItemList.Count > 0) { btnDiffCalc.IsEnabled = true; } this.Text_InvoiceNo.Focus(); }); }
/// <summary> /// 录入PoItem /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HyperlinkButton_InputPoItem_Click(object sender, RoutedEventArgs e) { if (!ValidatePOInput()) { return; } APInvoiceItemInputEntity request = new APInvoiceItemInputEntity(); request.ItemsNoList = vm.POItemNoList; request.OrderType = vm.OrderType; request.VendorSysNo = vm.VendorSysNo; request.VendorName = vm.VendorName; request.CompanyCode = CPApplication.Current.CompanyCode; request.POItemList = vm.ConvertVM <InvoiceInputMaintainVM, APInvoiceInfo>().POItemList; facade.InputPoItem(request, (obj, args) => { APInvoiceInfo info = new APInvoiceInfo(); info.POItemList = args.Result.poItemList; info.VendorName = args.Result.VendorName; info.VendorSysNo = args.Result.VendorSysNo; InvoiceInputMaintainVM resultVM = info.Convert <APInvoiceInfo, InvoiceInputMaintainVM>(); vm.POItemList = resultVM.POItemList; vm.VendorSysNo = resultVM.VendorSysNo; vm.VendorName = resultVM.VendorName; if (!string.IsNullOrEmpty(args.Result.ErrorMsg)) { this.Text_POItemsStatistic.Foreground = RedBrush; this.Text_POItemsStatistic.Text = args.Result.ErrorMsg; //Window.Alert(args.Result.ErrorMsg); } else { this.Text_POItemsStatistic.Text = string.Empty; } if (vm.POItemList.Count > 0) { VendorPicker.IsEnabled = false; } else { VendorPicker.IsEnabled = true; } if (vm.POItemList.Count > 0 && vm.InvoiceItemList.Count > 0) { btnDiffCalc.IsEnabled = true; } }); }
private bool Compare(InvoiceInputMaintainVM c1, InvoiceInputMaintainVM c2) { if (c1 == c2) { return(true); } if (c1 == null || c2 == null || c1.POItemList.Count != c2.POItemList.Count || c1.InvoiceItemList.Count != c2.InvoiceItemList.Count) { return(false); } var poNoStr1 = string.Join(",", c1.POItemList.Select(p => p.PoNo.ToString() + p.PoAmt.Value.ToString()).OrderBy(x => x).ToArray()); var poNoStr2 = string.Join(",", c2.POItemList.Select(p => p.PoNo.ToString() + p.PoAmt.Value.ToString()).OrderBy(x => x).ToArray()); var inoNoStr1 = string.Join(",", c1.InvoiceItemList.Select(p => p.InvoiceNo.ToString() + p.InvoiceAmt.Value.ToString()).OrderBy(x => x).ToArray()); var inoNoStr2 = string.Join(",", c2.InvoiceItemList.Select(p => p.InvoiceNo.ToString() + p.InvoiceAmt.Value.ToString()).OrderBy(x => x).ToArray()); return((poNoStr1 + inoNoStr1) == (poNoStr2 + inoNoStr2)); }
public override void OnPageLoad(object sender, EventArgs e) { base.OnPageLoad(sender, e); facade = new InvoiceInputFacade(this); VerifyPermission(); if (!string.IsNullOrEmpty(this.Request.Param)) { int sysNo = 0; int.TryParse(this.Request.Param, out sysNo); facade.LoadAPInvoiceWithItemsBySysNo(sysNo, (obj, args) => { vm = args.Result.Convert <APInvoiceInfo, InvoiceInputMaintainVM>(); if (vm != null) { this.DataContext = vm; lastVM = Newegg.Oversea.Silverlight.Utilities.UtilityHelper.DeepClone <InvoiceInputMaintainVM>(vm); OperationControlStatusHelper.GetChildObjects <CheckBox>(DataGrid_POItem_Result, "chkbx_SelectAll")[0].IsChecked = true; CheckBox_Click(OperationControlStatusHelper.GetChildObjects <CheckBox>(DataGrid_POItem_Result, "chkbx_SelectAll")[0], null); //OperationControlStatusHelper.GetChildObjects<CheckBox>(DataGrid_POItem_Result, "chkbx_SelectAll")[0] OperationControlStatusHelper.GetChildObjects <CheckBox>(DataGrid_InvoiceItem_Result, "chkbx_SelectAll")[0].IsChecked = true; CheckBox_Click(OperationControlStatusHelper.GetChildObjects <CheckBox>(DataGrid_InvoiceItem_Result, "chkbx_SelectAll")[0], null); } else { Window.Alert(ResInvoiceInputMaintain.Msg_NoData); } SetControlStatus(); }); } else { this.DataContext = vm = new InvoiceInputMaintainVM(); vm.InvoiceDate = DateTime.Today; lastVM = Newegg.Oversea.Silverlight.Utilities.UtilityHelper.DeepClone <InvoiceInputMaintainVM>(vm); SetControlStatus(); } BuildValidateCondition(); }
/// <summary> /// 根据条件加载供应商未录入的POItems /// 1.必须选择供应商。 /// 2.可选条件--加载日期起始。 /// 3.加载时会保留原有页面中的数据--只会更新POItems表,且保留原表中的数据。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void HyperlinkButton_LoadPOItems_Click(object sender, RoutedEventArgs e) { if (!vm.VendorSysNo.HasValue) { Window.Alert(ResInvoiceInputMaintain.Msg_ValidateVendor); return; } APInvoiceItemInputEntity request = new APInvoiceItemInputEntity(); request.CompanyCode = CPApplication.Current.CompanyCode; request.VendorSysNo = vm.VendorSysNo; request.POItemList = vm.ConvertVM <InvoiceInputMaintainVM, APInvoiceInfo>().POItemList; request.PODateFrom = vm.PODateFrom; facade.LoadNotInputPOItems(request, (obj, args) => { APInvoiceInfo info = new APInvoiceInfo(); info.POItemList = args.Result; InvoiceInputMaintainVM resultVM = info.Convert <APInvoiceInfo, InvoiceInputMaintainVM>(); vm.POItemList = resultVM.POItemList; if (vm.POItemList.Count > 0) { VendorPicker.IsEnabled = false; this.Text_POItemsStatistic.Foreground = BlackBrush; this.Text_POItemsStatistic.Text = ResInvoiceInputMaintain.Msg_LoadSuccess; } else { VendorPicker.IsEnabled = true; Window.Alert(ResInvoiceInputMaintain.Msg_EmptyPoItems); } if (vm.POItemList.Count > 0 && vm.InvoiceItemList.Count > 0) { btnDiffCalc.IsEnabled = true; } }); }
/// <summary> /// 差异计算 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDiffCalc_Click(object sender, RoutedEventArgs e) { if (vm.POItemList.Where(p => p.IsChecked).Count() == 0 || vm.InvoiceItemList.Where(x => x.IsChecked).Count() == 0) { Window.Alert(ResInvoiceInputMaintain.Msg_ValidateSelectItems); return; } decimal totlePOAmtSum = 0; decimal totleInvoiceAmt = 0; decimal totleInvoiceTaxAmt = 0; vm.POItemList.Where(p => p.IsChecked).ForEach(p => { totlePOAmtSum += p.PoAmt ?? 0; }); vm.InvoiceItemList.Where(p => p.IsChecked).ForEach(p => { totleInvoiceAmt += p.InvoiceAmt ?? 0; totleInvoiceTaxAmt += p.InvoiceTaxAmt ?? 0; }); vm.InvoiceAmt = decimal.Round(totleInvoiceAmt, 2); vm.InvoiceTaxAmt = decimal.Round(totleInvoiceTaxAmt, 2); vm.DiffTaxAmt = decimal.Round(totlePOAmtSum - totleInvoiceAmt, 2); //根据不同的值设置差异类型的选中状态 if (vm.DiffTaxAmt < -10) { vm.DiffTaxTreatmentType = InvoiceDiffType.MultiInvoicingAndTaxDiff; } else if (vm.DiffTaxAmt >= -10 && vm.DiffTaxAmt < 0) { vm.DiffTaxTreatmentType = InvoiceDiffType.MultiInvoicingAndExpensing; } else if (vm.DiffTaxAmt == 0) { vm.DiffTaxTreatmentType = InvoiceDiffType.Coincident; } else if (vm.DiffTaxAmt > 0 && vm.DiffTaxAmt <= 10) { vm.DiffTaxTreatmentType = InvoiceDiffType.LessInvoicingAndExpensing; } else { vm.DiffTaxTreatmentType = InvoiceDiffType.LessInvoicingAndTaxDiff; } //根据isSelected排序 vm.POItemList = vm.POItemList .OrderByDescending(x => x.IsChecked) .OrderBy(x => x.OrderType) .ThenBy(x => x.PoBaselineDate).ToList(); vm.InvoiceItemList = vm.InvoiceItemList .OrderByDescending(x => x.IsChecked) .OrderBy(x => x.InvoiceNo) .ThenBy(x => x.InvoiceDate).ToList(); //差异为零时清除未选择项 if (vm.DiffTaxAmt == 0) { vm.POItemList = vm.POItemList.Where(p => p.IsChecked).ToList(); vm.InvoiceItemList = vm.InvoiceItemList.Where(p => p.IsChecked).ToList(); } //返回发票概况 var selectInvoiceList = vm.InvoiceItemList.Where(p => p.IsChecked).ToList(); vm.Memo = string.Format(ResInvoiceInputMaintain.Label_Memo , selectInvoiceList.Min(x => Convert.ToInt32(x.InvoiceNo)) , selectInvoiceList.Max(x => Convert.ToInt32(x.InvoiceNo)) , selectInvoiceList.Count); lastVM = Newegg.Oversea.Silverlight.Utilities.UtilityHelper.DeepClone <InvoiceInputMaintainVM>(vm); CheckBox_IsDataRight.IsEnabled = Text_DiffMemo.IsEnabled = true; vm.IsDataRight = false; btnSave.IsEnabled = btnSubmit.IsEnabled = false; }