9 changed files with 350 additions and 5 deletions
@ -0,0 +1,20 @@ |
|||
namespace BBWY.Client.Models |
|||
{ |
|||
public class BillModel |
|||
{ |
|||
public string BelongFileName { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 账单号
|
|||
/// </summary>
|
|||
public string BillNo { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 账单费用
|
|||
/// </summary>
|
|||
public decimal Amount { get; set; } |
|||
|
|||
|
|||
public BillCorrectionType BillType { get; set; } |
|||
} |
|||
} |
@ -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; } |
|||
|
|||
/// <summary>
|
|||
/// 销售运费快递账单文件列表
|
|||
/// </summary>
|
|||
public ObservableCollection<string> SaleFreightBillFileList { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 销售运费账单列表
|
|||
/// </summary>
|
|||
public List<BillModel> SaleFreightBillList { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 导入快递账单
|
|||
/// </summary>
|
|||
public ICommand ImportSaleFreightBillCommand { get; set; } |
|||
|
|||
public BillCorrectionViewModel() |
|||
{ |
|||
SaleFreightBillFileList = new ObservableCollection<string>(); |
|||
SaleFreightBillList = new List<BillModel>(); |
|||
StartDate = DateTime.Now.Date.AddDays((DateTime.Now.Day - 1) * -1).AddMonths(-1); |
|||
EndDate = StartDate.AddMonths(1).AddDays(-1); |
|||
|
|||
ImportSaleFreightBillCommand = new RelayCommand<string>(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<BillModel> 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<BillModel> LoadYTSaleBillFile(IWorkbook xbook) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 读取邮政运费账单
|
|||
/// <para>验证邮件号和总邮资</para>
|
|||
/// </summary>
|
|||
/// <param name="xbook"></param>
|
|||
/// <returns></returns>
|
|||
private IList<BillModel> 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<BillModel> LoadJDSaleBillFile(IWorkbook xbook) |
|||
{ |
|||
return null; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,147 @@ |
|||
<Page x:Class="BBWY.Client.Views.BillCorrection.BillCorrectionView" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:local="clr-namespace:BBWY.Client.Views.BillCorrection" |
|||
xmlns:c="clr-namespace:BBWY.Controls;assembly=BBWY.Controls" |
|||
xmlns:cmodel="clr-namespace:BBWY.Client.Models" xmlns:sys="clr-namespace:System;assembly=mscorlib" |
|||
mc:Ignorable="d" |
|||
DataContext="{Binding BillCorrection,Source={StaticResource Locator}}" |
|||
d:DesignHeight="1080" d:DesignWidth="1920" |
|||
Title="BillCorrectionView"> |
|||
<Page.Resources> |
|||
<ObjectDataProvider x:Key="storageTypeProvider" MethodName="GetValues" ObjectType="{x:Type sys:Enum}"> |
|||
<ObjectDataProvider.MethodParameters> |
|||
<x:Type TypeName="cmodel:StorageType"/> |
|||
</ObjectDataProvider.MethodParameters> |
|||
</ObjectDataProvider> |
|||
</Page.Resources> |
|||
<Grid> |
|||
<c:RoundWaitProgress Play="{Binding IsLoading}" Panel.ZIndex="999"/> |
|||
<Grid Margin="5,0"> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition Height="40"/> |
|||
<RowDefinition Height="5"/> |
|||
<RowDefinition Height="100"/> |
|||
<RowDefinition Height="5"/> |
|||
<RowDefinition Height="40"/> |
|||
<RowDefinition Height="5"/> |
|||
<RowDefinition/> |
|||
</Grid.RowDefinitions> |
|||
<Border Background="{StaticResource Border.Background}" Padding="5,0"> |
|||
<Border.Resources> |
|||
<ResourceDictionary> |
|||
<ResourceDictionary.MergedDictionaries> |
|||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml"/> |
|||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml"/> |
|||
</ResourceDictionary.MergedDictionaries> |
|||
</ResourceDictionary> |
|||
</Border.Resources> |
|||
<StackPanel Orientation="Horizontal"> |
|||
<DatePicker Height="30" Margin="5,0,0,0" SelectedDate="{Binding StartDate,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/> |
|||
<DatePicker Height="30" Margin="5,0,0,0" SelectedDate="{Binding EndDate,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/> |
|||
<c:BButton Content="查询" Margin="5,0,0,0" Padding="10,0" Command="{Binding SearchHistoryCommand}"/> |
|||
<c:BButton Content="矫正" Padding="10,0" Command="{Binding CorrectCommand}" Background="#02A7F0"/> |
|||
<c:BButton Content="清空" Padding="10,0" Command="{Binding ClearCommand}" Background="{StaticResource Text.Pink}"/> |
|||
</StackPanel> |
|||
</Border> |
|||
|
|||
<Grid Grid.Row="2"> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition Height="auto"/> |
|||
<RowDefinition Height="5"/> |
|||
<RowDefinition/> |
|||
</Grid.RowDefinitions> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="0.33*"/> |
|||
<ColumnDefinition Width="5"/> |
|||
<ColumnDefinition Width="0.33*"/> |
|||
<ColumnDefinition Width="5"/> |
|||
<ColumnDefinition Width="0.34*"/> |
|||
</Grid.ColumnDefinitions> |
|||
<TextBlock Text="快递账单"/> |
|||
<TextBlock Text="入仓账单" Grid.Column="2" /> |
|||
<TextBlock Text="出仓账单" Grid.Column="4"/> |
|||
|
|||
<Border BorderThickness="1" BorderBrush="{StaticResource Border.Brush}" |
|||
Grid.Row="2"> |
|||
<Grid Margin="5,0"> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition Height="0.5*"/> |
|||
<RowDefinition Height="0.5*"/> |
|||
</Grid.RowDefinitions> |
|||
<StackPanel Orientation="Horizontal"> |
|||
<c:BButton Content="邮政快递" Padding="10,0" |
|||
Background="White" BorderThickness="1" BorderBrush="{StaticResource Border.Brush}" |
|||
Foreground="{StaticResource Text.Color}" |
|||
Command="{Binding ImportSaleFreightBillCommand}" CommandParameter="YZ"/> |
|||
<c:BButton Content="圆通快递" Padding="10,0" Margin="5,0" |
|||
Background="White" BorderThickness="1" BorderBrush="{StaticResource Border.Brush}" |
|||
Foreground="{StaticResource Text.Color}" |
|||
Command="{Binding ImportSaleFreightBillCommand}" CommandParameter="YT"/> |
|||
<c:BButton Content="京东快递" Padding="10,0" |
|||
Background="White" BorderThickness="1" BorderBrush="{StaticResource Border.Brush}" |
|||
Foreground="{StaticResource Text.Color}" |
|||
Command="{Binding ImportSaleFreightBillCommand}" CommandParameter="JD"/> |
|||
</StackPanel> |
|||
<ListBox ItemsSource="{Binding SaleFreightBillFileList}" |
|||
ItemContainerStyle="{StaticResource NoBgListBoxItemStyle}" |
|||
Style="{StaticResource NoScrollViewListBoxStyle}" |
|||
Grid.Row="1" |
|||
Foreground="{StaticResource Text.Link.Color}"> |
|||
<ListBox.ItemsPanel> |
|||
<ItemsPanelTemplate> |
|||
<StackPanel Orientation="Horizontal"/> |
|||
</ItemsPanelTemplate> |
|||
</ListBox.ItemsPanel> |
|||
<ListBox.ItemTemplate> |
|||
<DataTemplate> |
|||
<TextBlock Text="{Binding}" Margin="5,0"/> |
|||
</DataTemplate> |
|||
</ListBox.ItemTemplate> |
|||
</ListBox> |
|||
</Grid> |
|||
</Border> |
|||
|
|||
<Border BorderThickness="1" BorderBrush="{StaticResource Border.Brush}" |
|||
Grid.Row="2" Grid.Column="2" > |
|||
<Grid> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition Height="0.5*"/> |
|||
<RowDefinition Height="0.5*"/> |
|||
</Grid.RowDefinitions> |
|||
</Grid> |
|||
</Border> |
|||
|
|||
<Border BorderThickness="1" BorderBrush="{StaticResource Border.Brush}" |
|||
Grid.Row="2" Grid.Column="4" > |
|||
<Grid> |
|||
<Grid.RowDefinitions> |
|||
<RowDefinition Height="0.5*"/> |
|||
<RowDefinition Height="0.5*"/> |
|||
</Grid.RowDefinitions> |
|||
</Grid> |
|||
</Border> |
|||
</Grid> |
|||
|
|||
<Border Background="{StaticResource Border.Background}" Padding="5,0" Grid.Row="4"> |
|||
<Grid> |
|||
<StackPanel Orientation="Horizontal"> |
|||
<TextBlock Text="发货类型" VerticalAlignment="Center"/> |
|||
<ComboBox Margin="5,0,0,0" ItemsSource="{Binding Source={StaticResource storageTypeProvider}}" |
|||
Height="25" VerticalContentAlignment="Center"/> |
|||
<TextBlock Text="订单号" VerticalAlignment="Center" Margin="5,0,0,0"/> |
|||
<c:BTextBox Width="150" Height="25" Margin="5,0,0,0"/> |
|||
</StackPanel> |
|||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> |
|||
<c:BButton Content="结果搜索" Padding="10,0" Command="{Binding SearchLocalCommand}"/> |
|||
<c:BButton Content="清空条件" Padding="10,0" Command="{Binding ClearLocalConditionCommand}" Background="{StaticResource Text.Pink}"/> |
|||
<c:BButton Content="导出Excel" Padding="10,0" Background="#02A7F0" Command="{Binding ExportCommand}"/> |
|||
<c:BButton Content="保存" Padding="10,0" Background="#1CC2A2" Command="{Binding SaveCommand}"/> |
|||
</StackPanel> |
|||
</Grid> |
|||
</Border> |
|||
</Grid> |
|||
</Grid> |
|||
</Page> |
@ -0,0 +1,15 @@ |
|||
using System.Windows.Controls; |
|||
|
|||
namespace BBWY.Client.Views.BillCorrection |
|||
{ |
|||
/// <summary>
|
|||
/// BillCorrectionView.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class BillCorrectionView : Page |
|||
{ |
|||
public BillCorrectionView() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue