commit bec7d4e1d5f80f61547f1d0942ee0d5782e4dee1
Author: yibo <361071264@qq.com>
Date: Mon Feb 18 13:45:30 2019 +0800
init
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f83ed3c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+.*
+*.TMP
+*.suo
+*.user
+obj
+bin
diff --git a/B3DealerClient.sln b/B3DealerClient.sln
new file mode 100644
index 0000000..840f118
--- /dev/null
+++ b/B3DealerClient.sln
@@ -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}") = "B3DealerClient", "B3DealerClient\B3DealerClient.csproj", "{24AC5416-A243-485A-BC71-533606677CA3}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {24AC5416-A243-485A-BC71-533606677CA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {24AC5416-A243-485A-BC71-533606677CA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {24AC5416-A243-485A-BC71-533606677CA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {24AC5416-A243-485A-BC71-533606677CA3}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/B3DealerClient/App.config b/B3DealerClient/App.config
new file mode 100644
index 0000000..fad249e
--- /dev/null
+++ b/B3DealerClient/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/B3DealerClient/App.xaml b/B3DealerClient/App.xaml
new file mode 100644
index 0000000..725a37f
--- /dev/null
+++ b/B3DealerClient/App.xaml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/B3DealerClient/App.xaml.cs b/B3DealerClient/App.xaml.cs
new file mode 100644
index 0000000..128b6ac
--- /dev/null
+++ b/B3DealerClient/App.xaml.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace B3DealerClient
+{
+ ///
+ /// App.xaml 的交互逻辑
+ ///
+ public partial class App : Application
+ {
+ public App()
+ {
+ App.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException);
+ AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
+ }
+
+ private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
+ {
+ MessageBox.Show(e.Exception.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ //LogHelper.Error(e.Exception.Message, e.Exception);
+ e.Handled = true;
+ }
+
+ private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
+ {
+ var ex = e.ExceptionObject as Exception;
+ if (ex != null)
+ {
+ MessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
+ //LogHelper.Error(ex.Message, ex);
+ }
+ }
+
+
+ EventWaitHandle ProgramStarted;
+ readonly string[] FOLDERS = new string[] { "Config", "Log" };
+ protected override void OnStartup(StartupEventArgs e)
+ {
+ //bool createNew;
+ //ProgramStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "PigButcherManageSolution.Windows", out createNew);
+
+ //if (!createNew)
+ //{
+ // MessageBox.Show(@"系统已经在运行中,如果要重新启动,请从进程中关闭...", @"系统警告");
+ // App.Current.Shutdown();
+ //}
+
+ base.OnStartup(e);
+ foreach (var folder in FOLDERS)
+ {
+ if (!System.IO.Directory.Exists(folder))
+ System.IO.Directory.CreateDirectory(folder);
+ }
+ }
+ }
+}
diff --git a/B3DealerClient/B3DealerClient.csproj b/B3DealerClient/B3DealerClient.csproj
new file mode 100644
index 0000000..52621d4
--- /dev/null
+++ b/B3DealerClient/B3DealerClient.csproj
@@ -0,0 +1,244 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {24AC5416-A243-485A-BC71-533606677CA3}
+ WinExe
+ Properties
+ B3DealerClient
+ B3DealerClient
+ v4.5
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+ app.ico
+
+
+
+ False
+ ..\..\..\..\..\MyFolder\Company\Code\BwpB3DealerProject\TSREF\release\Forks.EnterpriseServices.dll
+
+
+ False
+ ..\..\..\..\..\MyFolder\Company\Code\BwpB3DealerProject\TSREF\release\Forks.JsonRpc.Client.dll
+
+
+ False
+ ..\..\..\..\..\MyFolder\Company\Code\BwpB3DealerProject\TSREF\release\Forks.Utils.dll
+
+
+ False
+ ..\..\..\..\..\MyFolder\Company\Code\BwpB3DealerProject\TSREF\release\Newtonsoft.Json.dll
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+
+
+
+
+
+ NumberPad.xaml
+
+
+
+ WeightControl.xaml
+
+
+ WeightSettingWindow.xaml
+
+
+ FunctionSelectDialog.xaml
+
+
+ LoginWindow.xaml
+
+
+ SettingDialog.xaml
+
+
+
+
+
+
+
+ CarcassInStoreWindow.xaml
+
+
+ CarcassSaleOutWindow.xaml
+
+
+ FreshInStoreWindow.xaml
+
+
+ FreshSaleOutWindow.xaml
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+
+
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+ Designer
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+ Designer
+ MSBuild:Compile
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/B3DealerClient/BL/LoginBL.cs b/B3DealerClient/BL/LoginBL.cs
new file mode 100644
index 0000000..e9273c1
--- /dev/null
+++ b/B3DealerClient/BL/LoginBL.cs
@@ -0,0 +1,26 @@
+using Forks.JsonRpc.Client;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace B3DealerClient.BL
+{
+ class LoginBL
+ {
+ internal static string GetUserNameByCode(string code)
+ {
+ var method = "/MainSystem/B3Dealer/Rpcs/BaseInfoRpc/GetUserNameByEmployeeCode";
+ var result = RpcFacade.Call(method, code);
+ if (string.IsNullOrEmpty(result))
+ throw new Exception("编码错误");
+ return result;
+ }
+
+ internal static void Login(string userName, string pwd)
+ {
+ RpcFacade.Login(userName, pwd);
+ }
+ }
+}
diff --git a/B3DealerClient/Control/DataFormat/DataFormat.cs b/B3DealerClient/Control/DataFormat/DataFormat.cs
new file mode 100644
index 0000000..e9faeb5
--- /dev/null
+++ b/B3DealerClient/Control/DataFormat/DataFormat.cs
@@ -0,0 +1,70 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace B3DealerClient.Control
+{
+ 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);
+ }
+}
diff --git a/B3DealerClient/Control/DataFormat/IND560DataFormat.cs b/B3DealerClient/Control/DataFormat/IND560DataFormat.cs
new file mode 100644
index 0000000..83c0998
--- /dev/null
+++ b/B3DealerClient/Control/DataFormat/IND560DataFormat.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace B3DealerClient.Control
+{
+ 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;
+ }
+ }
+}
diff --git a/B3DealerClient/Control/DataFormat/Xk3124DataFormat.cs b/B3DealerClient/Control/DataFormat/Xk3124DataFormat.cs
new file mode 100644
index 0000000..9402bb5
--- /dev/null
+++ b/B3DealerClient/Control/DataFormat/Xk3124DataFormat.cs
@@ -0,0 +1,121 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace B3DealerClient.Control
+{
+ 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;
+ }
+ }
+}
diff --git a/B3DealerClient/Control/DataFormat/Xk3190A9DataFormat.cs b/B3DealerClient/Control/DataFormat/Xk3190A9DataFormat.cs
new file mode 100644
index 0000000..674005f
--- /dev/null
+++ b/B3DealerClient/Control/DataFormat/Xk3190A9DataFormat.cs
@@ -0,0 +1,136 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace B3DealerClient.Control
+{
+ 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;
+ }
+ }
+}
diff --git a/B3DealerClient/Control/NumberPad.xaml b/B3DealerClient/Control/NumberPad.xaml
new file mode 100644
index 0000000..7ef3a9c
--- /dev/null
+++ b/B3DealerClient/Control/NumberPad.xaml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/B3DealerClient/Control/NumberPad.xaml.cs b/B3DealerClient/Control/NumberPad.xaml.cs
new file mode 100644
index 0000000..fb35fa7
--- /dev/null
+++ b/B3DealerClient/Control/NumberPad.xaml.cs
@@ -0,0 +1,85 @@
+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 B3DealerClient.Control
+{
+ ///
+ /// NumberPad.xaml 的交互逻辑
+ ///
+ public partial class NumberPad : Window, INotifyPropertyChanged
+ {
+ #region Public Properties
+
+ private string _result = string.Empty;
+ public string Result
+ {
+ get { return _result; }
+ private set
+ {
+ if (_result != value)
+ {
+ _result = value;
+ this.OnPropertyChanged("Result");
+ }
+ }
+ }
+
+ #endregion
+
+ public NumberPad(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
+ }
+}
diff --git a/B3DealerClient/Control/WeightConfig.cs b/B3DealerClient/Control/WeightConfig.cs
new file mode 100644
index 0000000..0573114
--- /dev/null
+++ b/B3DealerClient/Control/WeightConfig.cs
@@ -0,0 +1,37 @@
+using B3DealerClient.Utils;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace B3DealerClient.Control
+{
+ 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 static WeightConfig Init(string flag)
+ {
+ var path = Path.Combine("Config", flag + "WeightConfig.xml");
+ return XmlUtil.DeserializeFromFile(path);
+ }
+
+ public void Save(string flag)
+ {
+ var path = Path.Combine("Config", flag + "WeightConfig.xml");
+ XmlUtil.SerializerObjToFile(this, path);
+ }
+ }
+}
diff --git a/B3DealerClient/Control/WeightControl.xaml b/B3DealerClient/Control/WeightControl.xaml
new file mode 100644
index 0000000..ea395ba
--- /dev/null
+++ b/B3DealerClient/Control/WeightControl.xaml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/B3DealerClient/Control/WeightControl.xaml.cs b/B3DealerClient/Control/WeightControl.xaml.cs
new file mode 100644
index 0000000..e7c5e83
--- /dev/null
+++ b/B3DealerClient/Control/WeightControl.xaml.cs
@@ -0,0 +1,256 @@
+using B3DealerClient.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 B3DealerClient.Control
+{
+ ///
+ /// WeightControl.xaml 的交互逻辑
+ ///
+ public partial class WeightControl : UserControl, IDisposable
+ {
+ 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 ReceivedValue;
+
+ public event Action BeforeStart;
+
+ [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 = WindowUtil.GetParentWindow(this);
+ if (parentWindow != null)
+ {
+ parentWindow.Closing += delegate
+ {
+ if (_inQueryThread != null && _inQueryThread.IsAlive)
+ {
+ DisableWeight();
+ }
+ };
+ }
+ }
+
+ private void weightSetBtn_Click(object sender, RoutedEventArgs e)
+ {
+ if (new WeightSettingWindow(WeightFalg).ShowDialog() == true)
+ config = WeightConfig.Init(WeightFalg);
+ }
+
+ private void weightSwitch_Click(object sender, RoutedEventArgs e)
+ {
+ try
+ {
+ if (config == null)
+ {
+ config = WeightConfig.Init(WeightFalg);
+ }
+ weightSetBtn.IsEnabled = switchOn;
+ switchOn = !switchOn;
+ ChangeWeightBtnState();
+ if (switchOn)
+ {
+ if (BeforeStart != null)
+ BeforeStart();
+ OpenSerialPort();
+ _mainProcessIsRun = true;
+ ReadData();
+ }
+ else
+ {
+ DisableWeight();
+ }
+ }
+ catch
+ {
+ switchOn = !switchOn;
+ weightSetBtn.IsEnabled = !switchOn;
+ ChangeWeightBtnState();
+ throw;
+ }
+ }
+
+ 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;
+ if (_dataFormat.ParseAscii(_dataStrBuilder.ToString(), out str, out isStatic))
+ {
+ if (string.IsNullOrEmpty(str))
+ str = "0";
+ decimal v = 0;
+ decimal.TryParse(str, out v);
+ this.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ lblChengZhong.Content = string.Format(format, v);
+ }));
+ if (str != "0")
+ {
+ if (ReceivedValue != null)
+ ReceivedValue(v - (config.Discont ?? 0));
+ }
+ }
+ _dataStrBuilder.Clear();
+ }
+ else
+ {
+ _dataStrBuilder.Append(c);
+ }
+ }
+ }
+ }
+
+ 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();
+ }
+
+ public void Dispose()
+ {
+ ((IDisposable)weightPort).Dispose();
+ }
+ }
+}
diff --git a/B3DealerClient/Control/WeightSettingWindow.xaml b/B3DealerClient/Control/WeightSettingWindow.xaml
new file mode 100644
index 0000000..dd7e3de
--- /dev/null
+++ b/B3DealerClient/Control/WeightSettingWindow.xaml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/B3DealerClient/Control/WeightSettingWindow.xaml.cs b/B3DealerClient/Control/WeightSettingWindow.xaml.cs
new file mode 100644
index 0000000..c450cb7
--- /dev/null
+++ b/B3DealerClient/Control/WeightSettingWindow.xaml.cs
@@ -0,0 +1,94 @@
+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 B3DealerClient.Control
+{
+ ///
+ /// WeightSettingWindow.xaml 的交互逻辑
+ ///
+ public partial class WeightSettingWindow : Window
+ {
+ List weight = new List { "IND560", "Xk3124", "Xk3190A9" };
+ List com = new List { "COM1", "COM2", "COM3", "COM4", "COM5" };
+ List rate = new List { "1200", "2400", "4800", "7200", "9600" };
+ List bit = new List { "5", "6", "7", "8" };
+ string _flag;
+ WeightConfig config;
+
+ public WeightSettingWindow(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();
+ }
+ }
+}
diff --git a/B3DealerClient/FunctionSelectDialog.xaml b/B3DealerClient/FunctionSelectDialog.xaml
new file mode 100644
index 0000000..e89ef91
--- /dev/null
+++ b/B3DealerClient/FunctionSelectDialog.xaml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/B3DealerClient/FunctionSelectDialog.xaml.cs b/B3DealerClient/FunctionSelectDialog.xaml.cs
new file mode 100644
index 0000000..907cb1e
--- /dev/null
+++ b/B3DealerClient/FunctionSelectDialog.xaml.cs
@@ -0,0 +1,61 @@
+using B3DealerClient.Windows.CarcassInStoreWindow_;
+using B3DealerClient.Windows.CarcassSaleOutWindow_;
+using B3DealerClient.Windows.FreshInStoreWindow_;
+using B3DealerClient.Windows.FreshSaleOutWindow_;
+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 B3DealerClient
+{
+ ///
+ /// FunctionSelectDialog.xaml 的交互逻辑
+ ///
+ public partial class FunctionSelectDialog : Window
+ {
+ public FunctionSelectDialog()
+ {
+ InitializeComponent();
+ }
+
+ private void FuncionSelect(object sender, RoutedEventArgs e)
+ {
+ var fuc = (sender as Button).Tag.ToString();
+ Window window = null;
+ switch (fuc)
+ {
+ case "0":
+ window = new CarcassInStoreWindow();
+ break;
+ case "1":
+ window = new CarcassSaleOutWindow();
+ break;
+ case "2":
+ window = new FreshInStoreWindow();
+ break;
+ case "3":
+ window = new FreshSaleOutWindow();
+ break;
+ }
+ if (window != null)
+ {
+ window.Closing += delegate
+ {
+ this.Show();
+ };
+ window.Show();
+ this.Hide();
+ }
+ }
+ }
+}
diff --git a/B3DealerClient/Images/login.png b/B3DealerClient/Images/login.png
new file mode 100644
index 0000000..aefc251
Binary files /dev/null and b/B3DealerClient/Images/login.png differ
diff --git a/B3DealerClient/Images/setting.png b/B3DealerClient/Images/setting.png
new file mode 100644
index 0000000..3789db2
Binary files /dev/null and b/B3DealerClient/Images/setting.png differ
diff --git a/B3DealerClient/LoginWindow.xaml b/B3DealerClient/LoginWindow.xaml
new file mode 100644
index 0000000..96ffd24
--- /dev/null
+++ b/B3DealerClient/LoginWindow.xaml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
diff --git a/B3DealerClient/LoginWindow.xaml.cs b/B3DealerClient/LoginWindow.xaml.cs
new file mode 100644
index 0000000..910b43b
--- /dev/null
+++ b/B3DealerClient/LoginWindow.xaml.cs
@@ -0,0 +1,89 @@
+using B3DealerClient.BL;
+using B3DealerClient.Control;
+using B3DealerClient.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 B3DealerClient
+{
+ ///
+ /// LoginWindow.xaml 的交互逻辑
+ ///
+ public partial class LoginWindow : Window
+ {
+ public LoginWindow()
+ {
+ InitializeComponent();
+ }
+
+ private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
+ {
+ this.DragMove();
+ }
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ userNameInput.Text = AppContext.Instance.UserName;
+ }
+
+ private void Image_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ new SettingDialog().ShowDialog();
+ }
+
+ private void loginBtn_Click(object sender, RoutedEventArgs e)
+ {
+ if (string.IsNullOrEmpty(userNameInput.Text))
+ throw new Exception("请输入用户名");
+ AppContext.InitRpc();
+ LoginBL.Login(userNameInput.Text, pwdInput.Password);
+ AppContext.Instance.UserName = userNameInput.Text;
+ AppContext.Save();
+ AfterLogin();
+ }
+
+ void AfterLogin()
+ {
+ var dialog = new FunctionSelectDialog();
+ dialog.Closing += delegate { this.Show(); };
+ dialog.Show();
+ this.Hide();
+ }
+
+ private void ExitBtn_Click(object sender, RoutedEventArgs e)
+ {
+ App.Current.Shutdown();
+ }
+
+ private void userNameInput_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ var dialog = new NumberPad(this);
+ if (dialog.ShowDialog() == true)
+ {
+ if (!string.IsNullOrEmpty(dialog.Result))
+ {
+ AppContext.InitRpc();
+ userNameInput.Text = LoginBL.GetUserNameByCode(dialog.Result);
+ }
+ }
+ }
+
+ private void pwdInput_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ {
+ var dialog = new NumberPad(this);
+ if (dialog.ShowDialog() == true)
+ pwdInput.Password = dialog.Result;
+ }
+ }
+}
diff --git a/B3DealerClient/Properties/AssemblyInfo.cs b/B3DealerClient/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..4c14bcf
--- /dev/null
+++ b/B3DealerClient/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// 有关程序集的常规信息通过以下
+// 特性集控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("B3DealerClient")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("B3DealerClient")]
+[assembly: AssemblyCopyright("Copyright © 2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 使此程序集中的类型
+// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
+// 则将该类型上的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+//若要开始生成可本地化的应用程序,请在
+// 中的 .csproj 文件中
+//设置 CultureYouAreCodingWith。 例如,如果您在源文件中
+//使用的是美国英语,请将 设置为 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")]
diff --git a/B3DealerClient/Properties/Resources.Designer.cs b/B3DealerClient/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..b6d6e3b
--- /dev/null
+++ b/B3DealerClient/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本: 4.0.30319.42000
+//
+// 对此文件的更改可能会导致不正确的行为,并且如果
+// 重新生成代码,这些更改将丢失。
+//
+//------------------------------------------------------------------------------
+
+namespace B3DealerClient.Properties
+{
+
+
+ ///
+ /// 一个强类型的资源类,用于查找本地化的字符串等。
+ ///
+ // 此类是由 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()
+ {
+ }
+
+ ///
+ /// 返回此类使用的、缓存的 ResourceManager 实例。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("B3DealerClient.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 为所有资源查找重写当前线程的 CurrentUICulture 属性,
+ /// 方法是使用此强类型资源类。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/B3DealerClient/Properties/Resources.resx b/B3DealerClient/Properties/Resources.resx
new file mode 100644
index 0000000..ffecec8
--- /dev/null
+++ b/B3DealerClient/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/B3DealerClient/Properties/Settings.Designer.cs b/B3DealerClient/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..a5487d4
--- /dev/null
+++ b/B3DealerClient/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace B3DealerClient.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.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;
+ }
+ }
+ }
+}
diff --git a/B3DealerClient/Properties/Settings.settings b/B3DealerClient/Properties/Settings.settings
new file mode 100644
index 0000000..8f2fd95
--- /dev/null
+++ b/B3DealerClient/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/B3DealerClient/SettingDialog.xaml b/B3DealerClient/SettingDialog.xaml
new file mode 100644
index 0000000..71e0306
--- /dev/null
+++ b/B3DealerClient/SettingDialog.xaml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/B3DealerClient/SettingDialog.xaml.cs b/B3DealerClient/SettingDialog.xaml.cs
new file mode 100644
index 0000000..632f683
--- /dev/null
+++ b/B3DealerClient/SettingDialog.xaml.cs
@@ -0,0 +1,92 @@
+using B3DealerClient.Control;
+using B3DealerClient.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 B3DealerClient
+{
+ ///
+ /// SettingDialog.xaml 的交互逻辑
+ ///
+ public partial class SettingDialog : Window
+ {
+ public SettingDialog()
+ {
+ InitializeComponent();
+ }
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ ServerUrlInput.Text = AppContext.Instance.ServerUrl;
+ DbConnectInput.Text = AppContext.Instance.SqlConnection;
+ }
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ var btn = (sender as Button).Content.ToString();
+ switch (btn)
+ {
+ case "保存":
+ Save();
+ break;
+ case "升级":
+ Update();
+ break;
+ default:
+ Close();
+ break;
+ }
+ }
+
+ void Save()
+ {
+ string uri = ServerUrlInput.Text.Trim();
+ if (string.IsNullOrEmpty(uri))
+ throw new Exception("服务器地址不能为空");
+ string dbConnect = DbConnectInput.Text.Trim();
+ if (string.IsNullOrEmpty(dbConnect))
+ throw new Exception("数据库设置不能为空");
+ AppContext.Instance.ServerUrl = uri;
+ AppContext.Instance.SqlConnection = dbConnect;
+ AppContext.Save();
+ AppContext.ReInitRpc();
+ MessageBox.Show("保存成功!");
+ }
+
+ void Update()
+ {
+ if (string.IsNullOrEmpty(AppContext.Instance.SqlConnection))
+ throw new Exception("请设置数据库连接");
+ try
+ {
+ DbUtil.UpdateDatabase(AppContext.Instance.SqlConnection);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(string.Format("错误:{0}。详情:{1}", ex.Message, ex.StackTrace));
+ return;
+ }
+ MessageBox.Show("数据库升级成功");
+ }
+
+ //private void ServerUrlInput_PreviewMouseDown(object sender, MouseButtonEventArgs e)
+ //{
+ // var pad = new NumberPad(this);
+ // if (pad.ShowDialog() == true)
+ // {
+ // ServerUrlInput.Text = pad.Result;
+ // }
+ //}
+ }
+}
diff --git a/B3DealerClient/Style/Border.xaml b/B3DealerClient/Style/Border.xaml
new file mode 100644
index 0000000..f875cb3
--- /dev/null
+++ b/B3DealerClient/Style/Border.xaml
@@ -0,0 +1,8 @@
+
+
+
\ No newline at end of file
diff --git a/B3DealerClient/Style/Button.xaml b/B3DealerClient/Style/Button.xaml
new file mode 100644
index 0000000..e757331
--- /dev/null
+++ b/B3DealerClient/Style/Button.xaml
@@ -0,0 +1,31 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/B3DealerClient/Style/Calendar.xaml b/B3DealerClient/Style/Calendar.xaml
new file mode 100644
index 0000000..0441452
--- /dev/null
+++ b/B3DealerClient/Style/Calendar.xaml
@@ -0,0 +1,414 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/B3DealerClient/Style/CheckBox.xaml b/B3DealerClient/Style/CheckBox.xaml
new file mode 100644
index 0000000..ba4893d
--- /dev/null
+++ b/B3DealerClient/Style/CheckBox.xaml
@@ -0,0 +1,43 @@
+
+
+
\ No newline at end of file
diff --git a/B3DealerClient/Style/Colors.xaml b/B3DealerClient/Style/Colors.xaml
new file mode 100644
index 0000000..31f1467
--- /dev/null
+++ b/B3DealerClient/Style/Colors.xaml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Microsoft YaHei
+ 13
+
+ 0.5
+
+ 0.88
+ 0.4
+ yyyy年MM月dd日
+ yyyy-MM-dd HH:mm:ss
+
+
\ No newline at end of file
diff --git a/B3DealerClient/Style/ComboBox.xaml b/B3DealerClient/Style/ComboBox.xaml
new file mode 100644
index 0000000..2b0b454
--- /dev/null
+++ b/B3DealerClient/Style/ComboBox.xaml
@@ -0,0 +1,35 @@
+
+
+
+
\ No newline at end of file
diff --git a/B3DealerClient/Style/DataGrid.xaml b/B3DealerClient/Style/DataGrid.xaml
new file mode 100644
index 0000000..1fb21cc
--- /dev/null
+++ b/B3DealerClient/Style/DataGrid.xaml
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/B3DealerClient/Style/DatePicker.xaml b/B3DealerClient/Style/DatePicker.xaml
new file mode 100644
index 0000000..a1e9751
--- /dev/null
+++ b/B3DealerClient/Style/DatePicker.xaml
@@ -0,0 +1,164 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/B3DealerClient/Style/TSIcon.xaml b/B3DealerClient/Style/TSIcon.xaml
new file mode 100644
index 0000000..86e5fc1
--- /dev/null
+++ b/B3DealerClient/Style/TSIcon.xaml
@@ -0,0 +1,12 @@
+
+
+
+
\ No newline at end of file
diff --git a/B3DealerClient/Utils/AppContext.cs b/B3DealerClient/Utils/AppContext.cs
new file mode 100644
index 0000000..eb46818
--- /dev/null
+++ b/B3DealerClient/Utils/AppContext.cs
@@ -0,0 +1,67 @@
+using B3DealerClient.Utils;
+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 B3DealerClient
+{
+ public class AppContext
+ {
+ private static AppContext inst = null;
+ public static AppContext Instance
+ {
+ get
+ {
+ if (inst == null)
+ inst = XmlUtil.DeserializeFromFile();
+ return inst;
+ }
+ }
+
+ public string ServerUrl { get; set; }
+
+ public string UserName { get; set; }
+
+ public string SqlConnection { get; set; }
+
+ public static void Save()
+ {
+ XmlUtil.SerializerObjToFile(Instance);
+ }
+
+ [XmlIgnore]
+ public bool RpcInited { get; set; }
+
+ public static void ReInitRpc()
+ {
+ CheckUrl();
+ if (AppContext.Instance.RpcInited)
+ RpcFacade.ReInit(AppContext.Instance.ServerUrl);
+ else
+ {
+ RpcFacade.Init(AppContext.Instance.ServerUrl, "B3DealerClient");
+ AppContext.Instance.RpcInited = true;
+ }
+ }
+
+ public static void InitRpc()
+ {
+ CheckUrl();
+ if (!AppContext.Instance.RpcInited)
+ {
+ RpcFacade.Init(AppContext.Instance.ServerUrl, "B3DealerClient");
+ AppContext.Instance.RpcInited = true;
+ }
+ }
+
+ static void CheckUrl()
+ {
+ if (string.IsNullOrEmpty(AppContext.Instance.ServerUrl))
+ throw new Exception("请先配置服务器地址");
+ }
+ }
+}
diff --git a/B3DealerClient/Utils/ControlAttachProperty.cs b/B3DealerClient/Utils/ControlAttachProperty.cs
new file mode 100644
index 0000000..c191f32
--- /dev/null
+++ b/B3DealerClient/Utils/ControlAttachProperty.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace B3DealerClient.Utils
+{
+ public static class ControlAttachProperty
+ {
+ #region IconSizeProperty 字体图标大小
+ ///
+ /// 字体图标
+ ///
+ public static readonly DependencyProperty IconSizeProperty = DependencyProperty.RegisterAttached(
+ "IconSize", typeof(double), typeof(ControlAttachProperty), new FrameworkPropertyMetadata(12D));
+
+ public static double GetIconSize(DependencyObject d)
+ {
+ return (double)d.GetValue(IconSizeProperty);
+ }
+
+ public static void SetIconSize(DependencyObject obj, double value)
+ {
+ obj.SetValue(IconSizeProperty, value);
+ }
+ #endregion
+
+ #region IconMarginProperty 字体图标边距
+ ///
+ /// 字体图标
+ ///
+ public static readonly DependencyProperty IconMarginProperty = DependencyProperty.RegisterAttached(
+ "IconMargin", typeof(Thickness), typeof(ControlAttachProperty), new FrameworkPropertyMetadata(null));
+
+ public static Thickness GetIconMargin(DependencyObject d)
+ {
+ return (Thickness)d.GetValue(IconMarginProperty);
+ }
+
+ public static void SetIconMargin(DependencyObject obj, Thickness value)
+ {
+ obj.SetValue(IconMarginProperty, value);
+ }
+ #endregion
+
+ #region IsNumberPad 字体图标边距
+ ///
+ /// 字体图标
+ ///
+ public static readonly DependencyProperty IsNumberPadProperty = DependencyProperty.RegisterAttached(
+ "IsNumberPad", typeof(bool), typeof(ControlAttachProperty), new FrameworkPropertyMetadata(true));
+
+ public static bool GetIsNumberPad(DependencyObject d)
+ {
+ return (bool)d.GetValue(IsNumberPadProperty);
+ }
+
+ public static void SetIsNumberPad(DependencyObject obj, bool value)
+ {
+ obj.SetValue(IsNumberPadProperty, value);
+ }
+ #endregion
+ }
+}
diff --git a/B3DealerClient/Utils/DbUtil.cs b/B3DealerClient/Utils/DbUtil.cs
new file mode 100644
index 0000000..f011477
--- /dev/null
+++ b/B3DealerClient/Utils/DbUtil.cs
@@ -0,0 +1,50 @@
+using Forks.EnterpriseServices.DomainObjects2;
+using Forks.Utils;
+using Forks.Utils.Data;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace B3DealerClient.Utils
+{
+ public static class DbUtil
+ {
+ public static void UpdateDatabase(string sqlConnection)
+ {
+ using (ISqlUtil sqlUtil = new SqlUtil(sqlConnection))
+ {
+ var boTypes = GetTypes();
+ Dmo.UpdateTables(sqlUtil, boTypes);
+ }
+ }
+
+ static IEnumerable GetTypes()
+ {
+ var asm = Assembly.GetExecutingAssembly();
+ foreach (var t in asm.GetExportedTypes())
+ {
+ if (t.IsAbstract)
+ {
+ continue;
+ }
+ if (t.IsClass && IsMapTable(t))
+ {
+ yield return t;
+ }
+ }
+ }
+
+ static bool IsMapTable(Type t)
+ {
+ var attr = ReflectionUtil.GetAttribute(t);
+ if (attr == null)
+ {
+ return false;
+ }
+ return true;
+ }
+ }
+}
diff --git a/B3DealerClient/Utils/WindowUtil.cs b/B3DealerClient/Utils/WindowUtil.cs
new file mode 100644
index 0000000..9cc1372
--- /dev/null
+++ b/B3DealerClient/Utils/WindowUtil.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Media;
+
+namespace B3DealerClient.Utils
+{
+ public static class WindowUtil
+ {
+ public static Window GetParentWindow(DependencyObject obj)
+ {
+ var parent = VisualTreeHelper.GetParent(obj);
+ while (parent != null)
+ {
+ if (parent is Window)
+ {
+ return (Window)parent;
+ }
+ parent = VisualTreeHelper.GetParent(parent);
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/B3DealerClient/Utils/XmlUtil.cs b/B3DealerClient/Utils/XmlUtil.cs
new file mode 100644
index 0000000..c83cc7c
--- /dev/null
+++ b/B3DealerClient/Utils/XmlUtil.cs
@@ -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 B3DealerClient.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(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;
+ }
+ }
+ }
+}
diff --git a/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml
new file mode 100644
index 0000000..346f41a
--- /dev/null
+++ b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml
@@ -0,0 +1,250 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml.cs b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml.cs
new file mode 100644
index 0000000..5d3d082
--- /dev/null
+++ b/B3DealerClient/Windows/CarcassInStoreWindow_/CarcassInStoreWindow.xaml.cs
@@ -0,0 +1,27 @@
+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 B3DealerClient.Windows.CarcassInStoreWindow_
+{
+ ///
+ /// CarcassInStoreWindow.xaml 的交互逻辑
+ ///
+ public partial class CarcassInStoreWindow : Window
+ {
+ public CarcassInStoreWindow()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml b/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml
new file mode 100644
index 0000000..37c3341
--- /dev/null
+++ b/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml
@@ -0,0 +1,250 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml.cs b/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml.cs
new file mode 100644
index 0000000..d66bf12
--- /dev/null
+++ b/B3DealerClient/Windows/CarcassSaleOutWindow_/CarcassSaleOutWindow.xaml.cs
@@ -0,0 +1,27 @@
+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 B3DealerClient.Windows.CarcassSaleOutWindow_
+{
+ ///
+ /// CarcassSaleOutWindow.xaml 的交互逻辑
+ ///
+ public partial class CarcassSaleOutWindow : Window
+ {
+ public CarcassSaleOutWindow()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml b/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml
new file mode 100644
index 0000000..256bde7
--- /dev/null
+++ b/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml
@@ -0,0 +1,173 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml.cs b/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml.cs
new file mode 100644
index 0000000..510c3b9
--- /dev/null
+++ b/B3DealerClient/Windows/FreshInStoreWindow_/FreshInStoreWindow.xaml.cs
@@ -0,0 +1,27 @@
+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 B3DealerClient.Windows.FreshInStoreWindow_
+{
+ ///
+ /// FreshInStoreWindow.xaml 的交互逻辑
+ ///
+ public partial class FreshInStoreWindow : Window
+ {
+ public FreshInStoreWindow()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml b/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml
new file mode 100644
index 0000000..6d10e61
--- /dev/null
+++ b/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml
@@ -0,0 +1,8 @@
+
+
+
+
+
diff --git a/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml.cs b/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml.cs
new file mode 100644
index 0000000..517281b
--- /dev/null
+++ b/B3DealerClient/Windows/FreshSaleOutWindow_/FreshSaleOutWindow.xaml.cs
@@ -0,0 +1,27 @@
+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 B3DealerClient.Windows.FreshSaleOutWindow_
+{
+ ///
+ /// FreshSaleOutWindow.xaml 的交互逻辑
+ ///
+ public partial class FreshSaleOutWindow : Window
+ {
+ public FreshSaleOutWindow()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/B3DealerClient/app.ico b/B3DealerClient/app.ico
new file mode 100644
index 0000000..9a25455
Binary files /dev/null and b/B3DealerClient/app.ico differ