You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
234 lines
11 KiB
234 lines
11 KiB
using BBWY.Client.Models.APIModel;
|
|
using BBWY.Client.Models.APIModel.Response.PackTask;
|
|
using BBWY.Client.Views.PackTask;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Markup;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace BBWY.Client.Views.TotalPackTask
|
|
{
|
|
/// <summary>
|
|
/// PackUserSalaryControl.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class PackUserSalaryControl : UserControl
|
|
{
|
|
public PackUserSalaryControl()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
|
|
|
|
public List<PackUserSalary> PackUserSalaries
|
|
{
|
|
get
|
|
{
|
|
return (List<PackUserSalary>)GetValue(PackUserSalariesProperty);
|
|
|
|
}
|
|
set
|
|
{
|
|
SetValue(PackUserSalariesProperty, value);
|
|
}
|
|
}
|
|
|
|
|
|
public static readonly DependencyProperty PackUserSalariesProperty =
|
|
DependencyProperty.Register("PackUserSalaries", typeof(List<PackUserSalary>), typeof(PackUserSalaryControl), new PropertyMetadata(ChangedProperty));
|
|
|
|
|
|
|
|
|
|
private static void ChangedProperty(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
var control = d as PackUserSalaryControl;
|
|
// control.Str
|
|
var newValue = e.NewValue as List<PackUserSalary>;
|
|
control.PackUserSalaries = newValue;
|
|
|
|
control.LoadData();
|
|
}
|
|
|
|
string xaml = @" <Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"">
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition Height=""30""/>
|
|
[:Row:]
|
|
</Grid.RowDefinitions>
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width=""30""/>
|
|
<ColumnDefinition Width=""80""/>
|
|
<ColumnDefinition MinWidth=""60""/>
|
|
<ColumnDefinition MinWidth=""60""/>
|
|
[:Column:]
|
|
</Grid.ColumnDefinitions>
|
|
<CheckBox HorizontalAlignment=""Center"" Grid.Column=""0"" HorizontalContentAlignment=""Center"" />
|
|
<TextBlock Text=""日期"" Grid.Column=""1"" Style=""{StaticResource middleTextBlock}""/>
|
|
<TextBlock Text=""花名"" Grid.Column=""2"" Style=""{StaticResource middleTextBlock}""/>
|
|
<TextBlock Text=""总收益"" Grid.Column=""3"" Style=""{StaticResource middleTextBlock}""/>
|
|
[:HeaderNameList:]
|
|
<Border Width=""1"" HorizontalAlignment=""Left"" Background=""{StaticResource Border.Brush}"" Grid.RowSpan=""[:DataCount+1:]""/>
|
|
|
|
<Border Width=""1"" HorizontalAlignment=""Right"" Background=""{StaticResource Border.Brush}"" Grid.Column=""0"" />
|
|
<Border Width=""1"" HorizontalAlignment=""Right"" Background=""{StaticResource Border.Brush}"" Grid.Column=""1"" />
|
|
<Border Width=""1"" HorizontalAlignment=""Right"" Background=""{StaticResource Border.Brush}"" Grid.Column=""2"" />
|
|
<Border Width=""1"" HorizontalAlignment=""Right"" Background=""{StaticResource Border.Brush}"" Grid.Column=""3"" />
|
|
[:BorderHeaderList:]
|
|
<Border Width=""1"" HorizontalAlignment=""Right"" Background=""{StaticResource Border.Brush}"" Grid.Column=""[:4+DataItemCount:]"" Grid.RowSpan=""[:DataCount+1:]""/>
|
|
|
|
<Border Height=""1"" VerticalAlignment=""Top"" Grid.ColumnSpan=""[:4+DataItemCount:]"" Background=""{StaticResource Border.Brush}"" Grid.Row=""0""/>
|
|
<Border Height=""1"" VerticalAlignment=""Top"" Grid.ColumnSpan=""[:4+DataItemCount:]"" Background=""{StaticResource Border.Brush}"" Grid.Row=""1""/>
|
|
|
|
[:DataList:]
|
|
|
|
</Grid>";
|
|
|
|
|
|
const string rows = @"<RowDefinition Height=""30""/>";
|
|
string columns = @"<ColumnDefinition MinWidth=""60""/>";
|
|
string headName = @"<TextBlock Text=""[:ServiceName:]"" Grid.Column=""[:ColumnIndex:]"" Grid.Row=""[:RowIndex:]"" Style=""{StaticResource middleTextBlock}""/>";
|
|
string borderColumns = @" <Border Width=""1"" HorizontalAlignment=""Right"" Background=""{StaticResource Border.Brush}"" Grid.Column=""[:ColumnIndex:]"" Grid.Row=""[:RowIndex:]"" />";
|
|
/// <summary>
|
|
/// index 从1开始 0+1
|
|
/// </summary>
|
|
string rowStr = @"
|
|
<CheckBox HorizontalAlignment=""Center"" Grid.Column=""0"" Grid.Row=""[:RowIndex:]"" HorizontalContentAlignment=""Center"" />
|
|
<TextBlock Text=""[:Date:]"" Grid.Column=""1"" Grid.Row=""[:RowIndex:]"" Style=""{StaticResource middleTextBlock}""/>
|
|
<TextBlock Text=""[:PackUserName:]"" Grid.Column=""2"" Grid.Row=""[:RowIndex:]"" Style=""{StaticResource middleTextBlock}""/>
|
|
<TextBlock Text=""[:TotalIncome:]"" Grid.Column=""3"" Grid.Row=""[:RowIndex:]"" Style=""{StaticResource middleTextBlock}""/>
|
|
[:HeaderPriceList:]
|
|
<Border Width=""1"" HorizontalAlignment=""Right"" Background=""{StaticResource Border.Brush}"" Grid.Column=""0"" Grid.Row=""[:RowIndex:]""/>
|
|
<Border Width=""1"" HorizontalAlignment=""Right"" Background=""{StaticResource Border.Brush}"" Grid.Column=""1"" Grid.Row=""[:RowIndex:]""/>
|
|
<Border Width=""1"" HorizontalAlignment=""Right"" Background=""{StaticResource Border.Brush}"" Grid.Column=""2"" Grid.Row=""[:RowIndex:]""/>
|
|
<Border Width=""1"" HorizontalAlignment=""Right"" Background=""{StaticResource Border.Brush}"" Grid.Column=""3"" Grid.Row=""[:RowIndex:]""/>
|
|
<Border Width=""1"" HorizontalAlignment=""Right"" Background=""{StaticResource Border.Brush}"" Grid.Column=""4"" Grid.Row=""[:RowIndex:]""/>
|
|
[:BorderDataList:]
|
|
<Border Height=""1"" VerticalAlignment=""Bottom"" Grid.ColumnSpan=""[:4+DataItemCount:]"" Background=""{StaticResource Border.Brush}"" Grid.Row=""[:RowIndex:]""/>";
|
|
|
|
|
|
|
|
string serviceText = @" <TextBlock Text=""[:ServicePrice:]"" Grid.Column=""[:ColumnIndex:]"" Grid.Row=""[:RowIndex:]"" Style=""{StaticResource middleTextBlock}""/>";
|
|
string serviceBorder = @" <Border Width=""1"" HorizontalAlignment=""Right"" Background=""{StaticResource Border.Brush}"" Grid.Column=""[:ColumnIndex:]"" Grid.Row=""[:RowIndex:]""/>";
|
|
|
|
public void LoadData()
|
|
{
|
|
|
|
if (PackUserSalaries == null )
|
|
return;
|
|
|
|
if ( PackUserSalaries.Count <= 0)
|
|
{
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
{
|
|
gd.Children.Clear();
|
|
});
|
|
}
|
|
|
|
|
|
try
|
|
{
|
|
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
{
|
|
gd.Children.Clear();
|
|
});
|
|
|
|
|
|
var count = PackUserSalaries.Count;
|
|
|
|
StringBuilder sbRow =new StringBuilder();
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
sbRow.AppendLine(rows);
|
|
}
|
|
string rowDefinition = sbRow.ToString();
|
|
|
|
StringBuilder sbColumn = new StringBuilder();
|
|
var packServices = PackUserSalaries[0].IncomeItems;//服务项目列表
|
|
var packServiceCount = packServices.Count; //服务项目数量
|
|
|
|
|
|
|
|
StringBuilder sbHeaderNameList = new StringBuilder();
|
|
StringBuilder sbBorderHeaderList=new StringBuilder();
|
|
|
|
for (int i = 0; i < packServiceCount; i++)
|
|
{
|
|
sbColumn.AppendLine(columns);
|
|
sbHeaderNameList.AppendLine(headName.Replace("[:ServiceName:]", packServices[i].Name)
|
|
.Replace("[:ColumnIndex:]", (i+4).ToString())
|
|
.Replace("[:RowIndex:]", "0"));
|
|
sbBorderHeaderList.AppendLine(borderColumns.Replace("[:ColumnIndex:]", (i + 4).ToString())
|
|
.Replace("[:RowIndex:]", "0"));
|
|
}
|
|
|
|
string columnDefinition = sbColumn.ToString();
|
|
string HeaderNameList= sbHeaderNameList.ToString();
|
|
|
|
|
|
StringBuilder dataListSB= new StringBuilder();
|
|
for (int i = 0; i < PackUserSalaries.Count; i++)
|
|
{
|
|
|
|
var rowIndex = 1 + i;
|
|
StringBuilder headerPriceListSB = new StringBuilder();
|
|
StringBuilder serviceBorderSB = new StringBuilder();
|
|
for (int j = 0; j < PackUserSalaries[i].IncomeItems.Count; j++)
|
|
{
|
|
var columnIndex = 4 + j;//[:HeaderPriceList:]
|
|
headerPriceListSB.AppendLine(serviceText.Replace("[:ServicePrice:]", PackUserSalaries[i].IncomeItems[j].TotalPrice.ToString())
|
|
.Replace("[:ColumnIndex:]", columnIndex.ToString())
|
|
.Replace("[:RowIndex:]", rowIndex.ToString()));
|
|
|
|
serviceBorderSB.AppendLine(serviceBorder.Replace("[:ColumnIndex:]", columnIndex.ToString())
|
|
.Replace("[:RowIndex:]", rowIndex.ToString()));
|
|
}
|
|
dataListSB.AppendLine(rowStr.Replace("[:Date:]", PackUserSalaries[i].Date.ToString("yyyy-MM-dd"))
|
|
.Replace("[:PackUserName:]", PackUserSalaries[i].PackUserName)
|
|
.Replace("[:TotalIncome:]", PackUserSalaries[i].TotalIncome.ToString("0.00"))
|
|
.Replace("[:HeaderPriceList:]", headerPriceListSB.ToString())
|
|
.Replace("[:BorderDataList:]", serviceBorderSB.ToString())
|
|
.Replace("[:RowIndex:]", rowIndex.ToString())
|
|
.Replace("[:4+DataItemCount:]", (packServiceCount+4).ToString())
|
|
);
|
|
}
|
|
|
|
|
|
var newGrid = xaml.Replace("[:Row:]", rowDefinition)
|
|
.Replace("[:Column:]", columnDefinition)
|
|
.Replace("[:HeaderNameList:]", HeaderNameList)
|
|
.Replace("[:DataCount+1:]", (count+1).ToString())
|
|
.Replace("[:4+DataItemCount:]", (packServiceCount + 4).ToString())
|
|
.Replace("[:BorderHeaderList:]", sbBorderHeaderList.ToString())
|
|
.Replace("[:DataList:]", dataListSB.ToString());
|
|
|
|
|
|
|
|
var grid = XamlReader.Parse(newGrid) as Grid;
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
{
|
|
gd.Children.Add(grid);
|
|
});
|
|
|
|
}
|
|
catch
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|