| @ -0,0 +1,6 @@ | |||
| .* | |||
| *.TMP | |||
| *.suo | |||
| *.user | |||
| obj | |||
| bin | |||
| @ -0,0 +1,22 @@ | |||
| | |||
| Microsoft Visual Studio Solution File, Format Version 12.00 | |||
| # Visual Studio 2013 | |||
| VisualStudioVersion = 12.0.40629.0 | |||
| MinimumVisualStudioVersion = 10.0.40219.1 | |||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FourComponentWeightClient", "FourComponentWeightClient\FourComponentWeightClient.csproj", "{51E5F43A-248E-4956-A819-9626FCB669D5}" | |||
| EndProject | |||
| Global | |||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
| Debug|Any CPU = Debug|Any CPU | |||
| Release|Any CPU = Release|Any CPU | |||
| EndGlobalSection | |||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | |||
| {51E5F43A-248E-4956-A819-9626FCB669D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
| {51E5F43A-248E-4956-A819-9626FCB669D5}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
| {51E5F43A-248E-4956-A819-9626FCB669D5}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
| {51E5F43A-248E-4956-A819-9626FCB669D5}.Release|Any CPU.Build.0 = Release|Any CPU | |||
| EndGlobalSection | |||
| GlobalSection(SolutionProperties) = preSolution | |||
| HideSolutionNode = FALSE | |||
| EndGlobalSection | |||
| EndGlobal | |||
| @ -0,0 +1,265 @@ | |||
| <Application x:Class="FourComponentWeightClient.App" | |||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
| StartupUri="MainWindow.xaml"> | |||
| <Application.Resources> | |||
| <Style x:Key="Exist" TargetType="Button"> | |||
| <Setter Property="Background" Value="#F6F6F6"/> | |||
| <Setter Property="Template"> | |||
| <Setter.Value> | |||
| <ControlTemplate TargetType="Button"> | |||
| <Border Name="border" BorderThickness="1" CornerRadius="3" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> | |||
| <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | |||
| </Border> | |||
| <ControlTemplate.Triggers> | |||
| <Trigger Property="IsMouseOver" Value="True"> | |||
| <Setter Property="Control.Background" Value="#BEE6FD"/> | |||
| </Trigger> | |||
| </ControlTemplate.Triggers> | |||
| </ControlTemplate> | |||
| </Setter.Value> | |||
| </Setter> | |||
| </Style> | |||
| <Style x:Key="Login" TargetType="Button"> | |||
| <Setter Property="Foreground" Value="#FFFFFF"/> | |||
| <Setter Property="BorderBrush" Value="#0675E3"/> | |||
| <Setter Property="Background"> | |||
| <Setter.Value> | |||
| <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> | |||
| <GradientStop Color="#FF055EB6" Offset="1"/> | |||
| <GradientStop Color="#FF1888F8"/> | |||
| </LinearGradientBrush> | |||
| </Setter.Value> | |||
| </Setter> | |||
| <Setter Property="Template"> | |||
| <Setter.Value> | |||
| <ControlTemplate TargetType="Button"> | |||
| <Border Name="border" BorderThickness="1" CornerRadius="3" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> | |||
| <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | |||
| </Border> | |||
| <ControlTemplate.Triggers> | |||
| <Trigger Property="IsMouseOver" Value="True"> | |||
| <Setter Property="Control.Background" Value="#00A2E8"/> | |||
| </Trigger> | |||
| </ControlTemplate.Triggers> | |||
| </ControlTemplate> | |||
| </Setter.Value> | |||
| </Setter> | |||
| </Style> | |||
| <Style x:Key="Selected" TargetType="Button"> | |||
| <Setter Property="Foreground" Value="#FFFFFF"/> | |||
| <Setter Property="BorderBrush" Value="#0675E3"/> | |||
| <Setter Property="Background"> | |||
| <Setter.Value> | |||
| <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> | |||
| <GradientStop Color="#FF055EB6" Offset="1"/> | |||
| <GradientStop Color="#FF1888F8"/> | |||
| </LinearGradientBrush> | |||
| </Setter.Value> | |||
| </Setter> | |||
| <Setter Property="Template"> | |||
| <Setter.Value> | |||
| <ControlTemplate TargetType="Button"> | |||
| <Border Name="border" BorderThickness="1" CornerRadius="3" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> | |||
| <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | |||
| </Border> | |||
| <ControlTemplate.Triggers> | |||
| <Trigger Property="IsMouseOver" Value="True"> | |||
| <Setter Property="Control.Background" Value="#00A2E8"/> | |||
| </Trigger> | |||
| </ControlTemplate.Triggers> | |||
| </ControlTemplate> | |||
| </Setter.Value> | |||
| </Setter> | |||
| </Style> | |||
| <Style TargetType="Button"> | |||
| <Setter Property="Background" Value="#2B6DE8"/> | |||
| <Setter Property="Foreground" Value="White"/> | |||
| <Setter Property="Template"> | |||
| <Setter.Value> | |||
| <ControlTemplate TargetType="Button"> | |||
| <Border Name="border" BorderThickness="0" CornerRadius="3" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> | |||
| <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | |||
| </Border> | |||
| <ControlTemplate.Triggers> | |||
| <Trigger Property="IsMouseOver" Value="True"> | |||
| <Setter Property="Control.Background" Value="Black"/> | |||
| </Trigger> | |||
| <Trigger Property="IsEnabled" Value="false"> | |||
| <Setter Property="Control.Background" Value="#BABABA"/> | |||
| </Trigger> | |||
| </ControlTemplate.Triggers> | |||
| </ControlTemplate> | |||
| </Setter.Value> | |||
| </Setter> | |||
| </Style> | |||
| <Style x:Key="#8655D5" TargetType="Button"> | |||
| <Setter Property="Background" Value="#8655D5"/> | |||
| <Setter Property="Foreground" Value="White"/> | |||
| <Setter Property="Template"> | |||
| <Setter.Value> | |||
| <ControlTemplate TargetType="Button"> | |||
| <Border Name="border" BorderThickness="0" CornerRadius="3" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> | |||
| <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | |||
| </Border> | |||
| <ControlTemplate.Triggers> | |||
| <Trigger Property="IsMouseOver" Value="True"> | |||
| <Setter Property="Control.Background" Value="Black"/> | |||
| </Trigger> | |||
| <Trigger Property="IsEnabled" Value="false"> | |||
| <Setter Property="Control.Background" Value="#BABABA"/> | |||
| </Trigger> | |||
| </ControlTemplate.Triggers> | |||
| </ControlTemplate> | |||
| </Setter.Value> | |||
| </Setter> | |||
| </Style> | |||
| <Style x:Key="#D4691B" TargetType="Button"> | |||
| <Setter Property="Background" Value="#D4691B"/> | |||
| <Setter Property="Foreground" Value="White"/> | |||
| <Setter Property="Template"> | |||
| <Setter.Value> | |||
| <ControlTemplate TargetType="Button"> | |||
| <Border Name="border" BorderThickness="0" CornerRadius="3" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> | |||
| <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | |||
| </Border> | |||
| <ControlTemplate.Triggers> | |||
| <Trigger Property="IsMouseOver" Value="True"> | |||
| <Setter Property="Control.Background" Value="Black"/> | |||
| </Trigger> | |||
| <Trigger Property="IsEnabled" Value="false"> | |||
| <Setter Property="Control.Background" Value="#BABABA"/> | |||
| </Trigger> | |||
| </ControlTemplate.Triggers> | |||
| </ControlTemplate> | |||
| </Setter.Value> | |||
| </Setter> | |||
| </Style> | |||
| <Style x:Key="#2B6DE8" TargetType="Button"> | |||
| <Setter Property="Background" Value="#2B6DE8"/> | |||
| <Setter Property="Foreground" Value="White"/> | |||
| <Setter Property="Template"> | |||
| <Setter.Value> | |||
| <ControlTemplate TargetType="Button"> | |||
| <Border Name="border" BorderThickness="0" CornerRadius="3" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> | |||
| <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | |||
| </Border> | |||
| <ControlTemplate.Triggers> | |||
| <Trigger Property="IsMouseOver" Value="True"> | |||
| <Setter Property="Control.Background" Value="Black"/> | |||
| </Trigger> | |||
| <Trigger Property="IsEnabled" Value="false"> | |||
| <Setter Property="Control.Background" Value="#BABABA"/> | |||
| </Trigger> | |||
| </ControlTemplate.Triggers> | |||
| </ControlTemplate> | |||
| </Setter.Value> | |||
| </Setter> | |||
| </Style> | |||
| <Style x:Key="#12B735" TargetType="Button"> | |||
| <Setter Property="Background" Value="#12B735"/> | |||
| <Setter Property="Foreground" Value="White"/> | |||
| <Setter Property="Template"> | |||
| <Setter.Value> | |||
| <ControlTemplate TargetType="Button"> | |||
| <Border Name="border" BorderThickness="0" CornerRadius="3" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> | |||
| <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | |||
| </Border> | |||
| <ControlTemplate.Triggers> | |||
| <Trigger Property="IsMouseOver" Value="True"> | |||
| <Setter Property="Control.Background" Value="Black"/> | |||
| </Trigger> | |||
| <Trigger Property="IsEnabled" Value="false"> | |||
| <Setter Property="Control.Background" Value="#BABABA"/> | |||
| </Trigger> | |||
| </ControlTemplate.Triggers> | |||
| </ControlTemplate> | |||
| </Setter.Value> | |||
| </Setter> | |||
| </Style> | |||
| <Style x:Key="#F82327" TargetType="Button"> | |||
| <Setter Property="Background" Value="#F82327"/> | |||
| <Setter Property="Foreground" Value="White"/> | |||
| <Setter Property="Template"> | |||
| <Setter.Value> | |||
| <ControlTemplate TargetType="Button"> | |||
| <Border Name="border" BorderThickness="0" CornerRadius="3" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> | |||
| <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | |||
| </Border> | |||
| <ControlTemplate.Triggers> | |||
| <Trigger Property="IsMouseOver" Value="True"> | |||
| <Setter Property="Control.Background" Value="Black"/> | |||
| </Trigger> | |||
| <Trigger Property="IsEnabled" Value="false"> | |||
| <Setter Property="Control.Background" Value="#BABABA"/> | |||
| </Trigger> | |||
| </ControlTemplate.Triggers> | |||
| </ControlTemplate> | |||
| </Setter.Value> | |||
| </Setter> | |||
| </Style> | |||
| <Style x:Key="#1BA7DC" TargetType="Button"> | |||
| <Setter Property="Background" Value="#1BA7DC"/> | |||
| <Setter Property="Foreground" Value="White"/> | |||
| <Setter Property="Template"> | |||
| <Setter.Value> | |||
| <ControlTemplate TargetType="Button"> | |||
| <Border Name="border" BorderThickness="0" CornerRadius="3" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> | |||
| <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | |||
| </Border> | |||
| <ControlTemplate.Triggers> | |||
| <Trigger Property="IsMouseOver" Value="True"> | |||
| <Setter Property="Control.Background" Value="Black"/> | |||
| </Trigger> | |||
| <Trigger Property="IsEnabled" Value="false"> | |||
| <Setter Property="Control.Background" Value="#BABABA"/> | |||
| </Trigger> | |||
| </ControlTemplate.Triggers> | |||
| </ControlTemplate> | |||
| </Setter.Value> | |||
| </Setter> | |||
| </Style> | |||
| <Style x:Key="#E7954B" TargetType="Button"> | |||
| <Setter Property="Background" Value="#E7954B"/> | |||
| <Setter Property="Foreground" Value="White"/> | |||
| <Setter Property="Template"> | |||
| <Setter.Value> | |||
| <ControlTemplate TargetType="Button"> | |||
| <Border Name="border" BorderThickness="0" CornerRadius="3" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> | |||
| <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | |||
| </Border> | |||
| <ControlTemplate.Triggers> | |||
| <Trigger Property="IsMouseOver" Value="True"> | |||
| <Setter Property="Control.Background" Value="Black"/> | |||
| </Trigger> | |||
| <Trigger Property="IsEnabled" Value="false"> | |||
| <Setter Property="Control.Background" Value="#BABABA"/> | |||
| </Trigger> | |||
| </ControlTemplate.Triggers> | |||
| </ControlTemplate> | |||
| </Setter.Value> | |||
| </Setter> | |||
| </Style> | |||
| <Style x:Key="#BABABA" TargetType="Button"> | |||
| <Setter Property="Background" Value="#BABABA"/> | |||
| <Setter Property="Foreground" Value="White"/> | |||
| <Setter Property="Template"> | |||
| <Setter.Value> | |||
| <ControlTemplate TargetType="Button"> | |||
| <Border Name="border" BorderThickness="0" CornerRadius="3" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"> | |||
| <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | |||
| </Border> | |||
| <ControlTemplate.Triggers> | |||
| <Trigger Property="IsMouseOver" Value="True"> | |||
| <Setter Property="Control.Background" Value="Black"/> | |||
| </Trigger> | |||
| </ControlTemplate.Triggers> | |||
| </ControlTemplate> | |||
| </Setter.Value> | |||
| </Setter> | |||
| </Style> | |||
| </Application.Resources> | |||
| </Application> | |||
| @ -0,0 +1,31 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Configuration; | |||
| using System.Data; | |||
| using System.Linq; | |||
| using System.Windows; | |||
| namespace FourComponentWeightClient | |||
| { | |||
| /// <summary> | |||
| /// App.xaml 的交互逻辑 | |||
| /// </summary> | |||
| public partial class App : Application | |||
| { | |||
| public App() | |||
| { | |||
| //处理程序中未捕获的异常 | |||
| DispatcherUnhandledException += App_DispatcherUnhandledException; | |||
| } | |||
| private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) | |||
| { | |||
| var msg = e.Exception.Message; | |||
| #if DEBUG | |||
| msg = e.Exception.ToString(); | |||
| #endif | |||
| MessageBox.Show(msg, "错误", MessageBoxButton.OK, MessageBoxImage.Error); | |||
| e.Handled = true; | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,48 @@ | |||
| using Forks.JsonRpc.Client; | |||
| using FourComponentWeightClient.BO; | |||
| using Newtonsoft.Json; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Collections.ObjectModel; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| namespace FourComponentWeightClient.BL | |||
| { | |||
| public static class FourComponentWeightBL | |||
| { | |||
| public static ObservableCollection<FourComponentWeight> LoadList(DateTime date) | |||
| { | |||
| var json = RpcFacade.Call<string>("/MainSystem/B3DaHongMen/Rpcs/FourComponentWeightRpc/GetList", date); | |||
| var list = JsonConvert.DeserializeObject<List<FourComponentWeight>>(json); | |||
| var idx = list.Count; | |||
| foreach (var item in list) | |||
| { | |||
| item.RowIdx = idx; | |||
| idx--; | |||
| } | |||
| return new ObservableCollection<FourComponentWeight>(list); | |||
| } | |||
| public static void Insert(FourComponentWeight detail) | |||
| { | |||
| detail.ID = RpcFacade.Call<long>("/MainSystem/B3DaHongMen/Rpcs/FourComponentWeightRpc/Insert", JsonConvert.SerializeObject(detail)); | |||
| } | |||
| public static void FillDiaoPaiNumber(long id, int diaoPai) | |||
| { | |||
| RpcFacade.Call<int>("/MainSystem/B3DaHongMen/Rpcs/FourComponentWeightRpc/FillDiaoPai", id, diaoPai); | |||
| } | |||
| public static void UpdateDiscont(long id, decimal discont) | |||
| { | |||
| RpcFacade.Call<int>("/MainSystem/B3DaHongMen/Rpcs/FourComponentWeightRpc/UpdateDiscont", id, discont); | |||
| } | |||
| public static void DeleteItem(long id) | |||
| { | |||
| RpcFacade.Call<int>("/MainSystem/B3DaHongMen/Rpcs/FourComponentWeightRpc/DeleteRecord", id); | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,43 @@ | |||
| using FourComponentWeightClient.Utils; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.ComponentModel; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| using System.Xml.Serialization; | |||
| namespace FourComponentWeightClient.BO | |||
| { | |||
| public class DiscontSetting : INotifyPropertyChanged | |||
| { | |||
| public string Name { get; set; } | |||
| public decimal Weight { get; set; } | |||
| [XmlIgnore] | |||
| public int Number { get; set; } | |||
| [XmlIgnore] | |||
| public decimal TotalWeight { get { return Weight * Number; } } | |||
| public static List<DiscontSetting> Load() | |||
| { | |||
| return XmlUtil.DeserializeFromFile<List<DiscontSetting>>("Config\\DiscontSetting.xml"); | |||
| } | |||
| public static void Save(List<DiscontSetting> list) | |||
| { | |||
| XmlUtil.SerializerObjToFile(list, "Config\\DiscontSetting.xml"); | |||
| } | |||
| public event PropertyChangedEventHandler PropertyChanged; | |||
| public void Change(params string[] fields) | |||
| { | |||
| if (this.PropertyChanged == null) | |||
| return; | |||
| foreach (var item in fields) | |||
| this.PropertyChanged(this, new PropertyChangedEventArgs(item)); | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,38 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.ComponentModel; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| namespace FourComponentWeightClient.BO | |||
| { | |||
| public class FourComponentWeight : INotifyPropertyChanged | |||
| { | |||
| public long ID { get; set; } | |||
| public int RowIdx { get; set; } | |||
| public int? DiaoPaiNum { get; set; } | |||
| public decimal? Weight { get; set; } | |||
| public decimal? Discont { get; set; } | |||
| public decimal? NetWeight { get { return Weight - Discont; } } | |||
| public int Type { get; set; } | |||
| public DateTime? Date { get; set; } | |||
| public long Goods_ID { get; set; } | |||
| public string Goods_Name { get; set; } | |||
| public event PropertyChangedEventHandler PropertyChanged; | |||
| public void Change(params string[] fields) | |||
| { | |||
| if (this.PropertyChanged == null) | |||
| return; | |||
| foreach (var item in fields) | |||
| this.PropertyChanged(this, new PropertyChangedEventArgs(item)); | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,26 @@ | |||
| using FourComponentWeightClient.Utils; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| namespace FourComponentWeightClient.BO | |||
| { | |||
| public class GoodsSetting | |||
| { | |||
| public long Goods_ID { get; set; } | |||
| public int Type { get; set; } | |||
| public static List<GoodsSetting> Load() | |||
| { | |||
| return XmlUtil.DeserializeFromFile<List<GoodsSetting>>("Config\\GoodsSetting.xml"); | |||
| } | |||
| public static void Save(List<GoodsSetting> list) | |||
| { | |||
| XmlUtil.SerializerObjToFile(list, "Config\\GoodsSetting.xml"); | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,70 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| namespace FourComponentWeightClient.DataFormat | |||
| { | |||
| interface IDataFormat | |||
| { | |||
| char Beginchar { get; } | |||
| char Endchar { get; } | |||
| short Bufsize { get; } | |||
| bool ParseAscii(string buf, out string weight, out bool isStatic); | |||
| bool ParseAscii(string buf, out string weight, out bool isStatic, out string subStr); | |||
| } | |||
| internal abstract class DataFormatBase : IDataFormat | |||
| { | |||
| public abstract int DataLength | |||
| { | |||
| get; | |||
| } | |||
| public abstract char Beginchar | |||
| { | |||
| get; | |||
| } | |||
| public abstract char Endchar | |||
| { | |||
| get; | |||
| } | |||
| public abstract short Bufsize { get; } | |||
| public const short BUFSIZE = 36; | |||
| // 根据开始字符找出 一个完整的数据帧 | |||
| public string FindDataFrame(string buf, int fSize) | |||
| { | |||
| var bufSize = buf.Length; | |||
| if (fSize > bufSize) | |||
| { | |||
| return string.Empty; | |||
| } | |||
| int index = buf.IndexOf(Beginchar); // 查找开始字符的索引 | |||
| if (index < 0 || (index + fSize) > bufSize) | |||
| { | |||
| return string.Empty; | |||
| } | |||
| string data = buf.Substring(index, fSize); | |||
| // 检查结束字符 | |||
| if (data[fSize - 1] != Endchar) | |||
| { | |||
| return string.Empty; | |||
| } | |||
| return data; | |||
| } | |||
| public abstract string ParseData(string buf, out bool isStatic); | |||
| public abstract bool ParseAscii(string buf, out string weight, out bool isStatic); | |||
| public abstract bool ParseAscii(string buf, out string weight, out bool isStatic, out string subStr); | |||
| } | |||
| } | |||
| @ -0,0 +1,58 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| namespace FourComponentWeightClient.DataFormat | |||
| { | |||
| internal class IND560DataFormat : DataFormatBase | |||
| { | |||
| public override int DataLength | |||
| { | |||
| get { return 10; } | |||
| } | |||
| public override char Beginchar | |||
| { | |||
| get { return (char)0x80; }//这种数据没有固定的开始标志 | |||
| } | |||
| public override char Endchar | |||
| { | |||
| get { return (char)0x67; } | |||
| } | |||
| public override short Bufsize | |||
| { | |||
| get { return 36; } | |||
| } | |||
| public override string ParseData(string buf, out bool isStatic) | |||
| { | |||
| isStatic = false; | |||
| return string.Empty; | |||
| } | |||
| public override bool ParseAscii(string buf, out string weight, out bool isStatic) | |||
| { | |||
| isStatic = true; | |||
| weight = buf.Replace("kg", "").Replace((char)0x0D, (char)0x20).Replace((char)0x0A, (char)0x20).Replace((char)0x3F, (char)0x20); | |||
| weight = weight.Trim(); | |||
| if (weight.Any(x => x == ' ')) | |||
| { | |||
| var arr = weight.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); | |||
| if (arr.Length > 1) | |||
| weight = arr[1]; | |||
| } | |||
| return true; | |||
| } | |||
| public override bool ParseAscii(string buf, out string weight, out bool isStatic, out string subStr) | |||
| { | |||
| weight = ""; | |||
| isStatic = false; | |||
| subStr = ""; | |||
| return false; | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,121 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| namespace FourComponentWeightClient.DataFormat | |||
| { | |||
| internal class Xk3124DataFormat : DataFormatBase | |||
| { | |||
| public override int DataLength | |||
| { | |||
| get { return 17; } | |||
| } | |||
| public override char Beginchar | |||
| { | |||
| get { return (char)0x02; } | |||
| } | |||
| public override char Endchar | |||
| { | |||
| get { return (char)0x0D; ; } | |||
| } | |||
| public override short Bufsize | |||
| { | |||
| get { return 36; } | |||
| } | |||
| public override string ParseData(string buf, out bool isStatic) | |||
| { | |||
| StringBuilder str = new StringBuilder(); | |||
| char swa = buf[1]; // 状态字A | |||
| char swb = buf[2]; // 状态字B | |||
| int dotIndex = (swa & 0x07) - 2; // 小数点位置 | |||
| bool isPositive = (((swb >> 1) & 0x01) == 0); // 符号:是否为正数 | |||
| isStatic = (((swb >> 3) & 0x01) == 0); | |||
| char[] num = new char[6]; | |||
| for (int i = 0; i < 6; i++) | |||
| { | |||
| num[i] = buf[i + 4]; | |||
| } | |||
| if (dotIndex < 0) | |||
| { // 不考虑精确到十,百位 | |||
| return str.ToString(); | |||
| } | |||
| for (int i = 0; i < 6 - dotIndex; i++) | |||
| { | |||
| str.Append(num[i]); | |||
| } | |||
| str.Append('.'); | |||
| for (int i = 0; i < dotIndex; i++) | |||
| { | |||
| str.Append(num[6 - dotIndex + i]); | |||
| } | |||
| // 去掉空格 | |||
| string result = str.ToString().Trim(); | |||
| // 取消前面多余的0 | |||
| for (int i = 0; i < result.Length; i++) | |||
| { | |||
| if (result[i] != '0') | |||
| { | |||
| result = result.Substring(i, result.Length - i); | |||
| break; | |||
| } | |||
| } | |||
| if (result.IndexOf('.') == 0) | |||
| { | |||
| result = result.Insert(0, "0"); | |||
| } | |||
| if (result.IndexOf('.') == result.Length - 1) | |||
| { | |||
| result = result.Remove(result.IndexOf('.'), 1); | |||
| } | |||
| if (!isPositive) | |||
| { // 负数 | |||
| result = result.Insert(0, "-"); | |||
| } | |||
| return result; | |||
| } | |||
| public override bool ParseAscii(string buf, out string weight, out bool isStatic) | |||
| { | |||
| isStatic = false; | |||
| weight = FindDataFrame(buf, DataLength); | |||
| if (string.IsNullOrEmpty(weight)) | |||
| { | |||
| return false; | |||
| } | |||
| weight = ParseData(weight, out isStatic); | |||
| return true; | |||
| } | |||
| public override bool ParseAscii(string buf, out string weight, out bool isStatic, out string subStr) | |||
| { | |||
| weight = ""; | |||
| isStatic = false; | |||
| subStr = ""; | |||
| return false; | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,136 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| namespace FourComponentWeightClient.DataFormat | |||
| { | |||
| internal class Xk3190A9DataFormat : DataFormatBase | |||
| { | |||
| public override int DataLength | |||
| { | |||
| get { return 12; } | |||
| } | |||
| public override char Beginchar | |||
| { | |||
| get { return (char)0x02; } | |||
| } | |||
| public override char Endchar | |||
| { | |||
| get { return (char)0x03; } | |||
| } | |||
| public override short Bufsize | |||
| { | |||
| get { return 36; } | |||
| } | |||
| public override string ParseData(string buf, out bool isStatic) | |||
| { | |||
| string weight; | |||
| // 小数位数0-4 | |||
| int dot = (short)(0x0F & buf[8]); | |||
| weight = buf.Substring(2, 6).Trim(); | |||
| // insert dot | |||
| weight = InsertDot(weight, dot); | |||
| isStatic = true; // 默认 为 稳定 | |||
| // buffer[1] 符号位 | |||
| if (buf[1] == '-') | |||
| { | |||
| weight = weight.Insert(0, "-"); | |||
| } | |||
| return weight; | |||
| } | |||
| public override bool ParseAscii(string buf, out string weight, out bool isStatic) | |||
| { | |||
| isStatic = false; | |||
| weight = FindDataFrame(buf, DataLength); | |||
| if (string.IsNullOrEmpty(weight)) | |||
| { | |||
| return false; | |||
| } | |||
| weight = ParseData(weight, out isStatic); | |||
| return true; | |||
| } | |||
| private static string InsertDot(string weight, int dotBits) | |||
| { | |||
| string str = weight.TrimStart(new[] { | |||
| '0' | |||
| }); | |||
| str = str.Trim(); | |||
| if (dotBits > 0) | |||
| { | |||
| //str = str.Insert(str.Length - dotBits, "."); | |||
| if (string.IsNullOrEmpty(str)) | |||
| { | |||
| str = "0"; | |||
| str = str.Insert(str.Length, "."); | |||
| for (int i = 0; i < dotBits; i++) | |||
| { | |||
| str = str.Insert(str.Length, "0"); | |||
| } | |||
| } | |||
| else | |||
| str = str.Insert(str.Length - dotBits, "."); | |||
| } | |||
| if (str.IndexOf(".") == 0) | |||
| { | |||
| str = str.Insert(0, "0"); | |||
| } | |||
| return str; | |||
| } | |||
| public override bool ParseAscii(string buf, out string weight, out bool isStatic, out string subStr) | |||
| { | |||
| isStatic = false; | |||
| weight = FindDataFrame(buf, DataLength, out subStr); | |||
| if (string.IsNullOrEmpty(weight)) | |||
| { | |||
| return false; | |||
| } | |||
| weight = ParseData(weight, out isStatic); | |||
| return true; | |||
| } | |||
| // 根据开始字符找出 一个完整的数据帧 | |||
| public string FindDataFrame(string buf, int fSize, out string subStr) | |||
| { | |||
| var bufSize = buf.Length; | |||
| subStr = ""; | |||
| int index = buf.IndexOf(Beginchar); // 查找开始字符的索引 | |||
| if (index < 0 || (index + fSize) > bufSize) | |||
| { | |||
| return string.Empty; | |||
| } | |||
| string data = buf.Substring(index, fSize); | |||
| subStr = buf.Substring(index + fSize); | |||
| // 检查结束字符 | |||
| if (data[fSize - 1] != Endchar) | |||
| { | |||
| return string.Empty; | |||
| } | |||
| return data; | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,53 @@ | |||
| <Window x:Class="FourComponentWeightClient.DiscontSettingWindow" | |||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
| Title="扣重设置" Height="600" Width="550" ShowInTaskbar="False" | |||
| WindowStartupLocation="CenterOwner" ResizeMode="NoResize" FontSize="16"> | |||
| <Grid Margin="5"> | |||
| <Grid.RowDefinitions> | |||
| <RowDefinition Height="60"/> | |||
| <RowDefinition/> | |||
| <RowDefinition Height="50"/> | |||
| </Grid.RowDefinitions> | |||
| <Border BorderThickness="1" CornerRadius="3" BorderBrush="LightGray" Margin="5"> | |||
| <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> | |||
| <TextBlock Text="扣重项" Margin="5" VerticalAlignment="Center"/> | |||
| <TextBox x:Name="itemName" Margin="5" Width="120" Padding="5,0" VerticalContentAlignment="Center"/> | |||
| <TextBlock Margin="10,5,5,5" Text="标准值" VerticalAlignment="Center"/> | |||
| <TextBox x:Name="itemValue" Margin="5" Width="120" Padding="5,0" VerticalContentAlignment="Center"/> | |||
| <Button x:Name="addBtn" Width="100" Height="40" Content="增加" Click="addBtn_Click" Margin="5,4"/> | |||
| </StackPanel> | |||
| </Border> | |||
| <Border Grid.Row="1" BorderThickness="1" CornerRadius="3" BorderBrush="LightGray" Margin="5"> | |||
| <DataGrid HorizontalAlignment="Stretch" HeadersVisibility="Column" x:Name="discontGrid" EnableColumnVirtualization="True" EnableRowVirtualization="True" AutoGenerateColumns="False" CanUserAddRows="False" Margin="5" RowHeight="45"> | |||
| <DataGrid.Columns> | |||
| <DataGridTextColumn Binding="{Binding Name}" Header="扣重项" Width="1.5*"/> | |||
| <DataGridTextColumn Binding="{Binding Weight, StringFormat=\{0:0.######\}}" Header="标准值" Width="1.2*"/> | |||
| <DataGridTemplateColumn Header="排序" Width="2.0*"> | |||
| <DataGridTemplateColumn.CellTemplate> | |||
| <DataTemplate> | |||
| <Grid> | |||
| <Grid.ColumnDefinitions> | |||
| <ColumnDefinition/> | |||
| <ColumnDefinition/> | |||
| </Grid.ColumnDefinitions> | |||
| <Button Style="{StaticResource #12B735}" Focusable="False" Content="↓" Margin="5" x:Name="downBtn" Click="downBtn_Click" HorizontalAlignment="Stretch" /> | |||
| <Button Style="{StaticResource #E7954B}" Focusable="False" Grid.Column="1" Content="↑" Margin="5" x:Name="upBtn" Click="upBtn_Click" HorizontalAlignment="Stretch" /> | |||
| </Grid> | |||
| </DataTemplate> | |||
| </DataGridTemplateColumn.CellTemplate> | |||
| </DataGridTemplateColumn> | |||
| <DataGridTemplateColumn Header="删除" Width="1.5*"> | |||
| <DataGridTemplateColumn.CellTemplate> | |||
| <DataTemplate> | |||
| <Button Style="{StaticResource #F82327}" Focusable="False" Content="删除" Margin="5" x:Name="delBtn" Click="delBtn_Click" HorizontalAlignment="Stretch" /> | |||
| </DataTemplate> | |||
| </DataGridTemplateColumn.CellTemplate> | |||
| </DataGridTemplateColumn> | |||
| </DataGrid.Columns> | |||
| </DataGrid> | |||
| </Border> | |||
| <Button Grid.Row="2" Margin="80,5" Content="保存" x:Name="saveBtn" Click="saveBtn_Click"/> | |||
| </Grid> | |||
| </Window> | |||
| @ -0,0 +1,87 @@ | |||
| using FourComponentWeightClient.BO; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Collections.ObjectModel; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| using System.Windows; | |||
| using System.Windows.Controls; | |||
| using System.Windows.Data; | |||
| using System.Windows.Documents; | |||
| using System.Windows.Input; | |||
| using System.Windows.Media; | |||
| using System.Windows.Media.Imaging; | |||
| using System.Windows.Shapes; | |||
| namespace FourComponentWeightClient | |||
| { | |||
| /// <summary> | |||
| /// DiscontSettingWindow.xaml 的交互逻辑 | |||
| /// </summary> | |||
| public partial class DiscontSettingWindow : Window | |||
| { | |||
| ObservableCollection<DiscontSetting> list; | |||
| public DiscontSettingWindow() | |||
| { | |||
| InitializeComponent(); | |||
| list = new ObservableCollection<DiscontSetting>(DiscontSetting.Load()); | |||
| discontGrid.ItemsSource = list; | |||
| } | |||
| private void saveBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| DiscontSetting.Save(list.ToList()); | |||
| MessageBox.Show("保存成功!"); | |||
| } | |||
| private void delBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| var item = discontGrid.SelectedItem as DiscontSetting; | |||
| if (MessageBox.Show(string.Format("确定删除选{0}?", item.Name), "删除确认", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK) | |||
| { | |||
| list.Remove(item); | |||
| } | |||
| } | |||
| private void addBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| if (string.IsNullOrEmpty(itemName.Text)) | |||
| throw new Exception("扣重项不能为空"); | |||
| if (list.Any(x => x.Name == itemName.Text)) | |||
| throw new Exception("重复添加项"); | |||
| if (string.IsNullOrEmpty(itemValue.Text)) | |||
| throw new Exception("标准值不能为空"); | |||
| var item = new DiscontSetting { Name = itemName.Text, Weight = decimal.Parse(itemValue.Text) }; | |||
| if (item.Weight <= 0) | |||
| throw new Exception("标准值不合法"); | |||
| list.Add(item); | |||
| } | |||
| private void upBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| var item = discontGrid.SelectedItem as DiscontSetting; | |||
| ExChangeOrder(item, true); | |||
| } | |||
| private void downBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| var item = discontGrid.SelectedItem as DiscontSetting; | |||
| ExChangeOrder(item, false); | |||
| } | |||
| void ExChangeOrder(DiscontSetting current, bool up) | |||
| { | |||
| var idx = list.IndexOf(current); | |||
| if (up && idx == 0) | |||
| return; | |||
| if (!up && idx == list.Count - 1) | |||
| return; | |||
| var nIdx = idx + (up ? -1 : 1); | |||
| var change = list[nIdx]; | |||
| list[nIdx] = current; | |||
| list[idx] = change; | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,102 @@ | |||
| <Window xmlns:FourComponentWeightClient="clr-namespace:FourComponentWeightClient" x:Class="FourComponentWeightClient.FCWeightForm" | |||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
| Title="四分体称重" Height="700" Width="900" WindowState="Maximized" FontSize="15" > | |||
| <Grid Margin="5"> | |||
| <Grid.RowDefinitions> | |||
| <RowDefinition Height="90"/> | |||
| <RowDefinition Height="170"/> | |||
| <RowDefinition Height="1*"/> | |||
| </Grid.RowDefinitions> | |||
| <Grid.ColumnDefinitions> | |||
| <ColumnDefinition Width="1*"/> | |||
| <ColumnDefinition Width="1.5*"/> | |||
| </Grid.ColumnDefinitions> | |||
| <Border Grid.Row="0" | |||
| Grid.Column="0" Grid.ColumnSpan="2" BorderThickness="1" BorderBrush="LightGray"> | |||
| <FourComponentWeightClient:WeightControl x:Name="weightCtl" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2"/> | |||
| </Border> | |||
| <Border Grid.Row="1" | |||
| Grid.Column="0" BorderThickness="1" Margin="0,5,0,0" BorderBrush="LightGray"> | |||
| <DockPanel LastChildFill="True"> | |||
| <Button DockPanel.Dock="Top" x:Name="goodsSetBtn" Width="120" Height="40" Content="产品设置" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,2,2,0" Click="goodsSetBtn_Click"/> | |||
| <WrapPanel x:Name="goodsPanel" Orientation="Horizontal" Margin="0,2,2,0"></WrapPanel> | |||
| </DockPanel> | |||
| </Border> | |||
| <Border Grid.Row="2" Grid.Column="0" BorderThickness="1" Margin="0,5,0,0" BorderBrush="LightGray"> | |||
| <DockPanel LastChildFill="True"> | |||
| <StackPanel DockPanel.Dock="Top" Orientation="Horizontal" HorizontalAlignment="Right" > | |||
| <TextBlock Margin="0,10,10,0" Text="总扣重"/> | |||
| <TextBlock x:Name="totalDiscontLbl" Margin="10,10,10,0" Width="50" Foreground ="Red" Text="0"/> | |||
| <Button x:Name="discontSetBtn" Width="120" Height="40" Content="扣重设置" Margin="0,2,2,0" Click="discontSetBtn_Click"/> | |||
| </StackPanel> | |||
| <DataGrid HorizontalAlignment="Stretch" HeadersVisibility="Column" x:Name="discontGrid" EnableColumnVirtualization="True" EnableRowVirtualization="True" AutoGenerateColumns="False" CanUserAddRows="False" Margin="5" RowHeight="50"> | |||
| <DataGrid.Columns> | |||
| <DataGridTextColumn Binding="{Binding Name}" Header="扣重项" Width="1.2*"/> | |||
| <DataGridTextColumn Binding="{Binding Weight, StringFormat=\{0:0.######\}}" Header="标准值" Width="1*"/> | |||
| <DataGridTextColumn Binding="{Binding Number}" Header="数量" Width="0.8*"/> | |||
| <DataGridTextColumn Binding="{Binding TotalWeight, StringFormat=\{0:0.######\}}" Header="重量" Width="1*"/> | |||
| <DataGridTemplateColumn Header="操作" Width="2.0*"> | |||
| <DataGridTemplateColumn.CellTemplate> | |||
| <DataTemplate> | |||
| <Grid> | |||
| <Grid.ColumnDefinitions> | |||
| <ColumnDefinition/> | |||
| <ColumnDefinition/> | |||
| </Grid.ColumnDefinitions> | |||
| <Button Style="{StaticResource #12B735}" Focusable="False" Content="-" x:Name="subBtn" Margin="5" Click="subBtn_Click" HorizontalAlignment="Stretch" /> | |||
| <Button Style="{StaticResource #E7954B}" Focusable="False" Grid.Column="1" Content="+" Margin="5" x:Name="addBtn" Click="addBtn_Click" HorizontalAlignment="Stretch" /> | |||
| </Grid> | |||
| </DataTemplate> | |||
| </DataGridTemplateColumn.CellTemplate> | |||
| </DataGridTemplateColumn> | |||
| </DataGrid.Columns> | |||
| </DataGrid> | |||
| </DockPanel> | |||
| </Border> | |||
| <Border Grid.Row="1" Grid.Column="2" Grid.RowSpan="2" BorderThickness="1" Margin="5,5,0,0" BorderBrush="LightGray"> | |||
| <DockPanel LastChildFill="True"> | |||
| <StackPanel DockPanel.Dock="Top" Orientation="Horizontal" HorizontalAlignment="Right" > | |||
| <TextBlock Margin="10,10,10,0" Width="65" Text="宰杀日期"/> | |||
| <DatePicker x:Name="datePicker"/> | |||
| <Button x:Name="queryBtn" Width="120" Height="40" Content="刷新" Margin="0,2,2,0" Click="queryBtn_Click"/> | |||
| </StackPanel> | |||
| <DataGrid HorizontalAlignment="Stretch" HeadersVisibility="Column" x:Name="weightGrid" EnableColumnVirtualization="True" EnableRowVirtualization="True" AutoGenerateColumns="False" CanUserAddRows="False" Margin="5" RowHeight="50"> | |||
| <DataGrid.RowStyle> | |||
| <Style TargetType="DataGridRow"> | |||
| <EventSetter Event="PreviewMouseDown" Handler="Item_GotFocus"/> | |||
| </Style> | |||
| </DataGrid.RowStyle> | |||
| <DataGrid.Columns> | |||
| <DataGridTextColumn Binding="{Binding RowIdx}" Header="序号" Width="1*"/> | |||
| <DataGridTemplateColumn Header="吊牌号" Width="1.5*"> | |||
| <DataGridTemplateColumn.CellTemplate> | |||
| <DataTemplate> | |||
| <TextBlock x:Name="diaoPaiCell" Text="{Binding DiaoPaiNum}" PreviewMouseDown="diaoPaiCell_PreviewMouseDown"/> | |||
| </DataTemplate> | |||
| </DataGridTemplateColumn.CellTemplate> | |||
| </DataGridTemplateColumn> | |||
| <DataGridTextColumn Binding="{Binding Goods_Name}" Header="存货名称" Width="1.5*"/> | |||
| <DataGridTextColumn Binding="{Binding Weight, StringFormat=\{0:0.######\}}" Header="重量" Width="1*"/> | |||
| <DataGridTemplateColumn Header="扣重" Width="1*"> | |||
| <DataGridTemplateColumn.CellTemplate> | |||
| <DataTemplate> | |||
| <TextBlock x:Name="discontCell" Text="{Binding Discont, StringFormat=\{0:0.######\}}" PreviewMouseDown="discontCell_PreviewMouseDown"/> | |||
| </DataTemplate> | |||
| </DataGridTemplateColumn.CellTemplate> | |||
| </DataGridTemplateColumn> | |||
| <DataGridTextColumn Binding="{Binding NetWeight, StringFormat=\{0:0.######\}}" Header="净重" Width="1*"/> | |||
| <DataGridTemplateColumn Header="删除" Width="1.5*"> | |||
| <DataGridTemplateColumn.CellTemplate> | |||
| <DataTemplate> | |||
| <Button Style="{StaticResource #F82327}" Focusable="False" Content="删除" Margin="5" x:Name="delBtn" Click="delBtn_Click" HorizontalAlignment="Stretch" /> | |||
| </DataTemplate> | |||
| </DataGridTemplateColumn.CellTemplate> | |||
| </DataGridTemplateColumn> | |||
| </DataGrid.Columns> | |||
| </DataGrid> | |||
| </DockPanel> | |||
| </Border> | |||
| </Grid> | |||
| </Window> | |||
| @ -0,0 +1,186 @@ | |||
| using FourComponentWeightClient.BL; | |||
| using FourComponentWeightClient.BO; | |||
| using FourComponentWeightClient.Utils; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Collections.ObjectModel; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| using System.Windows; | |||
| using System.Windows.Controls; | |||
| using System.Windows.Data; | |||
| using System.Windows.Documents; | |||
| using System.Windows.Input; | |||
| using System.Windows.Media; | |||
| using System.Windows.Media.Imaging; | |||
| using System.Windows.Shapes; | |||
| namespace FourComponentWeightClient | |||
| { | |||
| /// <summary> | |||
| /// FCWeightForm.xaml 的交互逻辑 | |||
| /// </summary> | |||
| public partial class FCWeightForm : Window | |||
| { | |||
| ObservableCollection<DiscontSetting> discontList; | |||
| ObservableCollection<FourComponentWeight> weightList; | |||
| public FCWeightForm() | |||
| { | |||
| InitializeComponent(); | |||
| datePicker.SelectedDate = DateTime.Today; | |||
| BindGoodsBtns(); | |||
| BindDiscontItems(); | |||
| weightList = new ObservableCollection<FourComponentWeight>(); | |||
| } | |||
| DataGridRow focusRow; | |||
| void Item_GotFocus(object sender, MouseButtonEventArgs e) | |||
| { | |||
| focusRow = sender as DataGridRow; | |||
| } | |||
| void diaoPaiCell_PreviewMouseDown(object sender, MouseButtonEventArgs e) | |||
| { | |||
| var keyPad = new Keypad(this); | |||
| if (keyPad.ShowDialog() == true) | |||
| { | |||
| int num = 0; | |||
| if (int.TryParse(keyPad.Result, out num)) | |||
| { | |||
| var entity = focusRow.Item as FourComponentWeight; | |||
| FourComponentWeightBL.FillDiaoPaiNumber(entity.ID, num); | |||
| entity.DiaoPaiNum = num; | |||
| entity.Change("DiaoPaiNum"); | |||
| } | |||
| else | |||
| throw new Exception("输入吊牌号不正确"); | |||
| } | |||
| } | |||
| string[] gNames = new string[] { "牛肩", "牛前", "牛后" }; | |||
| void BindGoodsBtns() | |||
| { | |||
| goodsPanel.Children.Clear(); | |||
| var list = GoodsSetting.Load(); | |||
| if (list.Any(x => x.Goods_ID != 0)) | |||
| { | |||
| for (var i = 0; i < gNames.Length; i++) | |||
| { | |||
| var btn = new Button { Content = gNames[i], Tag = list[i], Margin = new Thickness(25), Width = 115, Height = 60 }; | |||
| btn.Click += btn_Click; | |||
| goodsPanel.Children.Add(btn); | |||
| } | |||
| } | |||
| } | |||
| void btn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| if (weightCtl.Weight == 0) | |||
| throw new Exception("重量不能为0"); | |||
| var btn = sender as Button; | |||
| var tag = btn.Tag as GoodsSetting; | |||
| var detail = new FourComponentWeight(); | |||
| if (weightList.Any()) | |||
| detail.RowIdx = weightList[0].RowIdx + 1; | |||
| else | |||
| detail.RowIdx = 1; | |||
| detail.Date = datePicker.SelectedDate.Value; | |||
| detail.Weight = weightCtl.Weight; | |||
| detail.Discont = Convert.ToDecimal(totalDiscontLbl.Text); | |||
| detail.Goods_Name = btn.Content.ToString(); | |||
| detail.Goods_ID = tag.Goods_ID; | |||
| detail.Type = tag.Type; | |||
| FourComponentWeightBL.Insert(detail); | |||
| weightList.Insert(0, detail); | |||
| ResetDiscont(); | |||
| } | |||
| void BindDiscontItems() | |||
| { | |||
| discontList = new ObservableCollection<DiscontSetting>(DiscontSetting.Load()); | |||
| discontGrid.ItemsSource = discontList; | |||
| } | |||
| void ResetDiscont() | |||
| { | |||
| foreach (var item in discontList) | |||
| { | |||
| item.Number = 0; | |||
| item.Change("Number", "TotalWeight"); | |||
| } | |||
| totalDiscontLbl.Text = "0"; | |||
| } | |||
| private void subBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| var item = discontGrid.SelectedItem as DiscontSetting; | |||
| if (item.Number == 0) | |||
| return; | |||
| item.Number -= 1; | |||
| item.Change("Number", "TotalWeight"); | |||
| totalDiscontLbl.Text = discontList.Sum(x => x.TotalWeight).ToString("#0.###"); | |||
| } | |||
| private void addBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| var item = discontGrid.SelectedItem as DiscontSetting; | |||
| item.Number += 1; | |||
| item.Change("Number", "TotalWeight"); | |||
| totalDiscontLbl.Text = discontList.Sum(x => x.TotalWeight).ToString("#0.###"); | |||
| } | |||
| private void discontSetBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| new DiscontSettingWindow().ShowDialog(); | |||
| BindDiscontItems(); | |||
| ResetDiscont(); | |||
| } | |||
| private void goodsSetBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| new GoodsSettingWindow().ShowDialog(); | |||
| BindGoodsBtns(); | |||
| } | |||
| private void queryBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| weightList = FourComponentWeightBL.LoadList(datePicker.SelectedDate.Value); | |||
| weightGrid.ItemsSource = weightList; | |||
| } | |||
| private void discontCell_PreviewMouseDown(object sender, MouseButtonEventArgs e) | |||
| { | |||
| var keypad = new Keypad(this); | |||
| if (keypad.ShowDialog() == true) | |||
| { | |||
| decimal discont; | |||
| if (decimal.TryParse(keypad.Result, out discont)) | |||
| { | |||
| var item = focusRow.Item as FourComponentWeight; | |||
| FourComponentWeightBL.UpdateDiscont(item.ID, discont); | |||
| item.Discont = discont; | |||
| item.Change("Discont", "NetWeight"); | |||
| } | |||
| else | |||
| MessageBox.Show("扣重输入不正确", "提示"); | |||
| } | |||
| } | |||
| private void delBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| var item = focusRow.Item as FourComponentWeight; | |||
| if (MessageBox.Show(string.Format("确定删除选序号为{0}的明细吗?", item.RowIdx), "删除确认", MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK) | |||
| { | |||
| FourComponentWeightBL.DeleteItem(item.ID); | |||
| foreach (var a in weightList.Where(x => x.RowIdx > item.RowIdx)) | |||
| { | |||
| a.RowIdx -= 1; | |||
| a.Change("RowIdx"); | |||
| } | |||
| weightList.Remove(item); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,181 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
| <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | |||
| <PropertyGroup> | |||
| <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |||
| <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |||
| <ProjectGuid>{51E5F43A-248E-4956-A819-9626FCB669D5}</ProjectGuid> | |||
| <OutputType>WinExe</OutputType> | |||
| <AppDesignerFolder>Properties</AppDesignerFolder> | |||
| <RootNamespace>FourComponentWeightClient</RootNamespace> | |||
| <AssemblyName>FourComponentWeightClient</AssemblyName> | |||
| <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | |||
| <FileAlignment>512</FileAlignment> | |||
| <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | |||
| <WarningLevel>4</WarningLevel> | |||
| <TargetFrameworkProfile /> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |||
| <PlatformTarget>AnyCPU</PlatformTarget> | |||
| <DebugSymbols>true</DebugSymbols> | |||
| <DebugType>full</DebugType> | |||
| <Optimize>false</Optimize> | |||
| <OutputPath>bin\Debug\</OutputPath> | |||
| <DefineConstants>DEBUG;TRACE</DefineConstants> | |||
| <ErrorReport>prompt</ErrorReport> | |||
| <WarningLevel>4</WarningLevel> | |||
| <Prefer32Bit>false</Prefer32Bit> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |||
| <PlatformTarget>AnyCPU</PlatformTarget> | |||
| <DebugType>pdbonly</DebugType> | |||
| <Optimize>true</Optimize> | |||
| <OutputPath>bin\Release\</OutputPath> | |||
| <DefineConstants>TRACE</DefineConstants> | |||
| <ErrorReport>prompt</ErrorReport> | |||
| <WarningLevel>4</WarningLevel> | |||
| <Prefer32Bit>false</Prefer32Bit> | |||
| </PropertyGroup> | |||
| <ItemGroup> | |||
| <Reference Include="Forks.JsonRpc.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL"> | |||
| <SpecificVersion>False</SpecificVersion> | |||
| <HintPath>..\..\..\..\..\..\..\BwpB3Project\tsref\release\Forks.JsonRpc.Client.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="Newtonsoft.Json, Version=4.0.3.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | |||
| <SpecificVersion>False</SpecificVersion> | |||
| <HintPath>..\..\..\..\..\..\..\BwpB3Project\tsref\release\Newtonsoft.Json.dll</HintPath> | |||
| </Reference> | |||
| <Reference Include="System" /> | |||
| <Reference Include="System.Data" /> | |||
| <Reference Include="System.Xml" /> | |||
| <Reference Include="Microsoft.CSharp" /> | |||
| <Reference Include="System.Core" /> | |||
| <Reference Include="System.Xml.Linq" /> | |||
| <Reference Include="System.Data.DataSetExtensions" /> | |||
| <Reference Include="System.Xaml"> | |||
| <RequiredTargetFramework>4.0</RequiredTargetFramework> | |||
| </Reference> | |||
| <Reference Include="WindowsBase" /> | |||
| <Reference Include="PresentationCore" /> | |||
| <Reference Include="PresentationFramework" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <ApplicationDefinition Include="App.xaml"> | |||
| <Generator>MSBuild:Compile</Generator> | |||
| <SubType>Designer</SubType> | |||
| </ApplicationDefinition> | |||
| <Compile Include="BO\FourComponentWeight.cs" /> | |||
| <Compile Include="BL\FourComponentWeightBL.cs" /> | |||
| <Compile Include="BO\DiscontSetting.cs" /> | |||
| <Compile Include="BO\GoodsSetting.cs" /> | |||
| <Compile Include="DataFormat\DataFormat.cs" /> | |||
| <Compile Include="DataFormat\IND560DataFormat.cs" /> | |||
| <Compile Include="DiscontSettingWindow.xaml.cs"> | |||
| <DependentUpon>DiscontSettingWindow.xaml</DependentUpon> | |||
| </Compile> | |||
| <Compile Include="GoodsSettingWindow.xaml.cs"> | |||
| <DependentUpon>GoodsSettingWindow.xaml</DependentUpon> | |||
| </Compile> | |||
| <Compile Include="Utils\WeightConfig.cs" /> | |||
| <Compile Include="DataFormat\Xk3124DataFormat.cs" /> | |||
| <Compile Include="DataFormat\Xk3190A9DataFormat.cs" /> | |||
| <Compile Include="FCWeightForm.xaml.cs"> | |||
| <DependentUpon>FCWeightForm.xaml</DependentUpon> | |||
| </Compile> | |||
| <Compile Include="SettingDialog.xaml.cs"> | |||
| <DependentUpon>SettingDialog.xaml</DependentUpon> | |||
| </Compile> | |||
| <Compile Include="Utils\AppContext.cs" /> | |||
| <Compile Include="Utils\Keypad.xaml.cs"> | |||
| <DependentUpon>Keypad.xaml</DependentUpon> | |||
| </Compile> | |||
| <Compile Include="Utils\LoginUtil.cs" /> | |||
| <Compile Include="Utils\XmlUtil.cs" /> | |||
| <Compile Include="WeightControl.xaml.cs"> | |||
| <DependentUpon>WeightControl.xaml</DependentUpon> | |||
| </Compile> | |||
| <Compile Include="WeightSetForm.xaml.cs"> | |||
| <DependentUpon>WeightSetForm.xaml</DependentUpon> | |||
| </Compile> | |||
| <Page Include="DiscontSettingWindow.xaml"> | |||
| <SubType>Designer</SubType> | |||
| <Generator>MSBuild:Compile</Generator> | |||
| </Page> | |||
| <Page Include="FCWeightForm.xaml"> | |||
| <SubType>Designer</SubType> | |||
| <Generator>MSBuild:Compile</Generator> | |||
| </Page> | |||
| <Page Include="GoodsSettingWindow.xaml"> | |||
| <SubType>Designer</SubType> | |||
| <Generator>MSBuild:Compile</Generator> | |||
| </Page> | |||
| <Page Include="MainWindow.xaml"> | |||
| <Generator>MSBuild:Compile</Generator> | |||
| <SubType>Designer</SubType> | |||
| </Page> | |||
| <Compile Include="App.xaml.cs"> | |||
| <DependentUpon>App.xaml</DependentUpon> | |||
| <SubType>Code</SubType> | |||
| </Compile> | |||
| <Compile Include="MainWindow.xaml.cs"> | |||
| <DependentUpon>MainWindow.xaml</DependentUpon> | |||
| <SubType>Code</SubType> | |||
| </Compile> | |||
| <Page Include="SettingDialog.xaml"> | |||
| <SubType>Designer</SubType> | |||
| <Generator>MSBuild:Compile</Generator> | |||
| </Page> | |||
| <Page Include="Utils\Keypad.xaml"> | |||
| <SubType>Designer</SubType> | |||
| <Generator>MSBuild:Compile</Generator> | |||
| </Page> | |||
| <Page Include="WeightControl.xaml"> | |||
| <SubType>Designer</SubType> | |||
| <Generator>MSBuild:Compile</Generator> | |||
| </Page> | |||
| <Page Include="WeightSetForm.xaml"> | |||
| <SubType>Designer</SubType> | |||
| <Generator>MSBuild:Compile</Generator> | |||
| </Page> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <Compile Include="Properties\AssemblyInfo.cs"> | |||
| <SubType>Code</SubType> | |||
| </Compile> | |||
| <Compile Include="Properties\Resources.Designer.cs"> | |||
| <AutoGen>True</AutoGen> | |||
| <DesignTime>True</DesignTime> | |||
| <DependentUpon>Resources.resx</DependentUpon> | |||
| </Compile> | |||
| <Compile Include="Properties\Settings.Designer.cs"> | |||
| <AutoGen>True</AutoGen> | |||
| <DependentUpon>Settings.settings</DependentUpon> | |||
| <DesignTimeSharedInput>True</DesignTimeSharedInput> | |||
| </Compile> | |||
| <EmbeddedResource Include="Properties\Resources.resx"> | |||
| <Generator>ResXFileCodeGenerator</Generator> | |||
| <LastGenOutput>Resources.Designer.cs</LastGenOutput> | |||
| </EmbeddedResource> | |||
| <None Include="app.config" /> | |||
| <None Include="Properties\Settings.settings"> | |||
| <Generator>SettingsSingleFileGenerator</Generator> | |||
| <LastGenOutput>Settings.Designer.cs</LastGenOutput> | |||
| </None> | |||
| <AppDesigner Include="Properties\" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <Resource Include="images\login.png" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <Resource Include="images\setting.png" /> | |||
| </ItemGroup> | |||
| <ItemGroup /> | |||
| <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | |||
| <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | |||
| Other similar extension points exist, see Microsoft.Common.targets. | |||
| <Target Name="BeforeBuild"> | |||
| </Target> | |||
| <Target Name="AfterBuild"> | |||
| </Target> | |||
| --> | |||
| </Project> | |||
| @ -0,0 +1,28 @@ | |||
| <Window x:Class="FourComponentWeightClient.GoodsSettingWindow" | |||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
| Title="存货设置" Height="300" Width="300" ShowInTaskbar="False" | |||
| WindowStartupLocation="CenterOwner" ResizeMode="NoResize" FontSize="16"> | |||
| <Grid Margin="10"> | |||
| <Grid.RowDefinitions> | |||
| <RowDefinition/> | |||
| <RowDefinition/> | |||
| <RowDefinition/> | |||
| <RowDefinition/> | |||
| </Grid.RowDefinitions> | |||
| <Grid.ColumnDefinitions> | |||
| <ColumnDefinition Width="1*"/> | |||
| <ColumnDefinition Width="1.5*"/> | |||
| </Grid.ColumnDefinitions> | |||
| <TextBlock Text="牛肩" HorizontalAlignment="Center" VerticalAlignment="Center"/> | |||
| <TextBox Grid.Column="1" x:Name="nj" Margin="4,12" Padding="5" VerticalContentAlignment="Center"/> | |||
| <TextBlock Grid.Row="1" Text="牛前" HorizontalAlignment="Center" VerticalAlignment="Center"/> | |||
| <TextBox Grid.Row="1" Grid.Column="1" x:Name="nq" Margin="4,12" Padding="5" VerticalContentAlignment="Center"/> | |||
| <TextBlock Grid.Row="2" Text="牛后" HorizontalAlignment="Center" VerticalAlignment="Center"/> | |||
| <TextBox Grid.Row="2" Grid.Column="1" x:Name="nh" Margin="4,12" Padding="5" VerticalContentAlignment="Center"/> | |||
| <Button Grid.Row="3" Grid.Column="1" Content="保存" Width="120" Height="40" HorizontalAlignment="Left" Click="Button_Click"/> | |||
| </Grid> | |||
| </Window> | |||
| @ -0,0 +1,61 @@ | |||
| using FourComponentWeightClient.BO; | |||
| using FourComponentWeightClient.Utils; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| using System.Windows; | |||
| using System.Windows.Controls; | |||
| using System.Windows.Data; | |||
| using System.Windows.Documents; | |||
| using System.Windows.Input; | |||
| using System.Windows.Media; | |||
| using System.Windows.Media.Imaging; | |||
| using System.Windows.Shapes; | |||
| namespace FourComponentWeightClient | |||
| { | |||
| /// <summary> | |||
| /// GoodsSettingWindow.xaml 的交互逻辑 | |||
| /// </summary> | |||
| public partial class GoodsSettingWindow : Window | |||
| { | |||
| List<GoodsSetting> list; | |||
| List<TextBox> ctls; | |||
| public GoodsSettingWindow() | |||
| { | |||
| InitializeComponent(); | |||
| ctls = new List<TextBox> { nj, nq, nh }; | |||
| list = GoodsSetting.Load(); | |||
| if (list.Count == 0) | |||
| { | |||
| for (var i = 0; i < ctls.Count;i++ ) | |||
| list.Add(new GoodsSetting() { Type = i }); | |||
| } | |||
| for (var i = 0; i < ctls.Count; i++) | |||
| { | |||
| ctls[i].Text = list[i].Goods_ID.ToString(); | |||
| ctls[i].PreviewMouseDown += nj_PreviewMouseDown; | |||
| } | |||
| } | |||
| void nj_PreviewMouseDown(object sender, MouseButtonEventArgs e) | |||
| { | |||
| var pad = new Keypad(this); | |||
| if (pad.ShowDialog() == true) | |||
| (sender as TextBox).Text = pad.Result; | |||
| } | |||
| private void Button_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| for (var i = 0; i < ctls.Count;i++ ) | |||
| list[i].Goods_ID = long.Parse(ctls[i].Text); | |||
| if (list.Any(x => x.Goods_ID == 0)) | |||
| throw new Exception("存货ID不能设置为0"); | |||
| GoodsSetting.Save(list); | |||
| MessageBox.Show("保存成功!"); | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,24 @@ | |||
| <Window x:Class="FourComponentWeightClient.MainWindow" | |||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
| Title="MainWindow" Height="433" Width="622" WindowStyle="None" AllowsTransparency="True" | |||
| ResizeMode="NoResize" MouseLeftButtonDown="Window_MouseLeftButtonDown" BorderThickness="40" | |||
| Loaded="Window_Loaded"> | |||
| <Window.Background> | |||
| <ImageBrush ImageSource="images/login.png"/> | |||
| </Window.Background> | |||
| <Window.Effect> | |||
| <DropShadowEffect BlurRadius="40" Color="#000000" ShadowDepth="0"/> | |||
| </Window.Effect> | |||
| <Grid> | |||
| <Image Source="images\setting.png" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,10,10,0" Width="32" PreviewMouseDown="Image_PreviewMouseDown"/> | |||
| <Label Content="用户名" FontFamily="微软雅黑" FontSize="22px" HorizontalAlignment="Left" Margin="130,142,0,0" VerticalAlignment="Top" Width="90" Foreground="Gray"/> | |||
| <TextBox Name="userNameInput" HorizontalAlignment="Left" Height="35" Margin="220,145,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" FontFamily="微软雅黑" FontSize="18" Width="187" VerticalContentAlignment="Center" PreviewMouseLeftButtonDown="UserNameTextBoxClick"/> | |||
| <Label Content="密 码" FontFamily="微软雅黑" FontSize="22px" HorizontalAlignment="Left" Margin="130,192,0,0" VerticalAlignment="Top" Width="90" Foreground="Gray"/> | |||
| <PasswordBox Name="pwdInput" HorizontalAlignment="Left" Height="35" Margin="220,195,0,0" VerticalAlignment="Top" FontSize="18" Width="187" VerticalContentAlignment="Center" PreviewMouseLeftButtonDown="PwdTextBoxClick"/> | |||
| <Button Name="loginBtn" Style="{StaticResource Login}" IsDefault="True" Content="登录" HorizontalAlignment="Left" Margin="145,255,0,0" VerticalAlignment="Top" Width="110" Height="45" FontSize="18" Click="LoginBtn_Click"> | |||
| </Button> | |||
| <Button Style="{StaticResource Exist}" Content="退出" HorizontalAlignment="Left" Margin="290,255,0,0" VerticalAlignment="Top" Width="110" Height="45" FontSize="18" BorderBrush="#A0A0A0" Click="ExistBtn_Click"/> | |||
| </Grid> | |||
| </Window> | |||
| @ -0,0 +1,94 @@ | |||
| using FourComponentWeightClient.Utils; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| using System.Windows; | |||
| using System.Windows.Controls; | |||
| using System.Windows.Data; | |||
| using System.Windows.Documents; | |||
| using System.Windows.Input; | |||
| using System.Windows.Media; | |||
| using System.Windows.Media.Imaging; | |||
| using System.Windows.Navigation; | |||
| using System.Windows.Shapes; | |||
| namespace FourComponentWeightClient | |||
| { | |||
| /// <summary> | |||
| /// MainWindow.xaml 的交互逻辑 | |||
| /// </summary> | |||
| public partial class MainWindow : Window | |||
| { | |||
| public MainWindow() | |||
| { | |||
| InitializeComponent(); | |||
| } | |||
| private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) | |||
| { | |||
| this.DragMove(); | |||
| } | |||
| private async void LoginBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| try | |||
| { | |||
| loginBtn.IsEnabled = false; | |||
| var username = userNameInput.Text.Trim(); | |||
| var pwd = pwdInput.Password; | |||
| if (string.IsNullOrEmpty(username)) | |||
| throw new Exception("请输入用户名"); | |||
| await Task.Factory.StartNew(() => LoginUtil.Login(username, pwd)); | |||
| var window = new FCWeightForm(); | |||
| window.Closing += delegate | |||
| { | |||
| this.Show(); | |||
| }; | |||
| window.Show(); | |||
| Hide(); | |||
| } | |||
| catch { throw; } | |||
| finally | |||
| { | |||
| loginBtn.IsEnabled = true; | |||
| } | |||
| } | |||
| private void ExistBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| App.Current.Shutdown(); | |||
| } | |||
| private void UserNameTextBoxClick(object sender, MouseButtonEventArgs e) | |||
| { | |||
| var keypad = new Keypad(this); | |||
| if (keypad.ShowDialog() == true) | |||
| { | |||
| if (string.IsNullOrEmpty(keypad.Result)) | |||
| throw new Exception("请输工号"); | |||
| userNameInput.Text = LoginUtil.GetUserNameByCode(keypad.Result); | |||
| } | |||
| } | |||
| private void PwdTextBoxClick(object sender, MouseButtonEventArgs e) | |||
| { | |||
| var keypad = new Keypad(this); | |||
| if (keypad.ShowDialog() == true) | |||
| pwdInput.Password = keypad.Result; | |||
| } | |||
| private void Image_PreviewMouseDown(object sender, MouseButtonEventArgs e) | |||
| { | |||
| new SettingDialog().ShowDialog(); | |||
| } | |||
| private void Window_Loaded(object sender, RoutedEventArgs e) | |||
| { | |||
| userNameInput.Text = AppContext.Instance.UserName; | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,55 @@ | |||
| using System.Reflection; | |||
| using System.Resources; | |||
| using System.Runtime.CompilerServices; | |||
| using System.Runtime.InteropServices; | |||
| using System.Windows; | |||
| // 有关程序集的常规信息通过以下 | |||
| // 特性集控制。更改这些特性值可修改 | |||
| // 与程序集关联的信息。 | |||
| [assembly: AssemblyTitle("FourComponentWeightClient")] | |||
| [assembly: AssemblyDescription("")] | |||
| [assembly: AssemblyConfiguration("")] | |||
| [assembly: AssemblyCompany("")] | |||
| [assembly: AssemblyProduct("FourComponentWeightClient")] | |||
| [assembly: AssemblyCopyright("Copyright © 2018")] | |||
| [assembly: AssemblyTrademark("")] | |||
| [assembly: AssemblyCulture("")] | |||
| // 将 ComVisible 设置为 false 使此程序集中的类型 | |||
| // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, | |||
| // 则将该类型上的 ComVisible 特性设置为 true。 | |||
| [assembly: ComVisible(false)] | |||
| //若要开始生成可本地化的应用程序,请在 | |||
| //<PropertyGroup> 中的 .csproj 文件中 | |||
| //设置 <UICulture>CultureYouAreCodingWith</UICulture>。 例如,如果您在源文件中 | |||
| //使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消 | |||
| //对以下 NeutralResourceLanguage 特性的注释。 更新 | |||
| //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 | |||
| //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] | |||
| [assembly: ThemeInfo( | |||
| ResourceDictionaryLocation.None, //主题特定资源词典所处位置 | |||
| //(在页面或应用程序资源词典中 | |||
| // 未找到某个资源的情况下使用) | |||
| ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 | |||
| //(在页面、应用程序或任何主题特定资源词典中 | |||
| // 未找到某个资源的情况下使用) | |||
| )] | |||
| // 程序集的版本信息由下面四个值组成: | |||
| // | |||
| // 主版本 | |||
| // 次版本 | |||
| // 生成号 | |||
| // 修订号 | |||
| // | |||
| // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, | |||
| // 方法是按如下所示使用“*”: | |||
| // [assembly: AssemblyVersion("1.0.*")] | |||
| [assembly: AssemblyVersion("1.0.0.0")] | |||
| [assembly: AssemblyFileVersion("1.0.0.0")] | |||
| @ -0,0 +1,63 @@ | |||
| //------------------------------------------------------------------------------ | |||
| // <auto-generated> | |||
| // 此代码由工具生成。 | |||
| // 运行时版本:4.0.30319.42000 | |||
| // | |||
| // 对此文件的更改可能会导致不正确的行为,并且如果 | |||
| // 重新生成代码,这些更改将会丢失。 | |||
| // </auto-generated> | |||
| //------------------------------------------------------------------------------ | |||
| namespace FourComponentWeightClient.Properties { | |||
| using System; | |||
| /// <summary> | |||
| /// 一个强类型的资源类,用于查找本地化的字符串等。 | |||
| /// </summary> | |||
| // 此类是由 StronglyTypedResourceBuilder | |||
| // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 | |||
| // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen | |||
| // (以 /str 作为命令选项),或重新生成 VS 项目。 | |||
| [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] | |||
| [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] | |||
| [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] | |||
| internal class Resources { | |||
| private static global::System.Resources.ResourceManager resourceMan; | |||
| private static global::System.Globalization.CultureInfo resourceCulture; | |||
| [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] | |||
| internal Resources() { | |||
| } | |||
| /// <summary> | |||
| /// 返回此类使用的缓存的 ResourceManager 实例。 | |||
| /// </summary> | |||
| [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] | |||
| internal static global::System.Resources.ResourceManager ResourceManager { | |||
| get { | |||
| if (object.ReferenceEquals(resourceMan, null)) { | |||
| global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FourComponentWeightClient.Properties.Resources", typeof(Resources).Assembly); | |||
| resourceMan = temp; | |||
| } | |||
| return resourceMan; | |||
| } | |||
| } | |||
| /// <summary> | |||
| /// 使用此强类型资源类,为所有资源查找 | |||
| /// 重写当前线程的 CurrentUICulture 属性。 | |||
| /// </summary> | |||
| [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] | |||
| internal static global::System.Globalization.CultureInfo Culture { | |||
| get { | |||
| return resourceCulture; | |||
| } | |||
| set { | |||
| resourceCulture = value; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,117 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <root> | |||
| <!-- | |||
| Microsoft ResX Schema | |||
| Version 2.0 | |||
| The primary goals of this format is to allow a simple XML format | |||
| that is mostly human readable. The generation and parsing of the | |||
| various data types are done through the TypeConverter classes | |||
| associated with the data types. | |||
| Example: | |||
| ... ado.net/XML headers & schema ... | |||
| <resheader name="resmimetype">text/microsoft-resx</resheader> | |||
| <resheader name="version">2.0</resheader> | |||
| <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> | |||
| <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> | |||
| <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> | |||
| <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> | |||
| <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> | |||
| <value>[base64 mime encoded serialized .NET Framework object]</value> | |||
| </data> | |||
| <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> | |||
| <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> | |||
| <comment>This is a comment</comment> | |||
| </data> | |||
| There are any number of "resheader" rows that contain simple | |||
| name/value pairs. | |||
| Each data row contains a name, and value. The row also contains a | |||
| type or mimetype. Type corresponds to a .NET class that support | |||
| text/value conversion through the TypeConverter architecture. | |||
| Classes that don't support this are serialized and stored with the | |||
| mimetype set. | |||
| The mimetype is used for serialized objects, and tells the | |||
| ResXResourceReader how to depersist the object. This is currently not | |||
| extensible. For a given mimetype the value must be set accordingly: | |||
| Note - application/x-microsoft.net.object.binary.base64 is the format | |||
| that the ResXResourceWriter will generate, however the reader can | |||
| read any of the formats listed below. | |||
| mimetype: application/x-microsoft.net.object.binary.base64 | |||
| value : The object must be serialized with | |||
| : System.Serialization.Formatters.Binary.BinaryFormatter | |||
| : and then encoded with base64 encoding. | |||
| mimetype: application/x-microsoft.net.object.soap.base64 | |||
| value : The object must be serialized with | |||
| : System.Runtime.Serialization.Formatters.Soap.SoapFormatter | |||
| : and then encoded with base64 encoding. | |||
| mimetype: application/x-microsoft.net.object.bytearray.base64 | |||
| value : The object must be serialized into a byte array | |||
| : using a System.ComponentModel.TypeConverter | |||
| : and then encoded with base64 encoding. | |||
| --> | |||
| <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> | |||
| <xsd:element name="root" msdata:IsDataSet="true"> | |||
| <xsd:complexType> | |||
| <xsd:choice maxOccurs="unbounded"> | |||
| <xsd:element name="metadata"> | |||
| <xsd:complexType> | |||
| <xsd:sequence> | |||
| <xsd:element name="value" type="xsd:string" minOccurs="0" /> | |||
| </xsd:sequence> | |||
| <xsd:attribute name="name" type="xsd:string" /> | |||
| <xsd:attribute name="type" type="xsd:string" /> | |||
| <xsd:attribute name="mimetype" type="xsd:string" /> | |||
| </xsd:complexType> | |||
| </xsd:element> | |||
| <xsd:element name="assembly"> | |||
| <xsd:complexType> | |||
| <xsd:attribute name="alias" type="xsd:string" /> | |||
| <xsd:attribute name="name" type="xsd:string" /> | |||
| </xsd:complexType> | |||
| </xsd:element> | |||
| <xsd:element name="data"> | |||
| <xsd:complexType> | |||
| <xsd:sequence> | |||
| <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |||
| <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> | |||
| </xsd:sequence> | |||
| <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> | |||
| <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> | |||
| <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> | |||
| </xsd:complexType> | |||
| </xsd:element> | |||
| <xsd:element name="resheader"> | |||
| <xsd:complexType> | |||
| <xsd:sequence> | |||
| <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> | |||
| </xsd:sequence> | |||
| <xsd:attribute name="name" type="xsd:string" use="required" /> | |||
| </xsd:complexType> | |||
| </xsd:element> | |||
| </xsd:choice> | |||
| </xsd:complexType> | |||
| </xsd:element> | |||
| </xsd:schema> | |||
| <resheader name="resmimetype"> | |||
| <value>text/microsoft-resx</value> | |||
| </resheader> | |||
| <resheader name="version"> | |||
| <value>2.0</value> | |||
| </resheader> | |||
| <resheader name="reader"> | |||
| <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||
| </resheader> | |||
| <resheader name="writer"> | |||
| <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> | |||
| </resheader> | |||
| </root> | |||
| @ -0,0 +1,26 @@ | |||
| //------------------------------------------------------------------------------ | |||
| // <auto-generated> | |||
| // 此代码由工具生成。 | |||
| // 运行时版本:4.0.30319.42000 | |||
| // | |||
| // 对此文件的更改可能会导致不正确的行为,并且如果 | |||
| // 重新生成代码,这些更改将会丢失。 | |||
| // </auto-generated> | |||
| //------------------------------------------------------------------------------ | |||
| namespace FourComponentWeightClient.Properties { | |||
| [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] | |||
| [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] | |||
| internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { | |||
| private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); | |||
| public static Settings Default { | |||
| get { | |||
| return defaultInstance; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,7 @@ | |||
| <?xml version='1.0' encoding='utf-8'?> | |||
| <SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> | |||
| <Profiles> | |||
| <Profile Name="(Default)" /> | |||
| </Profiles> | |||
| <Settings /> | |||
| </SettingsFile> | |||
| @ -0,0 +1,11 @@ | |||
| <Window x:Class="FourComponentWeightClient.SettingDialog" | |||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
| Title="系统设置" Height="200" Width="500" ShowInTaskbar="False" | |||
| WindowStartupLocation="CenterOwner" ResizeMode="NoResize" FontSize="16"> | |||
| <Grid> | |||
| <TextBlock Text="服务器地址" Margin="30,40,0,0" Width="80" Height="30" HorizontalAlignment="Left" VerticalAlignment="Top"/> | |||
| <TextBox x:Name="urlBox" Margin="120,36,0,0" Width="340" Height="32" HorizontalAlignment="Left" VerticalAlignment="Top" VerticalContentAlignment="Center" Padding="10,0" PreviewMouseLeftButtonDown="urlBox_PreviewMouseLeftButtonDown"/> | |||
| <Button Margin="0,80,0,0" Content="保存" Height="40" Width="120" Click="Button_Click"/> | |||
| </Grid> | |||
| </Window> | |||
| @ -0,0 +1,45 @@ | |||
| using Forks.JsonRpc.Client; | |||
| using FourComponentWeightClient.Utils; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| using System.Windows; | |||
| using System.Windows.Controls; | |||
| using System.Windows.Data; | |||
| using System.Windows.Documents; | |||
| using System.Windows.Input; | |||
| using System.Windows.Media; | |||
| using System.Windows.Media.Imaging; | |||
| using System.Windows.Shapes; | |||
| namespace FourComponentWeightClient | |||
| { | |||
| /// <summary> | |||
| /// SettingDialog.xaml 的交互逻辑 | |||
| /// </summary> | |||
| public partial class SettingDialog : Window | |||
| { | |||
| public SettingDialog() | |||
| { | |||
| InitializeComponent(); | |||
| urlBox.Text = AppContext.Instance.Url; | |||
| } | |||
| private void Button_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| if (string.IsNullOrEmpty(urlBox.Text)) | |||
| throw new Exception("服务器地址不能为空"); | |||
| AppContext.Instance.Url = urlBox.Text; | |||
| XmlUtil.SerializerObjToFile(AppContext.Instance); | |||
| AppContext.ReInitRpc(); | |||
| MessageBox.Show("保存成功!"); | |||
| } | |||
| private void urlBox_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) | |||
| { | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,51 @@ | |||
| using Forks.JsonRpc.Client; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| using System.Xml.Serialization; | |||
| namespace FourComponentWeightClient.Utils | |||
| { | |||
| public class AppContext | |||
| { | |||
| private static AppContext inst = null; | |||
| public static AppContext Instance | |||
| { | |||
| get | |||
| { | |||
| if (inst == null) | |||
| inst = XmlUtil.DeserializeFromFile<AppContext>(); | |||
| return inst; | |||
| } | |||
| } | |||
| public string Url { get; set; } | |||
| public string UserName { get; set; } | |||
| [XmlIgnore] | |||
| public bool RpcInited { get; set; } | |||
| public static void ReInitRpc() | |||
| { | |||
| if (AppContext.Instance.RpcInited) | |||
| RpcFacade.ReInit(AppContext.Instance.Url); | |||
| else | |||
| { | |||
| RpcFacade.Init(AppContext.Instance.Url, "fourCompWeight"); | |||
| AppContext.Instance.RpcInited = true; | |||
| } | |||
| } | |||
| public static void InitRpc() | |||
| { | |||
| if (!AppContext.Instance.RpcInited) | |||
| { | |||
| RpcFacade.Init(AppContext.Instance.Url, "fourCompWeight"); | |||
| AppContext.Instance.RpcInited = true; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,62 @@ | |||
| <Window x:Class="FourComponentWeightClient.Utils.Keypad" | |||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
| Title="键盘" Height="313" Width="299" ShowInTaskbar="False" | |||
| WindowStartupLocation="CenterOwner" ResizeMode="NoResize"> | |||
| <Window.Resources> | |||
| <DropShadowEffect x:Key="DropShadowEffect" ShadowDepth="1" Direction="-90" BlurRadius="3" /> | |||
| <Style TargetType="Label"> | |||
| <Setter Property="FontSize" Value="22"/> | |||
| <Setter Property="Label.Effect" Value="{StaticResource DropShadowEffect}"/> | |||
| </Style> | |||
| <LinearGradientBrush x:Key="IPhoneSteelBackground" EndPoint="0.5,1.272" StartPoint="0.5,0"> | |||
| <GradientStop Color="#FF9097A3" Offset="0"/> | |||
| <GradientStop Color="#FF444D5B" Offset="1"/> | |||
| </LinearGradientBrush> | |||
| <Style TargetType="Button"> | |||
| <EventSetter Event="Click" Handler="button_Click" /> | |||
| <Setter Property="Margin" Value="4"/> | |||
| <Setter Property="Button.Effect" Value="{StaticResource DropShadowEffect}"/> | |||
| <Setter Property="FontSize" Value="22"/> | |||
| <Setter Property="Background" Value="WhiteSmoke"/> | |||
| <Setter Property="RenderTransform"> | |||
| <Setter.Value> | |||
| <!-- Workaround for ATI video cards that don't render good with dropshadoweffect--> | |||
| <RotateTransform Angle="0.00000000001"/> | |||
| </Setter.Value> | |||
| </Setter> | |||
| </Style> | |||
| </Window.Resources> | |||
| <Grid Background="{DynamicResource IPhoneSteelBackground}"> | |||
| <Grid.RowDefinitions> | |||
| <RowDefinition /> | |||
| <RowDefinition /> | |||
| <RowDefinition /> | |||
| <RowDefinition /> | |||
| <RowDefinition /> | |||
| </Grid.RowDefinitions> | |||
| <Grid.ColumnDefinitions> | |||
| <ColumnDefinition /> | |||
| <ColumnDefinition /> | |||
| <ColumnDefinition /> | |||
| <ColumnDefinition /> | |||
| </Grid.ColumnDefinitions> | |||
| <Button Grid.Row="1" Grid.Column="0" BorderThickness="1" BorderBrush="Gray" CommandParameter="NUMPAD7" >7</Button> | |||
| <Button Grid.Row="1" Grid.Column="1" CommandParameter="NUMPAD8" BorderThickness="1" Content="8" /> | |||
| <Button Grid.Row="1" Grid.Column="2" CommandParameter="NUMPAD9" Content="9" /> | |||
| <Button Grid.Row="1" Grid.Column="3" CommandParameter="BACK" > | |||
| <Path Stretch="Fill" Width="36" Height="24" Data="F1M555.0371,274.4893L552.7871,276.7383L549.9861,273.9373L547.1991,276.7243L545.1131,274.6393L547.9001,271.8523L545.0101,268.9603L547.2601,266.7113L550.1501,269.6023L552.8921,266.8613L554.9761,268.9463L552.2361,271.6883z M555.3751,264.0003L544.8751,264.0003C543.1251,264.1253,535.0001,270.7503,535.0001,272.2503C535.0001,273.7503,543.1251,279.3753,544.8751,279.5003L555.3751,279.5003C558.8751,279.5003,559.3751,277.7093,559.3751,275.5003L559.3751,268.0003C559.3751,265.7913,558.7501,264.0003,555.3751,264.0003" Fill="#FF333333"/> | |||
| </Button> | |||
| <Button Grid.Row="2" Grid.Column="0" x:Name="button9" CommandParameter="NUMPAD4" Content="4"/> | |||
| <Button Grid.Row="2" Grid.Column="1" CommandParameter="NUMPAD5" Content="5" /> | |||
| <Button Grid.Row="2" Grid.Column="2" CommandParameter="NUMPAD6" Content="6" /> | |||
| <Button Grid.Row="3" Grid.Column="0" CommandParameter="NUMPAD1" Content="1"/> | |||
| <Button Grid.Row="3" Grid.Column="1" CommandParameter="NUMPAD2" Content="2"/> | |||
| <Button Grid.Row="3" Grid.Column="2" CommandParameter="NUMPAD3" Content="3" /> | |||
| <Button Grid.Row="2" Grid.Column="3" Grid.RowSpan="3" CommandParameter="RETURN" Content="确认"/> | |||
| <Button Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" CommandParameter="NUMPAD0" Content="0" /> | |||
| <Button Grid.Row="4" Grid.Column="2" CommandParameter="DECIMAL" Content="." /> | |||
| <Label Grid.Column="0" Grid.ColumnSpan="4" x:Name="lbl" Content="{Binding Result}" HorizontalContentAlignment="Right" Background="WhiteSmoke" Margin="4"/> | |||
| </Grid> | |||
| </Window> | |||
| @ -0,0 +1,84 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.ComponentModel; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| using System.Windows; | |||
| using System.Windows.Controls; | |||
| using System.Windows.Data; | |||
| using System.Windows.Documents; | |||
| using System.Windows.Input; | |||
| using System.Windows.Media; | |||
| using System.Windows.Media.Imaging; | |||
| using System.Windows.Shapes; | |||
| namespace FourComponentWeightClient.Utils | |||
| { | |||
| /// <summary> | |||
| /// Keypad.xaml 的交互逻辑 | |||
| /// </summary> | |||
| public partial class Keypad : Window, INotifyPropertyChanged | |||
| { | |||
| #region Public Properties | |||
| private string _result; | |||
| public string Result | |||
| { | |||
| get { return _result; } | |||
| private set { | |||
| if (_result != value) | |||
| { | |||
| _result = value; | |||
| this.OnPropertyChanged("Result"); | |||
| } | |||
| } | |||
| } | |||
| #endregion | |||
| public Keypad(Window owner) | |||
| { | |||
| InitializeComponent(); | |||
| this.Owner = owner; | |||
| lbl.DataContext = this; | |||
| } | |||
| private void button_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| Button button = sender as Button; | |||
| switch (button.CommandParameter.ToString()) | |||
| { | |||
| case "ESC": | |||
| this.Close(); | |||
| break; | |||
| case "RETURN": | |||
| this.DialogResult = true; | |||
| break; | |||
| case "BACK": | |||
| if (Result.Length > 0) | |||
| Result = Result.Remove(Result.Length - 1); | |||
| break; | |||
| default: | |||
| Result += button.Content.ToString(); | |||
| break; | |||
| } | |||
| } | |||
| #region INotifyPropertyChanged members | |||
| public event PropertyChangedEventHandler PropertyChanged; | |||
| private void OnPropertyChanged(String info) | |||
| { | |||
| if (PropertyChanged != null) | |||
| { | |||
| PropertyChanged(this, new PropertyChangedEventArgs(info)); | |||
| } | |||
| } | |||
| #endregion | |||
| } | |||
| } | |||
| @ -0,0 +1,27 @@ | |||
| using Forks.JsonRpc.Client; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| namespace FourComponentWeightClient.Utils | |||
| { | |||
| public static class LoginUtil | |||
| { | |||
| public static void Login(string userName, string pwd) | |||
| { | |||
| AppContext.InitRpc(); | |||
| RpcFacade.Login(userName, pwd); | |||
| AppContext.Instance.UserName = userName; | |||
| XmlUtil.SerializerObjToFile(AppContext.Instance); | |||
| } | |||
| internal static string GetUserNameByCode(string code) | |||
| { | |||
| AppContext.InitRpc(); | |||
| var method = "/MainSystem/B3CowButcherManage/Rpcs/ClientRpc/GetWpfUserName"; | |||
| var result = RpcFacade.Call<string>(method, code); | |||
| return result; | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,40 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.IO; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| namespace FourComponentWeightClient.Utils | |||
| { | |||
| public class WeightConfig | |||
| { | |||
| public string WeightSet { get; set; } | |||
| public string ComSet { get; set; } | |||
| public int? RateSet { get; set; } | |||
| public int? BitSet { get; set; } | |||
| public string Format { get; set; } | |||
| public decimal? Discont { get; set; } | |||
| public int WeightType { get; set; } | |||
| public decimal MinWeight { get; set; } | |||
| public decimal MaxWeight { get; set; } | |||
| public static WeightConfig Init(string flag) | |||
| { | |||
| return XmlUtil.DeserializeFromFile<WeightConfig>(); | |||
| } | |||
| public void Save(string flag) | |||
| { | |||
| XmlUtil.SerializerObjToFile(this); | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,47 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.IO; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| using System.Xml.Serialization; | |||
| namespace FourComponentWeightClient.Utils | |||
| { | |||
| public static class XmlUtil | |||
| { | |||
| static string config = "Config"; | |||
| public static void SerializerObjToFile(object obj, string fileName = "") | |||
| { | |||
| if (string.IsNullOrWhiteSpace(fileName)) | |||
| { | |||
| fileName = Path.Combine(config, obj.GetType().Name + ".xml"); | |||
| } | |||
| var ser = new XmlSerializer(obj.GetType()); | |||
| using (var stream = File.Open(fileName, FileMode.Create)) | |||
| { | |||
| ser.Serialize(stream, obj); | |||
| } | |||
| } | |||
| public static T DeserializeFromFile<T>(string fileName = "") | |||
| where T : new() | |||
| { | |||
| if (string.IsNullOrWhiteSpace(fileName)) | |||
| { | |||
| fileName = Path.Combine(config, typeof(T).Name + ".xml"); | |||
| } | |||
| if (!File.Exists(fileName)) | |||
| { | |||
| return new T(); | |||
| } | |||
| using (var reader = new StreamReader(fileName)) | |||
| { | |||
| var xs = new XmlSerializer(typeof(T)); | |||
| object obj = xs.Deserialize(reader); | |||
| reader.Close(); | |||
| return (T)obj; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,14 @@ | |||
| <UserControl x:Class="FourComponentWeightClient.WeightControl" | |||
| 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" | |||
| mc:Ignorable="d" Width="240" Height="80" MinHeight="80" MinWidth="240"> | |||
| <Grid> | |||
| <Border CornerRadius="5" Background="Black" Height="75" Margin="2,2,87,2" HorizontalAlignment="Stretch"> | |||
| <Label Name="lblChengZhong" Content="0" Foreground="Red" FontSize="28" FontFamily="DigifaceWide" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> | |||
| </Border> | |||
| <Button Name="weightSetBtn" Content="称设置" HorizontalAlignment="Right" Margin="0,2,2,0" VerticalAlignment="Top" Width="80" Height="35" FontSize="15" Click="weightSetBtn_Click"/> | |||
| <Button Name="weightSwitch" Content="启用称重" HorizontalAlignment="Right" Margin="0,0,2,2" VerticalAlignment="Bottom" Width="80" Height="35" FontSize="15" Click="weightSwitch_Click"/> | |||
| </Grid> | |||
| </UserControl> | |||
| @ -0,0 +1,323 @@ | |||
| using FourComponentWeightClient.DataFormat; | |||
| using FourComponentWeightClient.Utils; | |||
| using System; | |||
| using System.Collections.Concurrent; | |||
| using System.Collections.Generic; | |||
| using System.ComponentModel; | |||
| using System.IO.Ports; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading; | |||
| using System.Threading.Tasks; | |||
| using System.Windows; | |||
| using System.Windows.Controls; | |||
| using System.Windows.Data; | |||
| using System.Windows.Documents; | |||
| using System.Windows.Input; | |||
| using System.Windows.Media; | |||
| using System.Windows.Media.Imaging; | |||
| using System.Windows.Navigation; | |||
| using System.Windows.Shapes; | |||
| namespace FourComponentWeightClient | |||
| { | |||
| /// <summary> | |||
| /// WeightControl.xaml 的交互逻辑 | |||
| /// </summary> | |||
| public partial class WeightControl : UserControl | |||
| { | |||
| WeightConfig config; | |||
| SerialPort weightPort; | |||
| IDataFormat _dataFormat; | |||
| Thread _inQueryThread; | |||
| private bool _mainProcessIsRun; | |||
| readonly StringBuilder _dataStrBuilder = new StringBuilder(); | |||
| private bool switchOn; | |||
| [Browsable(true), Description("称设置标识")] | |||
| public string WeightFalg { get; set; } | |||
| [Browsable(true), Description("读取到值的事件")] | |||
| public event Action<decimal> ReceivedValue; | |||
| [Browsable(false)] | |||
| public decimal Weight | |||
| { | |||
| get | |||
| { | |||
| var v = Convert.ToDecimal(lblChengZhong.Content); | |||
| if (config != null) | |||
| v -= (config.Discont ?? 0); | |||
| return v; | |||
| } | |||
| } | |||
| [Browsable(false)] | |||
| public bool SwitchOn | |||
| { | |||
| get | |||
| { | |||
| return switchOn; | |||
| } | |||
| } | |||
| [Browsable(false)] | |||
| public decimal? Discont { get { return config.Discont; } } | |||
| public WeightControl() | |||
| { | |||
| InitializeComponent(); | |||
| this.Loaded += WeightControl_Loaded; | |||
| } | |||
| void WeightControl_Loaded(object sender, RoutedEventArgs e) | |||
| { | |||
| var parentWindow = Window.GetWindow(this); | |||
| if (parentWindow != null) | |||
| { | |||
| parentWindow.Closing += delegate | |||
| { | |||
| if (_inQueryThread != null && _inQueryThread.IsAlive) | |||
| { | |||
| DisableWeight(); | |||
| } | |||
| }; | |||
| } | |||
| } | |||
| private void weightSetBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| if (new WeightSetForm(WeightFalg).ShowDialog() == true) | |||
| config = WeightConfig.Init(WeightFalg); | |||
| } | |||
| private void weightSwitch_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| try | |||
| { | |||
| if (config == null) | |||
| { | |||
| config = WeightConfig.Init(WeightFalg); | |||
| WeighAvgControl.config = config; | |||
| } | |||
| weightSetBtn.IsEnabled = switchOn; | |||
| switchOn = !switchOn; | |||
| ChangeWeightBtnState(); | |||
| if (switchOn) | |||
| { | |||
| OpenSerialPort(); | |||
| _mainProcessIsRun = true; | |||
| ReadData(); | |||
| } | |||
| else | |||
| { | |||
| DisableWeight(); | |||
| } | |||
| } | |||
| catch | |||
| { | |||
| switchOn = !switchOn; | |||
| weightSetBtn.IsEnabled = !switchOn; | |||
| ChangeWeightBtnState(); | |||
| throw; | |||
| } | |||
| finally | |||
| { | |||
| this.Focus(); | |||
| } | |||
| } | |||
| void ChangeWeightBtnState() | |||
| { | |||
| if (switchOn) | |||
| weightSwitch.Content = "停止称重"; | |||
| else | |||
| weightSwitch.Content = "启用称重"; | |||
| } | |||
| void OpenSerialPort() | |||
| { | |||
| if (!switchOn) | |||
| return; | |||
| if (config.RateSet == null) | |||
| throw new Exception("请先配置称相关信息"); | |||
| weightPort = new SerialPort(); | |||
| weightPort.PortName = config.ComSet; | |||
| weightPort.BaudRate = config.RateSet.Value; | |||
| weightPort.DataBits = config.BitSet.Value; | |||
| weightPort.ReadBufferSize = 4096 * 100; | |||
| if (!string.IsNullOrEmpty(config.Format)) | |||
| format = "{0:{format}}".Replace("{format}", config.Format); | |||
| switch (config.WeightSet) | |||
| { | |||
| case "IND560": | |||
| _dataFormat = new IND560DataFormat(); | |||
| break; | |||
| case "Xk3124": | |||
| case "IND231": | |||
| _dataFormat = new Xk3124DataFormat(); | |||
| break; | |||
| case "Xk3190A9": | |||
| _dataFormat = new Xk3190A9DataFormat(); | |||
| break; | |||
| } | |||
| if (!weightPort.IsOpen) | |||
| { | |||
| try | |||
| { | |||
| weightPort.Open(); | |||
| } | |||
| catch (InvalidOperationException) | |||
| { | |||
| throw new Exception("指定的端口已打开"); | |||
| } | |||
| catch (UnauthorizedAccessException) | |||
| { | |||
| throw new Exception("对端口的访问被拒绝"); | |||
| } | |||
| } | |||
| } | |||
| void ReadData() | |||
| { | |||
| _inQueryThread = new Thread(InQuery); | |||
| _inQueryThread.Start(); | |||
| } | |||
| string format = "{0:0.00}"; | |||
| private void InQuery() | |||
| { | |||
| while (_mainProcessIsRun) | |||
| { | |||
| int availableCount = weightPort.BytesToRead; | |||
| if (availableCount == 0) | |||
| { | |||
| Thread.Sleep(10); | |||
| } | |||
| char[] buffer = new char[availableCount]; | |||
| weightPort.Read(buffer, 0, availableCount); | |||
| foreach (var c in buffer) | |||
| { | |||
| if (c == _dataFormat.Beginchar) | |||
| { | |||
| _dataStrBuilder.Clear(); | |||
| _dataStrBuilder.Append(c); | |||
| } | |||
| else if (c == _dataFormat.Endchar || _dataStrBuilder.Length > _dataFormat.Bufsize) | |||
| { | |||
| _dataStrBuilder.Append(c); | |||
| bool isStatic; | |||
| string str=string.Empty; | |||
| if (_dataFormat.ParseAscii(_dataStrBuilder.ToString(), out str, out isStatic)) | |||
| { | |||
| if (config.WeightType == 0) | |||
| { | |||
| if (string.IsNullOrEmpty(str)) | |||
| str = "0"; | |||
| this.Dispatcher.Invoke(new Action(delegate() | |||
| { | |||
| decimal v = 0; | |||
| decimal.TryParse(str, out v); | |||
| lblChengZhong.Content = string.Format(format, v); | |||
| if (str != "0") | |||
| { | |||
| if (ReceivedValue != null) | |||
| ReceivedValue(v - (config.Discont ?? 0)); | |||
| } | |||
| })); | |||
| } | |||
| else | |||
| { | |||
| decimal num = 0; | |||
| if (decimal.TryParse(str, out num)) | |||
| { | |||
| this.Dispatcher.Invoke(new Action(delegate() | |||
| { | |||
| lblChengZhong.Content = string.Format(format, num); | |||
| })); | |||
| WeighAvgControl.Add(num, isStatic); | |||
| } | |||
| if (WeighAvgControl.TryGetValue(out num)) | |||
| { | |||
| this.Dispatcher.Invoke(new Action(delegate() | |||
| { | |||
| if (str != "0") | |||
| { | |||
| if (ReceivedValue != null) | |||
| ReceivedValue(num - (config.Discont ?? 0)); | |||
| } | |||
| })); | |||
| } | |||
| } | |||
| } | |||
| _dataStrBuilder.Clear(); | |||
| } | |||
| else | |||
| { | |||
| _dataStrBuilder.Append(c); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| private class WeighAvgControl | |||
| { | |||
| public static WeightConfig config; | |||
| public static bool TryGetValue(out decimal result) | |||
| { | |||
| List<Tuple<decimal, bool>> list = null; | |||
| if (mWeighList.TryDequeue(out list)) | |||
| { | |||
| var r = list.Where(x => x.Item2).Select(x => x.Item1).GroupBy(x => x); | |||
| var firstOrDefault = r.OrderByDescending(x => x.Count()).FirstOrDefault(); | |||
| if (firstOrDefault != null) | |||
| { | |||
| result = firstOrDefault.Key; | |||
| return true; | |||
| } | |||
| result = 0; | |||
| return false; | |||
| } | |||
| result = 0; | |||
| return false; | |||
| } | |||
| static ConcurrentQueue<List<Tuple<decimal, bool>>> mWeighList = new ConcurrentQueue<List<Tuple<decimal, bool>>>(); | |||
| static List<Tuple<decimal, bool>> _list = new List<Tuple<decimal, bool>>(); | |||
| public static void Add(decimal value, bool isStatic) | |||
| { | |||
| if (value >= config.MinWeight && value <= config.MaxWeight) | |||
| { | |||
| _list.Add(new Tuple<decimal, bool>(value, isStatic)); | |||
| } | |||
| else | |||
| { | |||
| if (_list.Count > 0) | |||
| { | |||
| mWeighList.Enqueue(_list); | |||
| _list = new List<Tuple<decimal, bool>>(); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| void DisableWeight() | |||
| { | |||
| _mainProcessIsRun = false; | |||
| lblChengZhong.Content = string.Format(format, 0); | |||
| format = "{0:0.00}"; | |||
| Thread.Sleep(10); | |||
| if (_inQueryThread.IsAlive) | |||
| { | |||
| _inQueryThread.Abort(); | |||
| } | |||
| if (weightPort.IsOpen) | |||
| weightPort.Close(); | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,21 @@ | |||
| <Window x:Class="FourComponentWeightClient.WeightSetForm" | |||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |||
| Title="称设置" Height="420" Width="300" ResizeMode="NoResize" WindowStartupLocation="CenterOwner" FontSize="18"> | |||
| <Grid > | |||
| <TextBlock Text="称型号" HorizontalAlignment="Left" Margin="40,30,0,0" VerticalAlignment="Top"/> | |||
| <ComboBox Name="weightSet" HorizontalAlignment="Stretch" Margin="110,28,40,0" VerticalAlignment="Top" /> | |||
| <TextBlock Text="端口号" HorizontalAlignment="Left" Margin="40,80,0,0" VerticalAlignment="Top"/> | |||
| <ComboBox Name="comSet" HorizontalAlignment="Stretch" Margin="110,78,40,0" VerticalAlignment="Top" /> | |||
| <TextBlock Text="波特率" HorizontalAlignment="Left" Margin="40,130,0,0" VerticalAlignment="Top"/> | |||
| <ComboBox Name="rateSet" HorizontalAlignment="Stretch" Margin="110,128,40,0" VerticalAlignment="Top" /> | |||
| <TextBlock Text="数据位" HorizontalAlignment="Left" Margin="40,180,0,0" VerticalAlignment="Top"/> | |||
| <ComboBox Name="bitSet" HorizontalAlignment="Stretch" Margin="110,178,40,0" VerticalAlignment="Top" /> | |||
| <TextBlock Text="显示格式" HorizontalAlignment="Left" Margin="23,230,0,0" VerticalAlignment="Top"/> | |||
| <TextBox Name="format" HorizontalAlignment="Stretch" Height="28" VerticalContentAlignment="Center" Margin="110,228,40,0" VerticalAlignment="Top" /> | |||
| <TextBlock Text="扣重" HorizontalAlignment="Left" Margin="55,280,0,0" VerticalAlignment="Top"/> | |||
| <TextBox Name="discont" HorizontalAlignment="Stretch" Height="28" VerticalContentAlignment="Center" Margin="110,278,40,0" VerticalAlignment="Top" /> | |||
| <Button Name="saveBtn" Content="保存" HorizontalAlignment="Left" Margin="53,0,0,25" VerticalAlignment="Bottom" Width="75" Height="35" Click="saveBtn_Click"/> | |||
| <Button Name="closeBtn" Content="关闭" HorizontalAlignment="Left" Margin="170,0,0,25" VerticalAlignment="Bottom" Width="75" Height="35" Click="closeBtn_Click"/> | |||
| </Grid> | |||
| </Window> | |||
| @ -0,0 +1,95 @@ | |||
| using FourComponentWeightClient.Utils; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using System.Threading.Tasks; | |||
| using System.Windows; | |||
| using System.Windows.Controls; | |||
| using System.Windows.Data; | |||
| using System.Windows.Documents; | |||
| using System.Windows.Input; | |||
| using System.Windows.Media; | |||
| using System.Windows.Media.Imaging; | |||
| using System.Windows.Shapes; | |||
| namespace FourComponentWeightClient | |||
| { | |||
| /// <summary> | |||
| /// WeightSetForm.xaml 的交互逻辑 | |||
| /// </summary> | |||
| public partial class WeightSetForm : Window | |||
| { | |||
| List<string> weight = new List<string> { "IND560", "Xk3124", "Xk3190A9"}; | |||
| List<string> com = new List<string> { "COM1", "COM2", "COM3", "COM4", "COM5" }; | |||
| List<string> rate = new List<string> { "1200", "2400", "4800", "7200", "9600" }; | |||
| List<string> bit = new List<string> { "5", "6", "7", "8" }; | |||
| string _flag; | |||
| WeightConfig config; | |||
| public WeightSetForm(string flag) | |||
| { | |||
| this._flag = flag; | |||
| InitializeComponent(); | |||
| weightSet.ItemsSource = weight; | |||
| comSet.ItemsSource = com; | |||
| rateSet.ItemsSource = rate; | |||
| bitSet.ItemsSource = bit; | |||
| config = WeightConfig.Init(flag); | |||
| if (!string.IsNullOrEmpty(config.WeightSet)) | |||
| weightSet.SelectedIndex = weight.IndexOf(config.WeightSet); | |||
| else | |||
| weightSet.SelectedIndex = 0; | |||
| if (!string.IsNullOrEmpty(config.ComSet)) | |||
| comSet.SelectedIndex = com.IndexOf(config.ComSet); | |||
| else | |||
| comSet.SelectedIndex = 0; | |||
| if (config.RateSet.HasValue) | |||
| rateSet.SelectedIndex = rate.IndexOf(config.RateSet.ToString()); | |||
| else | |||
| rateSet.SelectedIndex = 2; | |||
| if (config.BitSet.HasValue) | |||
| bitSet.SelectedIndex = bit.IndexOf(config.BitSet.ToString()); | |||
| else | |||
| bitSet.SelectedIndex = 3; | |||
| if (string.IsNullOrEmpty(config.Format)) | |||
| format.Text = "0.00"; | |||
| else | |||
| format.Text = config.Format; | |||
| if (config.Discont == null) | |||
| discont.Text = "0.00"; | |||
| else | |||
| discont.Text = config.Discont.ToString(); | |||
| } | |||
| bool changed; | |||
| private void saveBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| config.WeightSet = weight[this.weightSet.SelectedIndex]; | |||
| config.ComSet = com[this.comSet.SelectedIndex]; | |||
| config.RateSet = int.Parse(rate[this.rateSet.SelectedIndex]); | |||
| config.BitSet = int.Parse(bit[this.bitSet.SelectedIndex]); | |||
| config.Format = format.Text; | |||
| if (!string.IsNullOrEmpty(discont.Text)) | |||
| { | |||
| decimal v; | |||
| if (decimal.TryParse(discont.Text, out v)) | |||
| config.Discont = v; | |||
| else | |||
| throw new Exception("扣重格式输入不正确"); | |||
| } | |||
| else | |||
| config.Discont = 0; | |||
| config.Save(_flag); | |||
| changed = true; | |||
| MessageBox.Show("保存成功!"); | |||
| } | |||
| private void closeBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| if (changed) | |||
| DialogResult = true; | |||
| this.Close(); | |||
| } | |||
| } | |||
| } | |||
| @ -0,0 +1,3 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <configuration> | |||
| <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration> | |||