diff --git a/BBWY.Client/BBWY.Client.csproj b/BBWY.Client/BBWY.Client.csproj index 1e06a446..34fa3294 100644 --- a/BBWY.Client/BBWY.Client.csproj +++ b/BBWY.Client/BBWY.Client.csproj @@ -40,7 +40,8 @@ - + + diff --git a/BBWY.Client/Models/BillCorrection/BillModel.cs b/BBWY.Client/Models/BillCorrection/BillModel.cs new file mode 100644 index 00000000..afdfac25 --- /dev/null +++ b/BBWY.Client/Models/BillCorrection/BillModel.cs @@ -0,0 +1,20 @@ +namespace BBWY.Client.Models +{ + public class BillModel + { + public string BelongFileName { get; set; } + + /// + /// 账单号 + /// + public string BillNo { get; set; } + + /// + /// 账单费用 + /// + public decimal Amount { get; set; } + + + public BillCorrectionType BillType { get; set; } + } +} diff --git a/BBWY.Client/Models/Enums.cs b/BBWY.Client/Models/Enums.cs index 1e4a577e..f56d3139 100644 --- a/BBWY.Client/Models/Enums.cs +++ b/BBWY.Client/Models/Enums.cs @@ -126,6 +126,16 @@ 销售订单 = 2 } + /// + /// 账单矫正类型 + /// + public enum BillCorrectionType + { + 销售运费账单 = 0, + 入仓操作账单 = 1, + 出仓操作账单 = 2 + } + /// /// 资金类型 /// diff --git a/BBWY.Client/ViewModels/BillCoreection/BillCorrectionViewModel.cs b/BBWY.Client/ViewModels/BillCoreection/BillCorrectionViewModel.cs new file mode 100644 index 00000000..2d044a1f --- /dev/null +++ b/BBWY.Client/ViewModels/BillCoreection/BillCorrectionViewModel.cs @@ -0,0 +1,138 @@ +using BBWY.Client.Models; +using BBWY.Common.Models; +using GalaSoft.MvvmLight.Command; +using Microsoft.Win32; +using NPOI.HSSF.UserModel; +using NPOI.SS.UserModel; +using NPOI.XSSF.UserModel; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Windows; +using System.Windows.Input; + +namespace BBWY.Client.ViewModels +{ + public class BillCorrectionViewModel : BaseVM, IDenpendency + { + public GlobalContext GlobalContext { get; set; } + + public DateTime StartDate { get; set; } + + public DateTime EndDate { get; set; } + + /// + /// 销售运费快递账单文件列表 + /// + public ObservableCollection SaleFreightBillFileList { get; set; } + + /// + /// 销售运费账单列表 + /// + public List SaleFreightBillList { get; set; } + + /// + /// 导入快递账单 + /// + public ICommand ImportSaleFreightBillCommand { get; set; } + + public BillCorrectionViewModel() + { + SaleFreightBillFileList = new ObservableCollection(); + SaleFreightBillList = new List(); + StartDate = DateTime.Now.Date.AddDays((DateTime.Now.Day - 1) * -1).AddMonths(-1); + EndDate = StartDate.AddMonths(1).AddDays(-1); + + ImportSaleFreightBillCommand = new RelayCommand(ImportSaleFreightBill); + } + + private void ImportSaleFreightBill(string expressName) + { + var ofd = new OpenFileDialog() { Filter = "excel文件|*.xlsx;*.xls" }; + if (ofd.ShowDialog() != true) + return; + var fileName = ofd.FileName.Substring(ofd.FileName.LastIndexOf("\\") + 1); + var filePath = ofd.FileName; + if (SaleFreightBillFileList.Contains(fileName)) + { + MessageBox.Show("请勿重复导入快递账单", "导入快递账单"); + return; + } + IWorkbook xbook = null; + try + { + using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) + { + if (filePath.EndsWith(".xls")) + xbook = new HSSFWorkbook(fs); + else if (filePath.EndsWith(".xlsx")) + xbook = new XSSFWorkbook(fs); + } + using (xbook) + { + IList billModelList = null; + if (expressName == "YT") + { + billModelList = LoadYTSaleBillFile(xbook); + } + else if (expressName == "YZ") + { + billModelList = LoadYZSaleBillFile(xbook); + } + else if (expressName == "JD") + { + billModelList = LoadJDSaleBillFile(xbook); + } + if (billModelList != null && billModelList.Count() > 0) + { + SaleFreightBillList.AddRange(billModelList); + SaleFreightBillFileList.Add(fileName); + } + + + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "导入账单失败提示"); + return; + } + } + + private IList LoadYTSaleBillFile(IWorkbook xbook) + { + return null; + } + + /// + /// 读取邮政运费账单 + /// 验证邮件号和总邮资 + /// + /// + /// + private IList LoadYZSaleBillFile(IWorkbook xbook) + { + var sheet = xbook.GetSheetAt(0); + var waybillNoCellTitle = sheet.GetRow(0).GetCell(2); + if (waybillNoCellTitle == null || waybillNoCellTitle.StringCellValue != "邮件号") + throw new Exception("验证邮政快递账单失败-未读取到邮件号"); + var saleExpressFreight = sheet.GetRow(0).GetCell(8); + if (saleExpressFreight == null || saleExpressFreight.StringCellValue != "总邮资") + throw new Exception("验证邮政快递账单失败-未读取到总邮资"); + + var rowCount = sheet.LastRowNum; + for (var i = 1; i < rowCount; i++) + { + + } + return null; + } + + private IList LoadJDSaleBillFile(IWorkbook xbook) + { + return null; + } + } +} diff --git a/BBWY.Client/ViewModels/MainViewModel.cs b/BBWY.Client/ViewModels/MainViewModel.cs index 10d47e18..d9b2cc84 100644 --- a/BBWY.Client/ViewModels/MainViewModel.cs +++ b/BBWY.Client/ViewModels/MainViewModel.cs @@ -163,7 +163,8 @@ namespace BBWY.Client.ViewModels Name = "财务端", ChildList = new List() { - new MenuModel(){ Name="采购审计",Url="/Views/FinancialTerminal/ProcurementAudit.xaml" } + new MenuModel(){ Name="采购审计",Url="/Views/FinancialTerminal/ProcurementAudit.xaml" }, + new MenuModel(){ Name="费用矫正",Url="/Views/BillCorrection/BillCorrectionView.xaml" } } })); } diff --git a/BBWY.Client/ViewModels/ViewModelLocator.cs b/BBWY.Client/ViewModels/ViewModelLocator.cs index 3be03b25..4af4b660 100644 --- a/BBWY.Client/ViewModels/ViewModelLocator.cs +++ b/BBWY.Client/ViewModels/ViewModelLocator.cs @@ -117,5 +117,14 @@ namespace BBWY.Client.ViewModels return s.ServiceProvider.GetRequiredService(); } } + + public BillCorrectionViewModel BillCorrection + { + get + { + using var s = sp.CreateScope(); + return s.ServiceProvider.GetRequiredService(); + } + } } } diff --git a/BBWY.Client/Views/BillCorrection/BillCorrectionView.xaml b/BBWY.Client/Views/BillCorrection/BillCorrectionView.xaml new file mode 100644 index 00000000..75d19127 --- /dev/null +++ b/BBWY.Client/Views/BillCorrection/BillCorrectionView.xaml @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/BBWY.Client/Views/BillCorrection/BillCorrectionView.xaml.cs b/BBWY.Client/Views/BillCorrection/BillCorrectionView.xaml.cs new file mode 100644 index 00000000..e9830447 --- /dev/null +++ b/BBWY.Client/Views/BillCorrection/BillCorrectionView.xaml.cs @@ -0,0 +1,15 @@ +using System.Windows.Controls; + +namespace BBWY.Client.Views.BillCorrection +{ + /// + /// BillCorrectionView.xaml 的交互逻辑 + /// + public partial class BillCorrectionView : Page + { + public BillCorrectionView() + { + InitializeComponent(); + } + } +} diff --git a/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml b/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml index 8b6ccdfb..bee5025b 100644 --- a/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml +++ b/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml @@ -52,7 +52,7 @@ DisplayMemberPath="Name" SelectedItem="{Binding SelectedDepartment,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/> - @@ -72,7 +72,7 @@ - + @@ -88,8 +88,12 @@ - +