/// <summary> /// 组织InvoiceInfoEntityViewList数据 /// </summary> private void BuildInvoiceInfoViewList() { for (int i = 0; i < totalCount; i++) { if (OldInvoiceInfoEntityViewList != null && OldInvoiceInfoEntityViewList.Count > i && OldInvoiceInfoEntityViewList[i].InvoiceInputNo == invoiceInputNoList[i]) { InvoiceInfoEntityViewList.Add(new EIMSInvoiceInfoEntityVM() { SysNo = (OldInvoiceInfoEntityViewList != null && OldInvoiceInfoEntityViewList.Count > i) ? OldInvoiceInfoEntityViewList[i].SysNo : 0, InvoiceInputNo = invoiceInputNoList[i], InvoiceDate = ChangeDateMode(invoiceInputDateList[i]), InvoiceInputAmount = Convert.ToDecimal(invoiceInputAmtList[i]), TaxRate = Convert.ToDecimal(cmbTax.SelectedValue), EIMSInvoiceInputExtendList = (OldInvoiceInfoEntityViewList != null && OldInvoiceInfoEntityViewList.Count > i) ? OldInvoiceInfoEntityViewList[i].EIMSInvoiceInputExtendList : InvoiceInputExtendViewList, VendorNumber = InvoicInputView.VendorNumber }); } else { InvoiceInfoEntityViewList.Add(new EIMSInvoiceInfoEntityVM() { SysNo = 0, InvoiceInputNo = invoiceInputNoList[i], InvoiceDate = ChangeDateMode(invoiceInputDateList[i]), InvoiceInputAmount = Convert.ToDecimal(invoiceInputAmtList[i]), TaxRate = Convert.ToDecimal(cmbTax.SelectedValue), EIMSInvoiceInputExtendList = InvoiceInputExtendViewList, VendorNumber = InvoicInputView.VendorNumber }); } } }
/// <summary> /// 防止两个异步方法同时执行,将录入发票代码提取出来 /// </summary> private void CreateInvoiceInput(List <EIMSInvoiceInfoEntityVM> invoiceInfoEntityList, List <EIMSInvoiceInfoEntityVM> editData) { facade.CreateEIMSInvoiceInput(invoiceInfoEntityList, (obj, args) => { if (args.FaultsHandle()) { return; } EIMSInvoiceResultVM result = args.Result.Convert <EIMSInvoiceResult, EIMSInvoiceResultVM>(); if (result.IsSucceed) { if (Type == "Input") { this.CurrentWindow.Alert(ResEIMSInvoiceEntry.Msg_InputSuccess); InvoiceInfoEntityViewList.Clear(); this.Dialog.ResultArgs.isForce = true; this.Dialog.Close(); } else if (Type == "Edit") { if (editData != null) { UpdateInvoiceInfo(editData); } } } else { this.CurrentWindow.Alert(result.Error); InvoiceInfoEntityViewList.Clear(); return; } }); }
private void UpdateInvoiceInfo(List <EIMSInvoiceInfoEntityVM> editData) { if (editData.Count > 0) { facade.UpdateEIMSInvoiceInput(editData, (obj, args) => { if (args.FaultsHandle()) { return; } if (args.Result.IsSucceed) { this.CurrentWindow.Alert(ResEIMSInvoiceEntry.Msg_EditSuccess); InvoiceInfoEntityViewList.Clear(); this.Dialog.ResultArgs.isForce = true; this.Dialog.Close(true); } else { this.CurrentWindow.Alert(args.Result.Error); InvoiceInfoEntityViewList.Clear(); } }); } }
/// <summary> /// 保存修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEdit_Click(object sender, RoutedEventArgs e) { List <EIMSInvoiceInfoEntityVM> old = InvoiceInfoView.OldEIMSList; if (InvoiceInfoEntityViewList == null) { InvoiceInfoEntityViewList = new List <EIMSInvoiceInfoEntityVM>(); } if (this.InvoiceInfoView.InvoiceInfoList.Count != OrginCount) { if (InvoiceInfoEntityView.EIMSInvoiceInputExtendList != null && InvoiceInfoEntityView.EIMSInvoiceInputExtendList.Count != 0) { for (int i = 0; i < InvoiceInfoEntityView.EIMSInvoiceInputExtendList.Count; i++) { if (this.InvoiceInfoView.InvoiceInfoList.Count != 0) { for (int j = 0; j < this.InvoiceInfoView.InvoiceInfoList.Count; j++) { if (this.InvoiceInfoView.InvoiceInfoList[j].InvoiceNumber != InvoiceInfoEntityView.EIMSInvoiceInputExtendList[i].InvoiceNumber) { InvoiceInfoEntityView.EIMSInvoiceInputExtendList[i].Status = -1; } } } else { InvoiceInfoEntityView.EIMSInvoiceInputExtendList[i].Status = -1; } } } } InvoiceInfoEntityViewList.Add(InvoiceInfoEntityView); decimal?totalInvoiceAmt = 0m; if (InvoiceInfoView.InvoiceInfoList != null && InvoiceInfoView.InvoiceInfoList.Count != 0) { for (int i = 0; i < InvoiceInfoView.InvoiceInfoList.Count; i++) { totalInvoiceAmt += InvoiceInfoView.InvoiceInfoList[i].InvoiceAmount; } if (InvoiceInfoEntityView.InvoiceInputAmount != totalInvoiceAmt) { this.CurrentWindow.Alert(ResEIMSInvoiceEntry.Msg_InvoiceInputAmountNoEquels); } else { UpdateCode(); } } else { UpdateCode(); } }
/// <summary> /// 预览按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPreview_Click(object sender, RoutedEventArgs e) { if (CehckEIMSInvoiceInputList()) { BuildInvoiceInfoViewList(); UCViewInvoice uc = new UCViewInvoice(InvoiceInfoEntityViewList, InvoicInputView, "Preview"); uc.Dialog = CurrentWindow.ShowDialog("发票信息预览", uc, (obj, args) => { InvoiceInfoEntityViewList.Clear(); }, new Size(700, 350)); } }
/// <summary> /// 确认按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnEdit_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(this.txtInvoiceAmt.Text) || string.IsNullOrEmpty(this.txtInvoiceInputSysNo.Text) || this.dpInvoiceInputDate.SelectedDate == null) { this.CurrentWindow.Alert(ResEIMSInvoiceEntry.Msg_InfoNotNull); } else { if (this.txtInvoiceInputSysNo.Text.Length != 8) { this.CurrentWindow.Alert(string.Format(ResEIMSInvoiceEntry.Msg_InvoiceInputCheck, this.txtInvoiceInputSysNo.Text)); } else { decimal invoiceAmt = 0m; if (Regex.IsMatch(this.txtInvoiceAmt.Text, @"(^\d+$)|(^\d+.\d+$)")) { invoiceAmt = Convert.ToDecimal(this.txtInvoiceAmt.Text); } if (invoiceAmt != Convert.ToDecimal(this.txtBillAmt.Text)) { this.CurrentWindow.Alert(ResEIMSInvoiceEntry.Msg_InvoiceInputAmountNoEquels); } else { BatchInvoiceInuputInfo(); facade.CreateEIMSInvoiceInput(InvoiceInfoEntityViewList, (obj, args) => { if (args.FaultsHandle()) { return; } if (args.Result.IsSucceed) { this.CurrentWindow.Alert(ResEIMSInvoiceEntry.Msg_InputSuccess); InvoiceInfoEntityViewList.Clear(); this.Dialog.ResultArgs.isForce = true; this.Dialog.Close(); } else { this.CurrentWindow.Alert(ResEIMSInvoiceEntry.Msg_InputFailed); } }); } } } }
//查看 void UCViewInvoice_Loaded(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(InvoiceNumber)) { facade.QueryInvoiceList(InvoiceNumber, (obj, args) => { if (args.FaultsHandle()) { return; } if (args.Result.EIMSList.Convert <EIMSInvoiceInfoEntity, EIMSInvoiceInfoEntityVM>().Count > 1) { this.gridOnlyOneInvoice.Visibility = System.Windows.Visibility.Collapsed; this.gridOneToInvoices.Visibility = System.Windows.Visibility.Visible; this.InvoiceEntryView = args.Result.InvoiceInfoList.Convert <EIMSInvoiceEntryInfo, EIMSInvoiceEntryVM>()[0]; this.spOneToInvoicesResult.DataContext = InvoiceEntryView; InvoiceInfoEntityViewList = args.Result.EIMSList.Convert <EIMSInvoiceInfoEntity, EIMSInvoiceInfoEntityVM>(); decimal?totalInvoiceInputAmount = 0; //添加合计行 for (int i = 0; i < InvoiceInfoEntityViewList.Count; i++) { totalInvoiceInputAmount += InvoiceInfoEntityViewList[i].InvoiceInputAmount; if (i == InvoiceInfoEntityViewList.Count - 1) { InvoiceInfoEntityViewList.Add(new EIMSInvoiceInfoEntityVM() { Index = "合计", InvoiceInputAmount = totalInvoiceInputAmount }); break; } } this.dgOneToInvoicesQueryResult.ItemsSource = InvoiceInfoEntityViewList; } else { this.gridOnlyOneInvoice.Visibility = System.Windows.Visibility.Visible; this.gridOneToInvoices.Visibility = System.Windows.Visibility.Collapsed; this.InvoiceInfoView = args.Result.Convert <EIMSInvoiceInfo, EIMSInvoiceInfoVM>(); this.InvoiceInfoEntityView = invoiceInfoView.EIMSList[0]; this.spOnlyOneInvoiceResult.DataContext = InvoiceInfoEntityView; OrginCount = InvoiceInfoView.InvoiceInfoList.Count; this.dgOnlyOneInvoiceQueryResult.ItemsSource = InvoiceInfoView.InvoiceInfoList; } }); } }
/// <summary> /// 预览 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void UCViewInvoicePreview_Loaded(object sender, RoutedEventArgs e) { this.gridOnlyOneInvoice.Visibility = System.Windows.Visibility.Collapsed; this.gridOneToInvoices.Visibility = System.Windows.Visibility.Visible; this.spOneToInvoicesResult.DataContext = InvoiceEntryView; decimal?totalInvoiceInputAmount = 0; //添加合计行 for (int i = 0; i < InvoiceInfoEntityViewList.Count; i++) { totalInvoiceInputAmount += InvoiceInfoEntityViewList[i].InvoiceInputAmount; if (i == InvoiceInfoEntityViewList.Count - 1) { InvoiceInfoEntityViewList.Add(new EIMSInvoiceInfoEntityVM() { Index = "合计", InvoiceInputAmount = totalInvoiceInputAmount }); break; } } this.dgOneToInvoicesQueryResult.ItemsSource = InvoiceInfoEntityViewList; }