Browse Source

init

master
robin 8 years ago
commit
f66b4436b9
53 changed files with 6750 additions and 0 deletions
  1. +52
    -0
      B3ButcherWeightClient.sln
  2. +109
    -0
      B3ButcherWeightClient/AutoSizeFormClass.cs
  3. +168
    -0
      B3ButcherWeightClient/B3ButcherWeightClient.csproj
  4. +62
    -0
      B3ButcherWeightClient/ChangeLevelForm.Designer.cs
  5. +75
    -0
      B3ButcherWeightClient/ChangeLevelForm.cs
  6. +120
    -0
      B3ButcherWeightClient/ChangeLevelForm.resx
  7. +0
    -0
      B3ButcherWeightClient/Config.txt
  8. +151
    -0
      B3ButcherWeightClient/ConfigUtil.cs
  9. +56
    -0
      B3ButcherWeightClient/Data/DataFormatBase.cs
  10. +42
    -0
      B3ButcherWeightClient/Data/IND560DataFormat.cs
  11. +103
    -0
      B3ButcherWeightClient/Data/Xk3124DataFormat.cs
  12. +110
    -0
      B3ButcherWeightClient/Data/Xk3190A9DataFormat.cs
  13. +106
    -0
      B3ButcherWeightClient/Data/Xk3190D10DataFormat.cs
  14. +48
    -0
      B3ButcherWeightClient/EncodeString.cs
  15. +163
    -0
      B3ButcherWeightClient/Livestock.Designer.cs
  16. +70
    -0
      B3ButcherWeightClient/Livestock.cs
  17. +129
    -0
      B3ButcherWeightClient/Livestock.resx
  18. +0
    -0
      B3ButcherWeightClient/Livestock.txt
  19. +29
    -0
      B3ButcherWeightClient/LogUtil.cs
  20. +119
    -0
      B3ButcherWeightClient/Login.Designer.cs
  21. +113
    -0
      B3ButcherWeightClient/Login.cs
  22. +123
    -0
      B3ButcherWeightClient/Login.resx
  23. +442
    -0
      B3ButcherWeightClient/Main.Designer.cs
  24. +632
    -0
      B3ButcherWeightClient/Main.cs
  25. +201
    -0
      B3ButcherWeightClient/Main.resx
  26. BIN
      B3ButcherWeightClient/Microsoft.Office.Interop.Excel.dll
  27. +18
    -0
      B3ButcherWeightClient/Program.cs
  28. +36
    -0
      B3ButcherWeightClient/Properties/AssemblyInfo.cs
  29. +63
    -0
      B3ButcherWeightClient/Properties/Resources.Designer.cs
  30. +117
    -0
      B3ButcherWeightClient/Properties/Resources.resx
  31. +26
    -0
      B3ButcherWeightClient/Properties/Settings.Designer.cs
  32. +7
    -0
      B3ButcherWeightClient/Properties/Settings.settings
  33. +335
    -0
      B3ButcherWeightClient/QueryForm.Designer.cs
  34. +217
    -0
      B3ButcherWeightClient/QueryForm.cs
  35. +174
    -0
      B3ButcherWeightClient/QueryForm.resx
  36. BIN
      B3ButcherWeightClient/Resources/loading.gif
  37. BIN
      B3ButcherWeightClient/Resources/warning1.gif
  38. +586
    -0
      B3ButcherWeightClient/Setting.Designer.cs
  39. +150
    -0
      B3ButcherWeightClient/Setting.cs
  40. +120
    -0
      B3ButcherWeightClient/Setting.resx
  41. +153
    -0
      B3ButcherWeightClient/SyncUtil.cs
  42. +34
    -0
      B3ButcherWeightClient/WinApiSendMessage.cs
  43. +3
    -0
      B3ButcherWeightClient/app.config
  44. BIN
      B3ButcherWeightClient/logo.ico
  45. +65
    -0
      BO/BO.csproj
  46. +30
    -0
      BO/BOClassAttribute.cs
  47. +30
    -0
      BO/LoginUser.cs
  48. +36
    -0
      BO/Properties/AssemblyInfo.cs
  49. +99
    -0
      BO/UpdateDb.cs
  50. +60
    -0
      BO/WeightTable.cs
  51. +1168
    -0
      Setup/Setup.vdproj
  52. BIN
      新版本注意事项.png
  53. BIN
      白条称重客户端.docx

+ 52
- 0
B3ButcherWeightClient.sln View File

@ -0,0 +1,52 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "B3ButcherWeightClient", "B3ButcherWeightClient\B3ButcherWeightClient.csproj", "{758A679D-2138-41EE-9675-7CC83B85AD15}"
ProjectSection(ProjectDependencies) = postProject
{2EAEFC6A-1B91-4D58-A793-B25462CA9225} = {2EAEFC6A-1B91-4D58-A793-B25462CA9225}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BO", "BO\BO.csproj", "{2EAEFC6A-1B91-4D58-A793-B25462CA9225}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{758A679D-2138-41EE-9675-7CC83B85AD15}.Debug|Any CPU.ActiveCfg = Debug|x86
{758A679D-2138-41EE-9675-7CC83B85AD15}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{758A679D-2138-41EE-9675-7CC83B85AD15}.Debug|Mixed Platforms.Build.0 = Debug|x86
{758A679D-2138-41EE-9675-7CC83B85AD15}.Debug|x86.ActiveCfg = Debug|x86
{758A679D-2138-41EE-9675-7CC83B85AD15}.Debug|x86.Build.0 = Debug|x86
{758A679D-2138-41EE-9675-7CC83B85AD15}.Release|Any CPU.ActiveCfg = Release|x86
{758A679D-2138-41EE-9675-7CC83B85AD15}.Release|Mixed Platforms.ActiveCfg = Release|x86
{758A679D-2138-41EE-9675-7CC83B85AD15}.Release|Mixed Platforms.Build.0 = Release|x86
{758A679D-2138-41EE-9675-7CC83B85AD15}.Release|x86.ActiveCfg = Release|x86
{758A679D-2138-41EE-9675-7CC83B85AD15}.Release|x86.Build.0 = Release|x86
{2EAEFC6A-1B91-4D58-A793-B25462CA9225}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2EAEFC6A-1B91-4D58-A793-B25462CA9225}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2EAEFC6A-1B91-4D58-A793-B25462CA9225}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{2EAEFC6A-1B91-4D58-A793-B25462CA9225}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{2EAEFC6A-1B91-4D58-A793-B25462CA9225}.Debug|x86.ActiveCfg = Debug|Any CPU
{2EAEFC6A-1B91-4D58-A793-B25462CA9225}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2EAEFC6A-1B91-4D58-A793-B25462CA9225}.Release|Any CPU.Build.0 = Release|Any CPU
{2EAEFC6A-1B91-4D58-A793-B25462CA9225}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2EAEFC6A-1B91-4D58-A793-B25462CA9225}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2EAEFC6A-1B91-4D58-A793-B25462CA9225}.Release|x86.ActiveCfg = Release|Any CPU
{1367E4CD-C7CA-4C4D-BF37-EC0D9BF949F3}.Debug|Any CPU.ActiveCfg = Debug
{1367E4CD-C7CA-4C4D-BF37-EC0D9BF949F3}.Debug|Mixed Platforms.ActiveCfg = Debug
{1367E4CD-C7CA-4C4D-BF37-EC0D9BF949F3}.Debug|x86.ActiveCfg = Debug
{1367E4CD-C7CA-4C4D-BF37-EC0D9BF949F3}.Release|Any CPU.ActiveCfg = Release
{1367E4CD-C7CA-4C4D-BF37-EC0D9BF949F3}.Release|Mixed Platforms.ActiveCfg = Release
{1367E4CD-C7CA-4C4D-BF37-EC0D9BF949F3}.Release|x86.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

+ 109
- 0
B3ButcherWeightClient/AutoSizeFormClass.cs View File

@ -0,0 +1,109 @@
using System.Collections.Generic;
using System.Windows.Forms;
namespace B3ButcherWeightClient {
class AutoSizeFormClass {
//(1).声明结构,只记录窗体和其控件的初始位置和大小。
public struct controlRect {
public int Left;
public int Top;
public int Width;
public int Height;
}
//(2).声明 1个对象
//注意这里不能使用控件列表记录 List nCtrl;,因为控件的关联性,记录的始终是当前的大小。
// public List oldCtrl= new List();//这里将西文的大于小于号都过滤掉了,只能改为中文的,使用中要改回西文
public List<controlRect> oldCtrl = new List<controlRect>();
int ctrlNo = 0;//1;
//(3). 创建两个函数
//(3.1)记录窗体和其控件的初始位置和大小,
public void ControllInitializeSize(Control mForm) {
controlRect cR;
cR.Left = mForm.Left;
cR.Top = mForm.Top;
cR.Width = mForm.Width;
cR.Height = mForm.Height;
oldCtrl.Add(cR);//第一个为"窗体本身",只加入一次即可
AddControl(mForm);//窗体内其余控件还可能嵌套控件(比如panel),要单独抽出,因为要递归调用
//this.WindowState = (System.Windows.Forms.FormWindowState)(2);//记录完控件的初始位置和大小后,再最大化
//0 - Normalize , 1 - Minimize,2- Maximize
}
private void AddControl(Control ctl) {
foreach (Control c in ctl.Controls) { //**放在这里,是先记录控件的子控件,后记录控件本身
//if (c.Controls.Count > 0)
// AddControl(c);//窗体内其余控件还可能嵌套控件(比如panel),要单独抽出,因为要递归调用
controlRect objCtrl;
objCtrl.Left = c.Left;
objCtrl.Top = c.Top;
objCtrl.Width = c.Width;
objCtrl.Height = c.Height;
oldCtrl.Add(objCtrl);
//**放在这里,是先记录控件本身,后记录控件的子控件
if (c.Controls.Count > 0)
AddControl(c);//窗体内其余控件还可能嵌套控件(比如panel),要单独抽出,因为要递归调用
}
}
//(3.2)控件自适应大小,
public void controlAutoSize(Control mForm) {
if (ctrlNo == 0) { //*如果在窗体的Form1_Load中,记录控件原始的大小和位置,正常没有问题,但要加入皮肤就会出现问题,因为有些控件如dataGridView的的子控件还没有完成,个数少
//*要在窗体的Form1_SizeChanged中,第一次改变大小时,记录控件原始的大小和位置,这里所有控件的子控件都已经形成
controlRect cR;
// cR.Left = mForm.Left; cR.Top = mForm.Top; cR.Width = mForm.Width; cR.Height = mForm.Height;
cR.Left = 0;
cR.Top = 0;
cR.Width = mForm.PreferredSize.Width;
cR.Height = mForm.PreferredSize.Height;
oldCtrl.Add(cR);//第一个为"窗体本身",只加入一次即可
AddControl(mForm);//窗体内其余控件可能嵌套其它控件(比如panel),故单独抽出以便递归调用
}
float wScale = (float)mForm.Width / (float)oldCtrl[0].Width;//新旧窗体之间的比例,与最早的旧窗体
float hScale = (float)mForm.Height / (float)oldCtrl[0].Height;//.Height;
ctrlNo = 1;//进入=1,第0个为窗体本身,窗体内的控件,从序号1开始
AutoScaleControl(mForm, wScale, hScale);//窗体内其余控件还可能嵌套控件(比如panel),要单独抽出,因为要递归调用
}
private void AutoScaleControl(Control ctl, float wScale, float hScale) {
int ctrLeft0, ctrTop0, ctrWidth0, ctrHeight0;
//int ctrlNo = 1;//第1个是窗体自身的 Left,Top,Width,Height,所以窗体控件从ctrlNo=1开始
foreach (Control c in ctl.Controls) { //**放在这里,是先缩放控件的子控件,后缩放控件本身
//if (c.Controls.Count > 0)
// AutoScaleControl(c, wScale, hScale);//窗体内其余控件还可能嵌套控件(比如panel),要单独抽出,因为要递归调用
ctrLeft0 = oldCtrl[ctrlNo].Left;
ctrTop0 = oldCtrl[ctrlNo].Top;
ctrWidth0 = oldCtrl[ctrlNo].Width;
ctrHeight0 = oldCtrl[ctrlNo].Height;
//c.Left = (int)((ctrLeft0 - wLeft0) * wScale) + wLeft1;//新旧控件之间的线性比例
//c.Top = (int)((ctrTop0 - wTop0) * h) + wTop1;
c.Left = (int)((ctrLeft0) * wScale);//新旧控件之间的线性比例。控件位置只相对于窗体,所以不能加 + wLeft1
c.Top = (int)((ctrTop0) * hScale);//
c.Width = (int)(ctrWidth0 * wScale);//只与最初的大小相关,所以不能与现在的宽度相乘 (int)(c.Width * w);
c.Height = (int)(ctrHeight0 * hScale);//
ctrlNo++;//累加序号
//**放在这里,是先缩放控件本身,后缩放控件的子控件
if (c.Controls.Count > 0)
AutoScaleControl(c, wScale, hScale);//窗体内其余控件还可能嵌套控件(比如panel),要单独抽出,因为要递归调用
if (ctl is DataGridView) {
//var dgv = ctl as DataGridView;
//Cursor.Current = Cursors.WaitCursor;
//var widths = 0;
//for (int i = 0; i < dgv.Columns.Count; i++) {
// dgv.AutoResizeColumn(i, DataGridViewAutoSizeColumnMode.AllCells); // 自动调整列宽
// widths += dgv.Columns[i].Width; // 计算调整列后单元列的宽度和
//}
//if (widths >= ctl.Size.Width) // 如果调整列的宽度大于设定列宽
// dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; // 调整列的模式 自动
//else
// dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; // 如果小于 则填充
//Cursor.Current = Cursors.Default;
}
}
}
}
}

+ 168
- 0
B3ButcherWeightClient/B3ButcherWeightClient.csproj View File

@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{758A679D-2138-41EE-9675-7CC83B85AD15}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>B3ButcherWeightClient</RootNamespace>
<AssemblyName>B3ButcherWeightClient</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>logo.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Forks.EnterpriseServices, Version=3.1.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Forks.EnterpriseServices.dll</HintPath>
</Reference>
<Reference Include="Forks.Utils, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AutoSizeFormClass.cs" />
<Compile Include="ChangeLevelForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ChangeLevelForm.Designer.cs">
<DependentUpon>ChangeLevelForm.cs</DependentUpon>
</Compile>
<Compile Include="Data\IND560DataFormat.cs" />
<Compile Include="Data\Xk3124DataFormat.cs" />
<Compile Include="Data\DataFormatBase.cs" />
<Compile Include="Data\Xk3190A9DataFormat.cs" />
<Compile Include="Data\Xk3190D10DataFormat.cs" />
<Compile Include="LogUtil.cs" />
<Compile Include="QueryForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="QueryForm.Designer.cs">
<DependentUpon>QueryForm.cs</DependentUpon>
</Compile>
<Compile Include="SyncUtil.cs" />
<Compile Include="WinApiSendMessage.cs" />
<Compile Include="ConfigUtil.cs" />
<Compile Include="EncodeString.cs" />
<Compile Include="Livestock.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Livestock.Designer.cs">
<DependentUpon>Livestock.cs</DependentUpon>
</Compile>
<Compile Include="Main.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Main.Designer.cs">
<DependentUpon>Main.cs</DependentUpon>
</Compile>
<Compile Include="Login.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Login.Designer.cs">
<DependentUpon>Login.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Setting.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Setting.Designer.cs">
<DependentUpon>Setting.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="ChangeLevelForm.resx">
<DependentUpon>ChangeLevelForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Livestock.resx">
<DependentUpon>Livestock.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Main.resx">
<DependentUpon>Main.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Login.resx">
<DependentUpon>Login.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="QueryForm.resx">
<DependentUpon>QueryForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Setting.resx">
<DependentUpon>Setting.cs</DependentUpon>
</EmbeddedResource>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BO\BO.csproj">
<Project>{2EAEFC6A-1B91-4D58-A793-B25462CA9225}</Project>
<Name>BO</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="logo.ico" />
<Content Include="Resources\loading.gif" />
<Content Include="Resources\warning1.gif" />
</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>

+ 62
- 0
B3ButcherWeightClient/ChangeLevelForm.Designer.cs View File

@ -0,0 +1,62 @@
namespace B3ButcherWeightClient
{
partial class ChangeLevelForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.SuspendLayout();
//
// panel1
//
this.panel1.AutoScroll = true;
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel1.Location = new System.Drawing.Point(1, 2);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(627, 539);
this.panel1.TabIndex = 7;
//
// ChangeLevelForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(630, 541);
this.Controls.Add(this.panel1);
this.MaximizeBox = false;
this.Name = "ChangeLevelForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "修改级别";
this.Load += new System.EventHandler(this.ChangeLevelForm_Load);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel1;
}
}

+ 75
- 0
B3ButcherWeightClient/ChangeLevelForm.cs View File

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace B3ButcherWeightClient
{
public partial class ChangeLevelForm : Form
{
readonly IList<Livestock.Info> _dTable = new List<Livestock.Info>();
readonly IList<Button> _btList = new List<Button>();
public ChangeLevelForm()
{
InitializeComponent();
this.Text = "替换--" + mName;
}
public long mID { get; set; }
public string mName { get; set; }
public void Init( string name)
{
mName = name;
}
private void ChangeLevelForm_Load(object sender, EventArgs e)
{
AddLivestockControl();
}
private void AddLivestockControl()
{
ConfigUtil.SetLivestock(_dTable);
var i = 0;
var j = 0;
foreach (var info in _dTable)
{
var bt = new Button();
bt.Text = info.;
bt.Size = new Size(200, 100);
bt.Left = i * 203;
bt.Top = j * 102;
bt.Tag = info;
bt.Click += Bt_Click; ;
panel1.Controls.Add(bt);
_btList.Add(bt);
i++;
if (i == 3)
{
i = 0;
j++;
}
}
}
private void Bt_Click(object sender, EventArgs e)
{
var bt = sender as Button;
if (bt != null)
{
bt.BackColor = Color.OrangeRed;
var _currentInfo = bt.Tag as Livestock.Info;
mID = _currentInfo.ID;
mName = _currentInfo.;
DialogResult=DialogResult.OK;
}
}
}
}

+ 120
- 0
B3ButcherWeightClient/ChangeLevelForm.resx View File

@ -0,0 +1,120 @@
<?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.Runtime.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:import namespace="http://www.w3.org/XML/1998/namespace" />
<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" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</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" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

+ 0
- 0
B3ButcherWeightClient/Config.txt View File


+ 151
- 0
B3ButcherWeightClient/ConfigUtil.cs View File

@ -0,0 +1,151 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Forks.Utils.IO;
namespace B3ButcherWeightClient {
public class ConfigUtil {
public static string ConfigFilePath = Application.StartupPath + "\\Config.txt";
public static string LivestockFilePath = Application.StartupPath + "\\Livestock.txt";
public static void Init() {
using (TextReader reader = FS.OpenReader(ConfigFilePath, true)) {
var nutFile = NutFile.Parse(reader);
var ser = nutFile.AsString(ConfigItem.Server, "");
if (!string.IsNullOrEmpty(ser)) {
var strBuilder = new StringBuilder();
strBuilder.Append("Server=");
strBuilder.Append(ser);
strBuilder.Append(";");
strBuilder.Append("Database=");
strBuilder.Append(nutFile.AsString(ConfigItem.Database, ""));
strBuilder.Append(";");
strBuilder.Append("User ID=");
strBuilder.Append(nutFile.AsString(ConfigItem.UserName, ""));
strBuilder.Append(";");
strBuilder.Append("Password=");
var password = nutFile.AsString(ConfigItem.Password, "");
strBuilder.Append(EncodeString.Encode(password));
strBuilder.Append(";");
ConnectionStr = strBuilder.ToString();
}
ser = nutFile.AsString(ConfigItem.RemoteServer, "");
if (!string.IsNullOrEmpty(ser)) {
var strBuilder = new StringBuilder();
strBuilder.Append("Server=");
strBuilder.Append(nutFile.AsString(ConfigItem.RemoteServer, ""));
strBuilder.Append(";");
strBuilder.Append("Database=");
strBuilder.Append(nutFile.AsString(ConfigItem.RemoteDatabase, ""));
strBuilder.Append(";");
strBuilder.Append("User ID=");
strBuilder.Append(nutFile.AsString(ConfigItem.RemoteUserName, ""));
strBuilder.Append(";");
strBuilder.Append("Password=");
var password = nutFile.AsString(ConfigItem.RemotePassword, "");
strBuilder.Append(EncodeString.Encode(password));
strBuilder.Append(";");
RemoteConStr = strBuilder.ToString();
}
LogFilePath = Application.StartupPath + "\\log\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
StartTime = nutFile.AsInt32(ConfigItem.StartTime, 12);
if (string.IsNullOrEmpty(nutFile.AsString(ConfigItem.Seconds, "1"))) {
Seconds = 1;
} else {
Seconds = (short)nutFile.AsInt32(ConfigItem.Seconds, 1);
}
BaseCount = (short)nutFile.AsInt32(ConfigItem.BaseCount, 6);
ComName = nutFile.AsString(ConfigItem.ComName, "COM1");
BaundRate = nutFile.AsString(ConfigItem.BaundRate, "9600");
DataBits = nutFile.AsString(ConfigItem.DataBits, "8");
Assignment = nutFile.AsString(ConfigItem.Assignment, "Continuous");
ReadType = nutFile.AsString(ConfigItem.ReadType, "0");
CType = nutFile.AsString(ConfigItem.CType, "");
MinWeight = nutFile.AsDecimal(ConfigItem.MinWeight, 25m);
MaxWeight = nutFile.AsDecimal(ConfigItem.MaxWeight, 300m);
AllowChangeLevel = nutFile.AsBool(ConfigItem.AllowChangeLevel, false);
SubWeight = nutFile.AsDecimal(ConfigItem.SubWeight, 0m);
PerDayStartHour = nutFile.AsInt32(ConfigItem.PerDayStartHour, 0);
}
}
public static void SetLivestock(IList<Livestock.Info> dTable) {
dTable.Clear();
using (var reader = FS.OpenReader(ConfigUtil.LivestockFilePath, true)) {
var nutFile = NutFile.Parse(reader);
var strs = nutFile.AsString("ITEM", "");
var items = strs.Split(',');
foreach (var item in items) {
var s = item.Split('|');
if (s.Length == 2) {
var info = new Livestock.Info();
info.ID = long.Parse(s[0]);
info. = s[1];
dTable.Add(info);
}
}
}
}
public static string ConnectionStr;
public static string RemoteConStr;
public static string LogFilePath;
public static short Seconds;
public static short BaseCount;
public static string ComName;
public static string BaundRate;
public static string DataBits;
public static string ReadType;
public static string Assignment;
public static decimal MinWeight;
public static decimal MaxWeight;
public static int StartTime;
public static string CType;
public static bool AllowChangeLevel;
public static decimal SubWeight;
public static int PerDayStartHour; }
public class ConfigItem {
public const string CType = "CType";
public const string ComName = "ComName";
public const string BaundRate = "BaundRate";
public const string DataBits = "DataBits";
public const string Assignment = "Assignment";
public const string Server = "Server";
public const string Database = "Database";
public const string UserName = "UserName";
public const string Password = "Password";
public const string RemoteServer = "RemoteServer";
public const string RemoteDatabase = "RemoteDatabase";
public const string RemoteUserName = "RemoteUserName";
public const string RemotePassword = "RemotePassword";
public const string RemoteConStr = "RemoteConStr";
public const string RLoginPassword = "RLoginPassword";
public const string MinWeight = "MinWeight";
public const string MaxWeight = "MaxWeight";
public const string StartTime = "StartTime";
public const string Seconds = "Seconds";
public const string BaseCount = "BaseCount";
public const string ReadType = "ReadType";
public const string LastUser = "LastUser";
public const string AllowChangeLevel = "AllowChangeLevel";
public const string SubWeight = "SubWeight";
public const string PerDayStartHour = "PerDayStartHour"; }
}

+ 56
- 0
B3ButcherWeightClient/Data/DataFormatBase.cs View File

@ -0,0 +1,56 @@
namespace B3ButcherWeightClient.Data {
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);
}
public 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);
}
}

+ 42
- 0
B3ButcherWeightClient/Data/IND560DataFormat.cs View File

@ -0,0 +1,42 @@
using System.Text;
namespace B3ButcherWeightClient.Data
{
public 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)0x0A; ; }
}
public override short Bufsize {
get { return 10; }
}
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);
weight = weight.Trim();
return true;
}
public override bool ParseAscii(string buf, out string weight, out bool isStatic, out string subStr) {
weight = "";
isStatic = false;
subStr = "";
return false;
}
}
}

+ 103
- 0
B3ButcherWeightClient/Data/Xk3124DataFormat.cs View File

@ -0,0 +1,103 @@
using System.Text;
namespace B3ButcherWeightClient.Data {
public 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;
}
}
//IND560单次读入
}

+ 110
- 0
B3ButcherWeightClient/Data/Xk3190A9DataFormat.cs View File

@ -0,0 +1,110 @@
namespace B3ButcherWeightClient.Data
{
public 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;
}
}
}

+ 106
- 0
B3ButcherWeightClient/Data/Xk3190D10DataFormat.cs View File

@ -0,0 +1,106 @@
namespace B3ButcherWeightClient.Data
{
public class Xk3190D10DataFormat : DataFormatBase {
public override int DataLength {
get { return 12; }
}
public override char Beginchar {
get { return (char)0x02; }
}
public override char Endchar {
get { return (char)0x0D; ; }
}
public override short Bufsize
{
get { return 24; }
}
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, "-");
} else {
}
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 );
subStr = "";
if (string.IsNullOrEmpty(weight)) {
return false;
}
weight = ParseData(weight, out isStatic);
return true;
}
#region 1.3 验证int奇数偶数
/// <summary>
/// 1.3 验证int奇数偶数
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
public bool isJO(int num) {
int a = num % 2;
if (a == 0)
return true;
else
return false;
}
#endregion
}
}

+ 48
- 0
B3ButcherWeightClient/EncodeString.cs View File

@ -0,0 +1,48 @@
namespace B3ButcherWeightClient {
public class EncodeString {
public static string Encode(string str) {
int length = str.Length;
byte[] buffer = new byte[length];
int i = 0;
foreach (char c in str) {
byte b = (byte)c;
byte tem = b;
byte bit0 = (byte)(b & 1);
byte bit1 = (byte)((b >> 1) & 1);
byte bit2 = (byte)((b >> 2) & 1);
byte bit3 = (byte)((b >> 3) & 1);
byte bit4 = (byte)((b >> 4) & 1);
byte bit5 = (byte)((b >> 5) & 1);
byte bit6 = (byte)((b >> 6) & 1);
byte bit7 = (byte)((b >> 7) & 1);
tem = (byte)(tem & 0);
tem = (byte)((bit0 << 7) | tem);
tem = (byte)((bit1 << 6) | tem);
tem = (byte)((bit2 << 3) | tem);
tem = (byte)((bit3 << 2) | tem);
tem = (byte)((bit4 << 5) | tem);
tem = (byte)((bit5 << 4) | tem);
tem = (byte)((bit6 << 1) | tem);
tem = (byte)(bit7 | tem);
buffer[i] = tem;
i++;
}
char[] ch = new char[length];
int j = 0;
foreach (byte b in buffer) {
ch[j] = (char)b;
j++;
}
return new string(ch);
}
public static readonly object RwLocker = new object();
}
}

+ 163
- 0
B3ButcherWeightClient/Livestock.Designer.cs View File

@ -0,0 +1,163 @@
namespace B3ButcherWeightClient {
partial class Livestock {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.Column3 = new System.Windows.Forms.DataGridViewButtonColumn();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.Column3,
this.Column1,
this.Column2});
this.dataGridView1.Location = new System.Drawing.Point(0, 41);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(378, 327);
this.dataGridView1.TabIndex = 0;
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
//
// Column3
//
this.Column3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
this.Column3.HeaderText = "删除";
this.Column3.Name = "Column3";
this.Column3.Text = "删除";
this.Column3.ToolTipText = "删除";
this.Column3.UseColumnTextForButtonValue = true;
this.Column3.Width = 35;
//
// Column1
//
this.Column1.DataPropertyName = "ID";
this.Column1.HeaderText = "ID";
this.Column1.Name = "Column1";
//
// Column2
//
this.Column2.DataPropertyName = "名称";
this.Column2.HeaderText = "名称";
this.Column2.Name = "Column2";
//
// button1
//
this.button1.Location = new System.Drawing.Point(303, 12);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "增加";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(32, 12);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(88, 21);
this.textBox1.TabIndex = 2;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(171, 12);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 21);
this.textBox2.TabIndex = 3;
this.textBox2.TextChanged += new System.EventHandler(this.textBox2_TextChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(9, 17);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(23, 12);
this.label1.TabIndex = 4;
this.label1.Text = "ID:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(136, 17);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(35, 12);
this.label2.TabIndex = 5;
this.label2.Text = "名称:";
//
// button2
//
this.button2.Location = new System.Drawing.Point(152, 374);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 1;
this.button2.Text = "保存";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Livestock
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(378, 404);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.dataGridView1);
this.Name = "Livestock";
this.Text = "级别设置";
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.DataGridViewButtonColumn Column3;
private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
}
}

+ 70
- 0
B3ButcherWeightClient/Livestock.cs View File

@ -0,0 +1,70 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Forks.Utils.IO;
namespace B3ButcherWeightClient {
public partial class Livestock : Form {
public class Info {
public long ID { get; set; }
public string { get; set; }
}
readonly IList<Info> _dTable = new List<Info>();
public Livestock() {
InitializeComponent();
ConfigUtil.SetLivestock(_dTable);
dataGridView1.DataSource = _dTable;
}
private void textBox2_TextChanged(object sender, EventArgs e) {
}
private void button1_Click(object sender, EventArgs e) {
var item = new Info();
var id = long.Parse(textBox1.Text);
item.ID = id;
item. = textBox2.Text;
_dTable.Add(item);
dataGridView1.DataSource = null;
dataGridView1.DataSource = _dTable;
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) {
var data = (IList<Info>)dataGridView1.DataSource;
if (Column3.Index == e.ColumnIndex) {
DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
var info = row.DataBoundItem as Info;
if (info != null)
data.Remove(info);
dataGridView1.DataSource = null;
dataGridView1.DataSource = data;
}
}
private void button2_Click(object sender, EventArgs e) {
var str = new StringBuilder();
foreach (DataGridViewRow row in dataGridView1.Rows) {
var info = row.DataBoundItem as Info;
if (info != null) {
str.AppendFormat("{0}|{1},", info.ID, info.);
}
}
using (TextReader reader = FS.OpenReader(ConfigUtil.LivestockFilePath, true)) {
var nutFile = NutFile.Parse(reader);
nutFile.SetValue("ITEM", str.ToString());
using (TextWriter writer = FS.OpenWriter(ConfigUtil.LivestockFilePath, createDirsIfNotExist: true)) {
nutFile.Write(writer);
}
}
Dispose();
}
}
}

+ 129
- 0
B3ButcherWeightClient/Livestock.resx View File

@ -0,0 +1,129 @@
<?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.Runtime.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:import namespace="http://www.w3.org/XML/1998/namespace" />
<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" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</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" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

+ 0
- 0
B3ButcherWeightClient/Livestock.txt View File


+ 29
- 0
B3ButcherWeightClient/LogUtil.cs View File

@ -0,0 +1,29 @@
using System;
using System.IO;
using System.Text;
using System.Windows.Forms;
namespace B3ButcherWeightClient
{
public class LogUtil {
static string LogPath {
get {
return Application.StartupPath + "\\" + DateTime.Today.ToString("yyyyMMdd") + "ErrorLog.txt";
}
}
public static void WriteLog(string msg) {
try {
using (var writer = new StreamWriter(LogPath, true, Encoding.UTF8)) {
writer.WriteLine(msg);
writer.WriteLine();
writer.Close();
writer.Dispose();
}
} catch (Exception ex) {
MessageBox.Show(ex.Message);
}
}
}
}

+ 119
- 0
B3ButcherWeightClient/Login.Designer.cs View File

@ -0,0 +1,119 @@
namespace B3ButcherWeightClient {
partial class Login {
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent() {
this.btnLogin = new System.Windows.Forms.Button();
this.txtBPassword = new System.Windows.Forms.TextBox();
this.txtBUser = new System.Windows.Forms.TextBox();
this.lblPassWord = new System.Windows.Forms.Label();
this.lblLoginName = new System.Windows.Forms.Label();
this.btnSetConStr = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btnLogin
//
this.btnLogin.Location = new System.Drawing.Point(183, 113);
this.btnLogin.Name = "btnLogin";
this.btnLogin.Size = new System.Drawing.Size(75, 23);
this.btnLogin.TabIndex = 10;
this.btnLogin.Text = "登 录";
this.btnLogin.UseVisualStyleBackColor = true;
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
//
// txtBPassword
//
this.txtBPassword.Location = new System.Drawing.Point(124, 60);
this.txtBPassword.MaxLength = 16;
this.txtBPassword.Name = "txtBPassword";
this.txtBPassword.PasswordChar = '*';
this.txtBPassword.Size = new System.Drawing.Size(114, 21);
this.txtBPassword.TabIndex = 9;
//
// txtBUser
//
this.txtBUser.Location = new System.Drawing.Point(124, 21);
this.txtBUser.MaxLength = 20;
this.txtBUser.Name = "txtBUser";
this.txtBUser.Size = new System.Drawing.Size(114, 21);
this.txtBUser.TabIndex = 7;
//
// lblPassWord
//
this.lblPassWord.AutoSize = true;
this.lblPassWord.Location = new System.Drawing.Point(77, 63);
this.lblPassWord.Name = "lblPassWord";
this.lblPassWord.Size = new System.Drawing.Size(41, 12);
this.lblPassWord.TabIndex = 8;
this.lblPassWord.Text = "密 码";
//
// lblLoginName
//
this.lblLoginName.AutoSize = true;
this.lblLoginName.Location = new System.Drawing.Point(77, 24);
this.lblLoginName.Name = "lblLoginName";
this.lblLoginName.Size = new System.Drawing.Size(41, 12);
this.lblLoginName.TabIndex = 6;
this.lblLoginName.Text = "用 户";
//
// btnSetConStr
//
this.btnSetConStr.Location = new System.Drawing.Point(84, 113);
this.btnSetConStr.Name = "btnSetConStr";
this.btnSetConStr.Size = new System.Drawing.Size(77, 23);
this.btnSetConStr.TabIndex = 11;
this.btnSetConStr.Text = "设 置";
this.btnSetConStr.UseVisualStyleBackColor = true;
this.btnSetConStr.Click += new System.EventHandler(this.btnSetConStr_Click);
//
// Login
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(343, 170);
this.Controls.Add(this.btnSetConStr);
this.Controls.Add(this.btnLogin);
this.Controls.Add(this.txtBPassword);
this.Controls.Add(this.txtBUser);
this.Controls.Add(this.lblPassWord);
this.Controls.Add(this.lblLoginName);
this.Name = "Login";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "青花瓷屠宰称重客户端";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnLogin;
private System.Windows.Forms.TextBox txtBPassword;
private System.Windows.Forms.TextBox txtBUser;
private System.Windows.Forms.Label lblPassWord;
private System.Windows.Forms.Label lblLoginName;
private System.Windows.Forms.Button btnSetConStr;
}
}

+ 113
- 0
B3ButcherWeightClient/Login.cs View File

@ -0,0 +1,113 @@
using System;
using System.Data;
using System.IO;
using System.Windows.Forms;
using Forks.Utils.Data;
using Forks.Utils.IO;
namespace B3ButcherWeightClient {
public partial class Login : Form {
public Login() {
InitializeComponent();
using (TextReader reader = FS.OpenReader(ConfigUtil.ConfigFilePath,true)) {
NutFile nutFile = NutFile.Parse(reader);
txtBUser.Text = nutFile.AsString(ConfigItem.LastUser, "system");
}
}
private void Form1_Load(object sender, EventArgs e) {
}
private void btnLogin_Click(object sender, EventArgs e) {
ConfigUtil.Init();
string loginUser = txtBUser.Text.Trim();
string passWord = txtBPassword.Text.Trim();
long userID = 0;
string role = "";
if (!CheckUser(loginUser)) {
MessageBox.Show("用户名不存在!");
txtBUser.Text = "";
txtBPassword.Text = "";
txtBUser.Focus();
} else {
if (CheckPassword(loginUser, passWord, out userID, out role)) {
Form main = new Main(this);
Hide();
using (var reader = FS.OpenReader(ConfigUtil.ConfigFilePath)) {
var nutFile = NutFile.Parse(reader);
nutFile.SetValue(ConfigItem.LastUser, loginUser);
using (var writer = FS.OpenWriter(ConfigUtil.ConfigFilePath)) {
nutFile.Write(writer);
}
}
main.Show();
} else {
MessageBox.Show("密码错误!");
txtBPassword.Text = "";
txtBPassword.Focus();
}
}
}
private void btnSetConStr_Click(object sender, EventArgs e) {
Form setForm = new Setting();
setForm.ShowDialog();
}
private static bool CheckUser(string userName) {
var conStr = ConfigUtil.ConnectionStr;
if (string.IsNullOrEmpty(conStr)) {
MessageBox.Show("未设置本地数据库信息");
return false;
}
var isExist = false;
if (!string.IsNullOrEmpty(userName)) {
string sql = "select PassWord from LoginUser where UserName='" + userName.Trim() + "'";
try {
using (ISqlUtil sqlUtil = new SqlUtil(conStr)) {
DataSet dataSet = sqlUtil.ExecuteSql(sql);
if (dataSet.Tables[0].Rows.Count > 0) {
isExist = true;
}
}
} catch (Exception ex) {
MessageBox.Show(ex.Message);
return false;
}
}
return isExist;
}
private static bool CheckPassword(string userName, string password, out long userID, out string role) {
userID = 0;
role = "";
string conStr = ConfigUtil.ConnectionStr;
bool isRight = false;
string sql = "select top 1 ID,RoleSchema from LoginUser where UserName='" + userName.Trim() + "' and PassWord=cast('" + password.Trim() + "' as binary)";
try {
using (ISqlUtil sqlUtil = new SqlUtil(conStr)) {
DataSet dataSet = sqlUtil.ExecuteSql(sql);
if (dataSet.Tables[0].Rows.Count > 0) {
isRight = true;
userID = (long)dataSet.Tables[0].Rows[0][0];
role = (string)dataSet.Tables[0].Rows[0][1];
}
}
} catch (Exception ex) {
MessageBox.Show(ex.Message);
return false;
}
return isRight;
}
}
}

+ 123
- 0
B3ButcherWeightClient/Login.resx View File

@ -0,0 +1,123 @@
<?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.Runtime.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:import namespace="http://www.w3.org/XML/1998/namespace" />
<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" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</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" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

+ 442
- 0
B3ButcherWeightClient/Main.Designer.cs View File

@ -0,0 +1,442 @@
using System.Drawing;
using System.Threading;
namespace B3ButcherWeightClient {
partial class Main {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
_timer.Dispose();
_mainProcessIsRun = false;
this._manualResetEvent.Set();
Thread.Sleep(500);
if (_serialPort.IsOpen) { // 关闭串口
_serialPort.Close();
_serialPort.Dispose();
}
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
if (_parentForm != null) {
_parentForm.Dispose();
}
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
this.lblDisplay = new System.Windows.Forms.Label();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Sequence = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.JdColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this. = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.DataTime = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.LevelID = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.subColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Weight = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.DeleteDetail = new System.Windows.Forms.DataGridViewButtonColumn();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.button1 = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.txtBatch = new System.Windows.Forms.TextBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.tbxSequence = new System.Windows.Forms.TextBox();
this.subWeightTextBox = new System.Windows.Forms.TextBox();
this.jdTextBox = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.lblNumber = new System.Windows.Forms.Label();
this.saveButton = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this._serialPort = new System.IO.Ports.SerialPort(this.components);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
this.SuspendLayout();
//
// lblDisplay
//
this.lblDisplay.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lblDisplay.BackColor = System.Drawing.Color.Black;
this.lblDisplay.Font = new System.Drawing.Font("宋体", 26.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblDisplay.ForeColor = System.Drawing.Color.LimeGreen;
this.lblDisplay.Location = new System.Drawing.Point(3, 3);
this.lblDisplay.Name = "lblDisplay";
this.lblDisplay.Size = new System.Drawing.Size(410, 64);
this.lblDisplay.TabIndex = 3;
this.lblDisplay.Text = "display";
this.lblDisplay.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// dataGridView
//
this.dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToDeleteRows = false;
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
this.dataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ID,
this.Sequence,
this.JdColumn,
this.,
this.DataTime,
this.LevelID,
this.subColumn,
this.Weight,
this.DeleteDetail});
this.dataGridView.Location = new System.Drawing.Point(3, 70);
this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true;
this.dataGridView.RowTemplate.Height = 23;
this.dataGridView.Size = new System.Drawing.Size(716, 675);
this.dataGridView.TabIndex = 4;
this.dataGridView.TabStop = false;
this.dataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridViewCellContentClick);
this.dataGridView.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView_CellMouseDoubleClick);
//
// ID
//
this.ID.DataPropertyName = "ID";
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
this.ID.DefaultCellStyle = dataGridViewCellStyle2;
this.ID.FillWeight = 0.8F;
this.ID.HeaderText = "ID";
this.ID.Name = "ID";
this.ID.ReadOnly = true;
this.ID.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Sequence
//
this.Sequence.DataPropertyName = "Sequence";
this.Sequence.FillWeight = 0.7901235F;
this.Sequence.HeaderText = "顺序号";
this.Sequence.Name = "Sequence";
this.Sequence.ReadOnly = true;
//
// JdColumn
//
this.JdColumn.DataPropertyName = "PhaseCode";
this.JdColumn.FillWeight = 0.7901235F;
this.JdColumn.HeaderText = "阶段号";
this.JdColumn.Name = "JdColumn";
this.JdColumn.ReadOnly = true;
this.JdColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// 批号
//
this..DataPropertyName = "GoodsBatchName";
this..FillWeight = 0.7901235F;
this..HeaderText = "批号";
this..Name = "批号";
this..ReadOnly = true;
//
// DataTime
//
this.DataTime.DataPropertyName = "DateTime";
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle3.Format = "yyyy-MM-dd HH:mm:ss";
this.DataTime.DefaultCellStyle = dataGridViewCellStyle3;
this.DataTime.FillWeight = 0.7901235F;
this.DataTime.HeaderText = "时间";
this.DataTime.Name = "DataTime";
this.DataTime.ReadOnly = true;
this.DataTime.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// LevelID
//
this.LevelID.DataPropertyName = "Livestock_Name";
this.LevelID.FillWeight = 0.7901235F;
this.LevelID.HeaderText = "级别";
this.LevelID.Name = "LevelID";
this.LevelID.ReadOnly = true;
this.LevelID.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.LevelID.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// subColumn
//
this.subColumn.DataPropertyName = "SubWeight";
dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
dataGridViewCellStyle4.Format = "0.00";
this.subColumn.DefaultCellStyle = dataGridViewCellStyle4;
this.subColumn.FillWeight = 0.7901235F;
this.subColumn.HeaderText = "扣重";
this.subColumn.MinimumWidth = 50;
this.subColumn.Name = "subColumn";
this.subColumn.ReadOnly = true;
this.subColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// Weight
//
this.Weight.DataPropertyName = "Weight";
dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
dataGridViewCellStyle5.Format = "0.00";
this.Weight.DefaultCellStyle = dataGridViewCellStyle5;
this.Weight.FillWeight = 1F;
this.Weight.HeaderText = "重量";
this.Weight.Name = "Weight";
this.Weight.ReadOnly = true;
this.Weight.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
//
// DeleteDetail
//
this.DeleteDetail.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
this.DeleteDetail.FillWeight = 1F;
this.DeleteDetail.HeaderText = "删除";
this.DeleteDetail.Name = "DeleteDetail";
this.DeleteDetail.ReadOnly = true;
this.DeleteDetail.Text = "删除";
this.DeleteDetail.UseColumnTextForButtonValue = true;
this.DeleteDetail.Width = 35;
//
// splitContainer1
//
this.splitContainer1.BackColor = System.Drawing.Color.LightGray;
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.BackColor = System.Drawing.Color.White;
this.splitContainer1.Panel1.Controls.Add(this.button1);
this.splitContainer1.Panel1.Controls.Add(this.lblDisplay);
this.splitContainer1.Panel1.Controls.Add(this.dataGridView);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.BackColor = System.Drawing.Color.White;
this.splitContainer1.Panel2.Controls.Add(this.pictureBox1);
this.splitContainer1.Panel2.Controls.Add(this.txtBatch);
this.splitContainer1.Panel2.Controls.Add(this.pictureBox2);
this.splitContainer1.Panel2.Controls.Add(this.tbxSequence);
this.splitContainer1.Panel2.Controls.Add(this.subWeightTextBox);
this.splitContainer1.Panel2.Controls.Add(this.jdTextBox);
this.splitContainer1.Panel2.Controls.Add(this.label2);
this.splitContainer1.Panel2.Controls.Add(this.label3);
this.splitContainer1.Panel2.Controls.Add(this.label1);
this.splitContainer1.Panel2.Controls.Add(this.lblNumber);
this.splitContainer1.Panel2.Controls.Add(this.saveButton);
this.splitContainer1.Panel2.Controls.Add(this.panel1);
this.splitContainer1.Size = new System.Drawing.Size(1387, 748);
this.splitContainer1.SplitterDistance = 722;
this.splitContainer1.TabIndex = 6;
//
// button1
//
this.button1.Font = new System.Drawing.Font("宋体", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button1.Location = new System.Drawing.Point(520, 3);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(167, 58);
this.button1.TabIndex = 5;
this.button1.Text = "查询";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(741, 8);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(34, 29);
this.pictureBox1.TabIndex = 18;
this.pictureBox1.TabStop = false;
this.pictureBox1.Visible = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox2_Click);
//
// txtBatch
//
this.txtBatch.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtBatch.Location = new System.Drawing.Point(262, 69);
this.txtBatch.Name = "txtBatch";
this.txtBatch.Size = new System.Drawing.Size(119, 29);
this.txtBatch.TabIndex = 11;
//
// pictureBox2
//
this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
this.pictureBox2.Location = new System.Drawing.Point(654, 3);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(34, 29);
this.pictureBox2.TabIndex = 18;
this.pictureBox2.TabStop = false;
this.pictureBox2.Visible = false;
this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click);
//
// tbxSequence
//
this.tbxSequence.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tbxSequence.Location = new System.Drawing.Point(79, 70);
this.tbxSequence.Name = "tbxSequence";
this.tbxSequence.ReadOnly = true;
this.tbxSequence.Size = new System.Drawing.Size(122, 29);
this.tbxSequence.TabIndex = 11;
//
// subWeightTextBox
//
this.subWeightTextBox.Font = new System.Drawing.Font("宋体", 42F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.subWeightTextBox.Location = new System.Drawing.Point(259, 8);
this.subWeightTextBox.Multiline = true;
this.subWeightTextBox.Name = "subWeightTextBox";
this.subWeightTextBox.Size = new System.Drawing.Size(122, 43);
this.subWeightTextBox.TabIndex = 8;
this.subWeightTextBox.Visible = false;
//
// jdTextBox
//
this.jdTextBox.Font = new System.Drawing.Font("宋体", 42F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.jdTextBox.Location = new System.Drawing.Point(79, 8);
this.jdTextBox.Multiline = true;
this.jdTextBox.Name = "jdTextBox";
this.jdTextBox.Size = new System.Drawing.Size(122, 43);
this.jdTextBox.TabIndex = 8;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(207, 9);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(59, 20);
this.label2.TabIndex = 12;
this.label2.Text = "扣重:";
this.label2.Visible = false;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label3.Location = new System.Drawing.Point(209, 72);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(59, 20);
this.label3.TabIndex = 12;
this.label3.Text = "批号:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(6, 18);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(79, 20);
this.label1.TabIndex = 12;
this.label1.Text = "标识号:";
//
// lblNumber
//
this.lblNumber.AutoSize = true;
this.lblNumber.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblNumber.Location = new System.Drawing.Point(6, 72);
this.lblNumber.Name = "lblNumber";
this.lblNumber.Size = new System.Drawing.Size(79, 20);
this.lblNumber.TabIndex = 12;
this.lblNumber.Text = "顺序号:";
//
// saveButton
//
this.saveButton.Font = new System.Drawing.Font("宋体", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.saveButton.Location = new System.Drawing.Point(402, 3);
this.saveButton.Name = "saveButton";
this.saveButton.Size = new System.Drawing.Size(167, 58);
this.saveButton.TabIndex = 7;
this.saveButton.Text = "添 加";
this.saveButton.UseVisualStyleBackColor = true;
this.saveButton.Click += new System.EventHandler(this.saveButton_Click);
//
// panel1
//
this.panel1.AutoScroll = true;
this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.panel1.Location = new System.Drawing.Point(3, 105);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(655, 640);
this.panel1.TabIndex = 6;
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1387, 748);
this.Controls.Add(this.splitContainer1);
this.Name = "Main";
this.Text = "青花瓷称重客户端";
this.Load += new System.EventHandler(this.Main_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Label lblDisplay;
private System.Windows.Forms.DataGridView dataGridView;
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button saveButton;
private System.Windows.Forms.TextBox jdTextBox;
private System.Windows.Forms.TextBox tbxSequence;
private System.Windows.Forms.Label lblNumber;
private System.Windows.Forms.Label label1;
private System.IO.Ports.SerialPort _serialPort;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox subWeightTextBox;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.DataGridViewTextBoxColumn ID;
private System.Windows.Forms.DataGridViewTextBoxColumn Sequence;
private System.Windows.Forms.DataGridViewTextBoxColumn JdColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn ;
private System.Windows.Forms.DataGridViewTextBoxColumn DataTime;
private System.Windows.Forms.DataGridViewTextBoxColumn LevelID;
private System.Windows.Forms.DataGridViewTextBoxColumn subColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn Weight;
private System.Windows.Forms.DataGridViewButtonColumn DeleteDetail;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.TextBox txtBatch;
}
}

+ 632
- 0
B3ButcherWeightClient/Main.cs View File

@ -0,0 +1,632 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using B3ButcherWeightClient.Data;
using BO;
using Forks.EnterpriseServices.BusinessInterfaces;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.Utils.Data;
using Timer = System.Threading.Timer;
namespace B3ButcherWeightClient
{
public partial class Main : Form
{
#region 变量实例
private string _msg = string.Empty;
private readonly IDataFormat _dataFormat;
private Thread _insertThread;
private Thread _inQueryThread, _outQueryThread;
private bool _mainProcessIsRun;
private static DateTime NewToday
{
get
{
return new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, ConfigUtil.PerDayStartHour, 0, 0);
}
}
private static DateTime NextNewToday
{
get { return NewToday.AddHours(24); }
}
private readonly ManualResetEvent _manualResetEvent = new ManualResetEvent(false);
private readonly object _queLocker = new object();
private readonly Queue<WeightTable> _weightQueue = new Queue<WeightTable>();
readonly ConcurrentQueue<string> _dataQueue = new ConcurrentQueue<string>();
readonly StringBuilder _dataStrBuilder = new StringBuilder();
readonly Form _parentForm;
readonly IList<Livestock.Info> _dTable = new List<Livestock.Info>();
readonly IList<Button> _btList = new List<Button>();
private Livestock.Info _currentInfo = new Livestock.Info();
static string startDate = NewToday.ToString("yyyy-MM-dd HH:mm:ss");//24小时
private readonly string _querySql = string.Format("select [ID],[Sequence],[PhaseCode],[DateTime],[Livestock_Name],[Weight],[SubWeight],[GoodsBatchName] from [WeightTable] where [DateTime] >='{0}' order by [ID] desc", startDate);
private string _querySeqSql = string.Format("select top 1 Sequence from [WeightTable] where [DateTime] > '{0}' and [DateTime] <'{1}' order by Sequence desc", NewToday.ToString("yyyy-MM-dd HH:mm"), NextNewToday.ToString("yyyy-MM-dd HH:mm"));
private DataSet _resultDataSet = new DataSet();
private readonly Timer _timer;
private const int WmProcessMessage = 0x0500 + 1;
private const int WmUpdDisplayMessage = 0x0500 + 2;
private const int WmUpdLanStateMessage = 0x0500 + 3;
private string _displayValue;
private int _mainHandle;
int MainHandle
{
get
{
if (_mainHandle == 0)
{
_mainHandle = WinApiSendMessage.FindWindow(null, @"青花瓷称重客户端");
}
return _mainHandle;
}
}
#endregion
readonly AutoSizeFormClass _asc = new AutoSizeFormClass();
public Main(Form form)
{
InitializeComponent();
dataGridView.AutoGenerateColumns = false;
OpenSerialPort();
_parentForm = form;
AddLivestockControl();
_displayValue = "display";
_mainProcessIsRun = true;
pictureBox2.Visible = false;
switch (ConfigUtil.CType)
{
case "XK3130":
case "XK3124":
_dataFormat = new Xk3124DataFormat();
break;
case "IND560":
_dataFormat = new IND560DataFormat();
break;
case "Xk3190A9":
_dataFormat = new Xk3190A9DataFormat();
break;
default:
_dataFormat = new Xk3124DataFormat();
break;
}
BeginInsertThread();
ReadData();
_timer = new Timer(TimerClick, null, 0, 1000);
var syncThread = new Thread(SyncTask) { IsBackground = true };
syncThread.Start();
CheckForIllegalCrossThreadCalls = false;//线程间操作
tbxSequence.Text = "1";
}
protected override void DefWndProc(ref Message m)
{
switch (m.Msg)
{
case WmProcessMessage:
QueryResult();
break;
case WmUpdDisplayMessage:
lblDisplay.Text = _displayValue;
break;
case WmUpdLanStateMessage:
break;
default:
base.DefWndProc(ref m);
break;
}
}
#region 控件事件
private void Main_Resize(object sender, EventArgs e)
{
_asc.controlAutoSize(this);
}
void bt_Click(object sender, EventArgs e)
{
var bt = sender as Button;
foreach (var button in _btList)
{
button.BackColor = Color.White;
}
if (bt != null)
{
bt.BackColor = Color.OrangeRed;
_currentInfo = bt.Tag as Livestock.Info;
}
}
private void Main_Load(object sender, EventArgs e)
{
InitSequence();
//_asc.ControllInitializeSize(this);
//WindowState = FormWindowState.Maximized;
FormLoadQueryResult();
}
private void saveButton_Click(object sender, EventArgs e)
{
decimal w;
if (decimal.TryParse(_displayValue, out w))
AddWeightInfo(w);
}
private void DataGridViewCellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (DeleteDetail.Index == e.ColumnIndex)
{
if (MessageBox.Show("确定要删除吗?", "删除", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
return;
var sql = string.Format("delete [WeightTable] where id = {0}", dataGridView.Rows[e.RowIndex].Cells["ID"].Value);
//var sequence = dataGridView.Rows[e.RowIndex].Cells["Sequence"].Value;
using (var sqlUtil = new SqlUtil(ConfigUtil.ConnectionStr))
{
sqlUtil.ExecuteNonQuery(sql);
}
//同步删除远程数据库的数据
pictureBox2.Visible = !SyncUtil.TryDeleteServerData(dataGridView.Rows[e.RowIndex].Cells["ID"].Value.ToString(), out _msg);
dataGridView.Rows.RemoveAt(e.RowIndex);
InitSequence();
//
}
}
private void pictureBox2_Click(object sender, EventArgs e)
{
MessageBox.Show(_msg);
}
#endregion
#region 方法
private void InitSequence()
{
using (var sqlUtil = new SqlUtil(ConfigUtil.ConnectionStr))
{
var obj = sqlUtil.ExecuteScalar(_querySeqSql);
tbxSequence.Text = obj != null ? (long.Parse(obj.ToString()) + 1).ToString() : @"1";
}
}
private void AddLivestockControl()
{
ConfigUtil.SetLivestock(_dTable);
var i = 0;
var j = 0;
foreach (var info in _dTable)
{
var bt = new Button();
bt.Text = info.;
bt.Size = new Size(200, 100);
bt.Left = i * 203;
bt.Top = j * 102;
bt.Tag = info;
bt.Click += bt_Click;
panel1.Controls.Add(bt);
_btList.Add(bt);
i++;
if (i == 3)
{
i = 0;
j++;
}
}
}
private void OpenSerialPort()
{
_serialPort.PortName = ConfigUtil.ComName;
_serialPort.BaudRate = int.Parse(ConfigUtil.BaundRate);
_serialPort.DataBits = int.Parse(ConfigUtil.DataBits);
_serialPort.ReadBufferSize = 4096 * 100;
// 打开串口
if (!_serialPort.IsOpen)
{
try
{
_serialPort.Open();
}
catch (InvalidOperationException)
{
MessageBox.Show(@"指定的端口已打开");
}
catch (UnauthorizedAccessException)
{
MessageBox.Show(@"对端口的访问被拒绝");
}
}
}
// 接受数据: 称仪表连续输出
void ReadData()
{
_inQueryThread = new Thread(InQuery);
_inQueryThread.Start();
_outQueryThread = new Thread(OutQuery);
_outQueryThread.Start();
}
private void InQuery()
{
while (_mainProcessIsRun)
{
int availableCount = _serialPort.BytesToRead;
if (availableCount == 0)
{
Thread.Sleep(1);
}
char[] buffer = new char[availableCount];
_serialPort.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);
_dataQueue.Enqueue(_dataStrBuilder.ToString());
_dataStrBuilder.Clear();
}
else
{
_dataStrBuilder.Append(c);
}
}
}
}
private void OutQuery()
{
while (_mainProcessIsRun)
{
try
{
bool isStatic;
string str;
string subStr;
if (!_dataQueue.TryDequeue(out subStr))
{
Thread.Sleep(1);
continue;
}
// 解析接受的端口数据
if (_dataFormat.ParseAscii(subStr, out str, out isStatic))
{
_displayValue = str;
WinApiSendMessage.SendMessage(_mainHandle, WmUpdDisplayMessage, 0, 0);
}
decimal num;
if (ConfigUtil.ReadType == "0")
{
if (decimal.TryParse(str, out num))
{
WeighAvgControl.Add(num, isStatic);
}
if (WeighAvgControl.TryGetValue(out num))
{
AddWeightInfo(num);
}
}
else if (ConfigUtil.ReadType == "1")
{
if (decimal.TryParse(str, out num))
{
if (num >= ConfigUtil.MinWeight && num <= ConfigUtil.MaxWeight)
AddWeightInfo(num);
}
}
}
catch (Exception)
{
Thread.Sleep(1000);
continue;
}
Thread.Sleep(1);
}
}
private void TimerClick(object o)
{
WinApiSendMessage.SendMessage(MainHandle, WmUpdLanStateMessage, 0, 0);
}
private void AddWeightInfo(decimal curValue)
{
var info = new WeightTable();
info.DateTime = DateTime.Now;
info.SubWeight = ConfigUtil.SubWeight;//默认取设置的扣重
decimal subWeight = 0;
if (!string.IsNullOrEmpty(subWeightTextBox.Text))
{
if (decimal.TryParse(subWeightTextBox.Text, out subWeight))
info.SubWeight = subWeight;
}
info.Weight = curValue - subWeight;
info.Livestock_ID = _currentInfo.ID;
info.Livestock_Name = _currentInfo.;
info.Sequence = long.Parse(tbxSequence.Text);
info.PhaseCode = jdTextBox.Text;
info.GoodsBatchName = txtBatch.Text;
WeightEnQueue(info);
}
private void WeightEnQueue(WeightTable inforStruct)
{
Monitor.Enter(_queLocker);
_weightQueue.Enqueue(inforStruct);
_manualResetEvent.Set();
Monitor.Exit(_queLocker);
}
private WeightTable WeightDeQueue()
{
Monitor.Enter(_queLocker);
WeightTable weightInfo = null;
if (_weightQueue.Count > 0)
{
weightInfo = _weightQueue.Dequeue();
}
Monitor.Exit(_queLocker);
return weightInfo;
}
private void BeginInsertThread()
{
_insertThread = new Thread(DoInser) { IsBackground = true };
_insertThread.Start(new object());
}
private void DoInser(object o)
{
_manualResetEvent.WaitOne();
while (_mainProcessIsRun)
{
var weightInfo = WeightDeQueue();//获取队列对象
if (weightInfo != null)
{
string err = string.Empty;
try
{
using (var context = new TransactionContext(Dmo.NewSession(ConfigUtil.ConnectionStr)))
{
context.Session.Insert(weightInfo);
//_displayValue = weightInfo.Weight.ToString();
context.Commit();
}
tbxSequence.Text = (weightInfo.Sequence + 1).ToString();
}
catch (Exception ex)
{
err = ex.Message;
}
finally
{
lock (EncodeString.RwLocker)
{
using (ISqlUtil sqlUtil = new SqlUtil(ConfigUtil.ConnectionStr))
{
try
{
lock (EncodeString.RwLocker)
{
_resultDataSet = sqlUtil.ExecuteSql(_querySql);
}
sqlUtil.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
if (!string.IsNullOrEmpty(err))
MessageBox.Show(err);
WinApiSendMessage.SendMessage(_mainHandle, WmProcessMessage, 0, 0);
}
}
}
private void QueryResult()
{
lock (EncodeString.RwLocker)
{
dataGridView.DataSource = _resultDataSet.Tables[0];
}
}
private void FormLoadQueryResult()
{
using (ISqlUtil sqlUtil = new SqlUtil(ConfigUtil.ConnectionStr))
{
try
{
lock (EncodeString.RwLocker)
{
_resultDataSet = sqlUtil.ExecuteSql(_querySql);
}
sqlUtil.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
dataGridView.DataSource = _resultDataSet.Tables[0];
}
void SyncTask()
{
var sleeptime = 500;
pictureBox2.Visible = true;
while (_mainProcessIsRun)
{
Thread.Sleep(sleeptime);
sleeptime = 20000;
if (string.IsNullOrEmpty(ConfigUtil.RemoteConStr))
{
_msg = "没有设置服务器数据库,无法同步!";
LogUtil.WriteLog(DateTime.Now + ":" + _msg);
continue;
}
pictureBox2.Visible = !SyncUtil.TryUpdateServerData(out _msg);
}
}
#endregion
private class WeighAvgControl
{
public static bool TryGetValue(out decimal result)
{
List<Tuple<decimal, bool>> list;
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 >= ConfigUtil.MinWeight && value <= ConfigUtil.MaxWeight)
{
_list.Add(new Tuple<decimal, bool>(value, isStatic));
}
else
{
if (_list.Count > 0)
{
mWeighList.Enqueue(_list);
_list = new List<Tuple<decimal, bool>>();
}
}
}
}
private void dataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (!ConfigUtil.AllowChangeLevel)
{
return;
}
// e.RowIndex
long id;
if (long.TryParse(dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString(), out id))
{
var levelName = dataGridView.Rows[e.RowIndex].Cells[0].Value.ToString();
var f = new ChangeLevelForm();
f.Init(levelName);
if (f.ShowDialog() == DialogResult.OK)
{
var newLevelId = f.mID;
var newLevelName = f.mName;
var updateSql = "update [WeightTable] set [Livestock_ID]=" + newLevelId + ",[Livestock_Name]='" + newLevelName + "' where ID=" + id + " ";
bool needUpdate = false;
lock (EncodeString.RwLocker)
{
using (ISqlUtil sqlUtil = new SqlUtil(ConfigUtil.ConnectionStr))
{
try
{
lock (EncodeString.RwLocker)
{
sqlUtil.ExecuteNonQuery(updateSql);
_resultDataSet = sqlUtil.ExecuteSql(_querySql);
dataGridView.DataSource = _resultDataSet.Tables[0];
needUpdate = true;
}
sqlUtil.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
if (needUpdate)
{
//同步修改远程数据库的数据
pictureBox2.Visible = !SyncUtil.TryUpdateLevel(id.ToString(), newLevelId, newLevelName, out _msg);
}
}
}
}
private void button1_Click(object sender, EventArgs e)
{
var form = new QueryForm();
form.StartPosition = FormStartPosition.CenterParent;
form.ShowDialog();
}
}
}

+ 201
- 0
B3ButcherWeightClient/Main.resx View File

@ -0,0 +1,201 @@
<?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.Runtime.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:import namespace="http://www.w3.org/XML/1998/namespace" />
<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" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</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" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Sequence.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="JdColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="批号.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="DataTime.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="LevelID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="subColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Weight.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
R0lGODlhIAAdALMPAP///xgYGBAQCBgYACEhACkpAFJSAGNjAHNzAJSUAK2tAL29AM7OAO/vAP//AAAA
ACH/C05FVFNDQVBFMi4wAwHoAwAh/lbR3cq+sOaxvjog08nOtNeisuGw5rG+tcQgR0lGIE1vdmllIEdl
YXIgNC4wIMn6s8kNCkdhbWFuaSCz9sa3IChodHRwOi8vd3d3LmdhbWFuaS5jb20pLgAh+QQBZAABACwA
AAAAIAAdAAMErTDISal4T9TNu8SYJ3aP4TjXqErXeWbr+CCuUzyx19YOnm87XsP3m2BODYPCFSp+Gi/Q
aUH8PQpI0IOpsW6ZUq63BiKQq7Iv+LHgwVaPhPvIQ6BJalfiMeBFVQ8HfkNyfgZ3FXR+eW5dHIp+WH5Z
HpA8gpN/QA8MmZ4uQ49mn6QEaJaXD6OeTR+Mc1efrag1Q2GsGheFrBg0nwo4tKSyt8PGIVrJysvMPs3P
zwERACH5BAUyAAEALAAAAAAgAB0AAwTCMMhJqXhP1M27xJgndlhRhGMaXARhZuqYtS0acyxd3/hT0KYd
j1L6CQZB2/BBAzELg8fww6yBWicNr+Q6XbuwG8blcuqUMh/W+xjosrG2jgD66S6qsd0VrQLpUjICa01I
hIBpWEAnh1hhHGNkinR7h4GQT3Mtg5qOlxZ+kqJdk0IVXItvdkGkaJGsd6hzP15Eoaw/Zm9nl7KpbFW4
XXAXg7BvIAK4qz9RAb6kZCa0nUBOe8eN1WQhTt7f4OGB4uTkAREAIfkEBRQAAQAsAAAAACAAHQADBK0w
yEmpeE/UzbvEmCd2j+E416hK13lm6/ggrlM8sdfWDp5vO17D95tgTg2DwhUqfhov0GlB/D0KSNCDqbFu
mVKutwYikKuyL/ix4MFWj4T7yEOgSWpX4jHgRVUPB35Dcn4GdxV0fnluXRyKflh+WR6QPIKTf0APDJme
LkOPZp+kBGiWlw+jnk0fjHNXn62oNUNhrBoXhawYNJ8KOLSksrfDxiFaycrLzD7Nz88BEQAh+QQFHgAB
ACwAAAAAIAAdAAMEwjDISal4T9TNu8SYJ3ZYUYRjGlwEYWbqmLUtGnMsXd/4U9CmHY9S+gkGQdvwQQMx
C4PH8MOsgVonDa/kOl27sBvG5XLqlDIf1vsY6LKxto4A+ukuqrHdFa0C6VIyAmtNSISAaVhAJ4dYYRxj
ZIp0e4eBkE9zLYOajpcWfpKiXZNCFVyLb3ZBpGiRrHeocz9eRKGsP2ZvZ5eyqWxVuF1wF4OwbyACuKs/
UQG+pGQmtJ1ATnvHjdVkIU7e3+DhgeLk5AERACH+71RoaXMgR0lGIGZpbGUgd2FzIGFzc2VtYmxlZCB3
aXRoIEdJRiBDb25zdHJ1Y3Rpb24gU2V0IGZyb206DQoNCkFsY2hlbXkgTWluZHdvcmtzIEluYy4NClAu
Ty4gQm94IDUwMA0KQmVldG9uLCBPbnRhcmlvDQpMMEcgMUEwDQpDQU5BREEuDQoNClRoaXMgY29tbWVu
dCBibG9jayB3aWxsIG5vdCBhcHBlYXIgaW4gZmlsZXMgY3JlYXRlZCB3aXRoIGEgcmVnaXN0ZXJlZCB2
ZXJzaW9uIG9mIEdJRiBDb25zdHJ1Y3Rpb24gU2V0ADs=
</value>
</data>
<data name="pictureBox2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
R0lGODlhIAAdALMPAP///xgYGBAQCBgYACEhACkpAFJSAGNjAHNzAJSUAK2tAL29AM7OAO/vAP//AAAA
ACH/C05FVFNDQVBFMi4wAwHoAwAh/lbR3cq+sOaxvjog08nOtNeisuGw5rG+tcQgR0lGIE1vdmllIEdl
YXIgNC4wIMn6s8kNCkdhbWFuaSCz9sa3IChodHRwOi8vd3d3LmdhbWFuaS5jb20pLgAh+QQBZAABACwA
AAAAIAAdAAMErTDISal4T9TNu8SYJ3aP4TjXqErXeWbr+CCuUzyx19YOnm87XsP3m2BODYPCFSp+Gi/Q
aUH8PQpI0IOpsW6ZUq63BiKQq7Iv+LHgwVaPhPvIQ6BJalfiMeBFVQ8HfkNyfgZ3FXR+eW5dHIp+WH5Z
HpA8gpN/QA8MmZ4uQ49mn6QEaJaXD6OeTR+Mc1efrag1Q2GsGheFrBg0nwo4tKSyt8PGIVrJysvMPs3P
zwERACH5BAUyAAEALAAAAAAgAB0AAwTCMMhJqXhP1M27xJgndlhRhGMaXARhZuqYtS0acyxd3/hT0KYd
j1L6CQZB2/BBAzELg8fww6yBWicNr+Q6XbuwG8blcuqUMh/W+xjosrG2jgD66S6qsd0VrQLpUjICa01I
hIBpWEAnh1hhHGNkinR7h4GQT3Mtg5qOlxZ+kqJdk0IVXItvdkGkaJGsd6hzP15Eoaw/Zm9nl7KpbFW4
XXAXg7BvIAK4qz9RAb6kZCa0nUBOe8eN1WQhTt7f4OGB4uTkAREAIfkEBRQAAQAsAAAAACAAHQADBK0w
yEmpeE/UzbvEmCd2j+E416hK13lm6/ggrlM8sdfWDp5vO17D95tgTg2DwhUqfhov0GlB/D0KSNCDqbFu
mVKutwYikKuyL/ix4MFWj4T7yEOgSWpX4jHgRVUPB35Dcn4GdxV0fnluXRyKflh+WR6QPIKTf0APDJme
LkOPZp+kBGiWlw+jnk0fjHNXn62oNUNhrBoXhawYNJ8KOLSksrfDxiFaycrLzD7Nz88BEQAh+QQFHgAB
ACwAAAAAIAAdAAMEwjDISal4T9TNu8SYJ3ZYUYRjGlwEYWbqmLUtGnMsXd/4U9CmHY9S+gkGQdvwQQMx
C4PH8MOsgVonDa/kOl27sBvG5XLqlDIf1vsY6LKxto4A+ukuqrHdFa0C6VIyAmtNSISAaVhAJ4dYYRxj
ZIp0e4eBkE9zLYOajpcWfpKiXZNCFVyLb3ZBpGiRrHeocz9eRKGsP2ZvZ5eyqWxVuF1wF4OwbyACuKs/
UQG+pGQmtJ1ATnvHjdVkIU7e3+DhgeLk5AERACH+71RoaXMgR0lGIGZpbGUgd2FzIGFzc2VtYmxlZCB3
aXRoIEdJRiBDb25zdHJ1Y3Rpb24gU2V0IGZyb206DQoNCkFsY2hlbXkgTWluZHdvcmtzIEluYy4NClAu
Ty4gQm94IDUwMA0KQmVldG9uLCBPbnRhcmlvDQpMMEcgMUEwDQpDQU5BREEuDQoNClRoaXMgY29tbWVu
dCBibG9jayB3aWxsIG5vdCBhcHBlYXIgaW4gZmlsZXMgY3JlYXRlZCB3aXRoIGEgcmVnaXN0ZXJlZCB2
ZXJzaW9uIG9mIEdJRiBDb25zdHJ1Y3Rpb24gU2V0ADs=
</value>
</data>
<metadata name="_serialPort.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>32</value>
</metadata>
</root>

BIN
B3ButcherWeightClient/Microsoft.Office.Interop.Excel.dll View File


+ 18
- 0
B3ButcherWeightClient/Program.cs View File

@ -0,0 +1,18 @@
using System;
using System.Windows.Forms;
using Forks.EnterpriseServices.BusinessInterfaces;
namespace B3ButcherWeightClient {
static class Program {
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
BIFactory.Init(new DmoTransactionPlugin());
Application.Run(new Login());
}
}
}

+ 36
- 0
B3ButcherWeightClient/Properties/AssemblyInfo.cs View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("B3ButcherWeightClient")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("B3ButcherWeightClient")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("adf74c9d-6ba0-43f6-b93b-9f54bf612f35")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 内部版本号
// 修订号
//
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]

+ 63
- 0
B3ButcherWeightClient/Properties/Resources.Designer.cs View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.18063
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace B3ButcherWeightClient.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("B3ButcherWeightClient.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;
}
}
}
}

+ 117
- 0
B3ButcherWeightClient/Properties/Resources.resx View File

@ -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>

+ 26
- 0
B3ButcherWeightClient/Properties/Settings.Designer.cs View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.18063
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace B3ButcherWeightClient.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.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;
}
}
}
}

+ 7
- 0
B3ButcherWeightClient/Properties/Settings.settings View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

+ 335
- 0
B3ButcherWeightClient/QueryForm.Designer.cs View File

@ -0,0 +1,335 @@
namespace B3ButcherWeightClient {
partial class QueryForm {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle20 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle21 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle22 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle23 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle24 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle25 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle26 = new System.Windows.Forms.DataGridViewCellStyle();
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle27 = new System.Windows.Forms.DataGridViewCellStyle();
this.textBoxEndTime = new System.Windows.Forms.TextBox();
this.textBoxBeginTime = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.IDColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.SeqColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.DateColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.PhaseColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.LivestockColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.NumberColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.WeightColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.SubWeightColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.RWeightColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.monthCalendar = new System.Windows.Forms.MonthCalendar();
this.button4 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.txtShunXuHao = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
this.SuspendLayout();
//
// textBoxEndTime
//
this.textBoxEndTime.Font = new System.Drawing.Font("宋体", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBoxEndTime.Location = new System.Drawing.Point(286, 17);
this.textBoxEndTime.MaxLength = 20;
this.textBoxEndTime.Multiline = true;
this.textBoxEndTime.Name = "textBoxEndTime";
this.textBoxEndTime.Size = new System.Drawing.Size(149, 40);
this.textBoxEndTime.TabIndex = 9;
this.textBoxEndTime.TabStop = false;
this.textBoxEndTime.DoubleClick += new System.EventHandler(this.textBoxEndTime_DoubleClick);
//
// textBoxBeginTime
//
this.textBoxBeginTime.Font = new System.Drawing.Font("宋体", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBoxBeginTime.Location = new System.Drawing.Point(76, 17);
this.textBoxBeginTime.MaxLength = 20;
this.textBoxBeginTime.Multiline = true;
this.textBoxBeginTime.Name = "textBoxBeginTime";
this.textBoxBeginTime.Size = new System.Drawing.Size(164, 40);
this.textBoxBeginTime.TabIndex = 10;
this.textBoxBeginTime.TabStop = false;
this.textBoxBeginTime.DoubleClick += new System.EventHandler(this.textBoxBeginTime_DoubleClick);
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label3.Location = new System.Drawing.Point(246, 29);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(34, 24);
this.label3.TabIndex = 7;
this.label3.Text = "->";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label2.Location = new System.Drawing.Point(12, 22);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(58, 24);
this.label2.TabIndex = 8;
this.label2.Text = "日期";
//
// button1
//
this.button1.Font = new System.Drawing.Font("宋体", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button1.Location = new System.Drawing.Point(733, 11);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(117, 58);
this.button1.TabIndex = 11;
this.button1.Text = "查询";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button3
//
this.button3.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button3.Location = new System.Drawing.Point(856, 12);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(162, 58);
this.button3.TabIndex = 11;
this.button3.Text = "级别汇总查询";
this.button3.UseVisualStyleBackColor = true;
this.button3.Visible = false;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToDeleteRows = false;
this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.IDColumn,
this.SeqColumn,
this.DateColumn,
this.PhaseColumn,
this.LivestockColumn,
this.NumberColumn,
this.WeightColumn,
this.SubWeightColumn,
this.RWeightColumn});
this.dataGridView1.Location = new System.Drawing.Point(1, 77);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.ReadOnly = true;
this.dataGridView1.RowTemplate.Height = 23;
this.dataGridView1.Size = new System.Drawing.Size(1140, 733);
this.dataGridView1.TabIndex = 12;
//
// IDColumn
//
this.IDColumn.DataPropertyName = "ID";
dataGridViewCellStyle19.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.IDColumn.DefaultCellStyle = dataGridViewCellStyle19;
this.IDColumn.FillWeight = 0.8370507F;
this.IDColumn.HeaderText = "ID";
this.IDColumn.Name = "IDColumn";
this.IDColumn.ReadOnly = true;
//
// SeqColumn
//
this.SeqColumn.DataPropertyName = "Sequence";
dataGridViewCellStyle20.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.SeqColumn.DefaultCellStyle = dataGridViewCellStyle20;
this.SeqColumn.FillWeight = 0.8370507F;
this.SeqColumn.HeaderText = "顺序号";
this.SeqColumn.Name = "SeqColumn";
this.SeqColumn.ReadOnly = true;
//
// DateColumn
//
this.DateColumn.DataPropertyName = "DateTime";
dataGridViewCellStyle21.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.DateColumn.DefaultCellStyle = dataGridViewCellStyle21;
this.DateColumn.FillWeight = 1.8F;
this.DateColumn.HeaderText = "时间";
this.DateColumn.Name = "DateColumn";
this.DateColumn.ReadOnly = true;
//
// PhaseColumn
//
this.PhaseColumn.DataPropertyName = "PhaseCode";
dataGridViewCellStyle22.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.PhaseColumn.DefaultCellStyle = dataGridViewCellStyle22;
this.PhaseColumn.FillWeight = 1.065272F;
this.PhaseColumn.HeaderText = "阶段号";
this.PhaseColumn.Name = "PhaseColumn";
this.PhaseColumn.ReadOnly = true;
//
// LivestockColumn
//
this.LivestockColumn.DataPropertyName = "Livestock_Name";
dataGridViewCellStyle23.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.LivestockColumn.DefaultCellStyle = dataGridViewCellStyle23;
this.LivestockColumn.FillWeight = 1.065272F;
this.LivestockColumn.HeaderText = "级别";
this.LivestockColumn.Name = "LivestockColumn";
this.LivestockColumn.ReadOnly = true;
//
// NumberColumn
//
this.NumberColumn.DataPropertyName = "Number";
dataGridViewCellStyle24.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle24.Format = "0";
this.NumberColumn.DefaultCellStyle = dataGridViewCellStyle24;
this.NumberColumn.FillWeight = 1.065272F;
this.NumberColumn.HeaderText = "头数";
this.NumberColumn.Name = "NumberColumn";
this.NumberColumn.ReadOnly = true;
//
// WeightColumn
//
this.WeightColumn.DataPropertyName = "AllWeight";
dataGridViewCellStyle25.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle25.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle25.Format = "0.00";
this.WeightColumn.DefaultCellStyle = dataGridViewCellStyle25;
this.WeightColumn.FillWeight = 1.065272F;
this.WeightColumn.HeaderText = "重量";
this.WeightColumn.Name = "WeightColumn";
this.WeightColumn.ReadOnly = true;
//
// SubWeightColumn
//
this.SubWeightColumn.DataPropertyName = "SubWeight";
dataGridViewCellStyle26.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle26.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle26.Format = "0.00";
this.SubWeightColumn.DefaultCellStyle = dataGridViewCellStyle26;
this.SubWeightColumn.FillWeight = 1.065272F;
this.SubWeightColumn.HeaderText = "扣重";
this.SubWeightColumn.Name = "SubWeightColumn";
this.SubWeightColumn.ReadOnly = true;
//
// RWeightColumn
//
this.RWeightColumn.DataPropertyName = "Weight";
dataGridViewCellStyle27.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
dataGridViewCellStyle27.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
dataGridViewCellStyle27.Format = "0.00";
this.RWeightColumn.DefaultCellStyle = dataGridViewCellStyle27;
this.RWeightColumn.FillWeight = 1.065272F;
this.RWeightColumn.HeaderText = "净重";
this.RWeightColumn.Name = "RWeightColumn";
this.RWeightColumn.ReadOnly = true;
//
// monthCalendar
//
this.monthCalendar.Location = new System.Drawing.Point(167, 62);
this.monthCalendar.Name = "monthCalendar";
this.monthCalendar.TabIndex = 13;
this.monthCalendar.DateSelected += new System.Windows.Forms.DateRangeEventHandler(this.monthCalendar_DateSelected);
//
// button4
//
this.button4.Font = new System.Drawing.Font("宋体", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.button4.Location = new System.Drawing.Point(1024, 12);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(117, 58);
this.button4.TabIndex = 11;
this.button4.Text = "导出";
this.button4.UseVisualStyleBackColor = true;
this.button4.Visible = false;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(441, 22);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(82, 24);
this.label1.TabIndex = 8;
this.label1.Text = "顺序号";
//
// txtShunXuHao
//
this.txtShunXuHao.Font = new System.Drawing.Font("宋体", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.txtShunXuHao.Location = new System.Drawing.Point(520, 17);
this.txtShunXuHao.MaxLength = 20;
this.txtShunXuHao.Multiline = true;
this.txtShunXuHao.Name = "txtShunXuHao";
this.txtShunXuHao.Size = new System.Drawing.Size(149, 40);
this.txtShunXuHao.TabIndex = 9;
this.txtShunXuHao.TabStop = false;
this.txtShunXuHao.DoubleClick += new System.EventHandler(this.textBoxEndTime_DoubleClick);
//
// QueryForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1156, 812);
this.Controls.Add(this.monthCalendar);
this.Controls.Add(this.dataGridView1);
this.Controls.Add(this.button3);
this.Controls.Add(this.button4);
this.Controls.Add(this.button1);
this.Controls.Add(this.txtShunXuHao);
this.Controls.Add(this.textBoxEndTime);
this.Controls.Add(this.textBoxBeginTime);
this.Controls.Add(this.label3);
this.Controls.Add(this.label1);
this.Controls.Add(this.label2);
this.Name = "QueryForm";
this.Text = "查询";
this.Load += new System.EventHandler(this.QueryForm_Load);
this.SizeChanged += new System.EventHandler(this.QueryForm_SizeChanged);
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBoxEndTime;
private System.Windows.Forms.TextBox textBoxBeginTime;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.DataGridView dataGridView1;
private System.Windows.Forms.MonthCalendar monthCalendar;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.DataGridViewTextBoxColumn IDColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn SeqColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn DateColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn PhaseColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn LivestockColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn NumberColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn WeightColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn SubWeightColumn;
private System.Windows.Forms.DataGridViewTextBoxColumn RWeightColumn;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtShunXuHao;
}
}

+ 217
- 0
B3ButcherWeightClient/QueryForm.cs View File

@ -0,0 +1,217 @@
using System;
using System.Data;
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using Forks.Utils.Data;
using Microsoft.Office.Interop.Excel;
using Application = Microsoft.Office.Interop.Excel.Application;
namespace B3ButcherWeightClient {
public partial class QueryForm : Form {
private int textBoxNum;
private DataSet mResultDataSet = new DataSet();
public QueryForm() {
InitializeComponent();
}
private AutoSizeFormClass asc = new AutoSizeFormClass();
private void QueryForm_Load(object sender, EventArgs e) {
monthCalendar.Visible = false;
monthCalendar.LostFocus += (s, e1) => { this.monthCalendar.Visible = false; };
textBoxBeginTime.Text = DateTime.Today.ToString("yyyy-MM-dd") ;
textBoxEndTime.Text = DateTime.Today.ToString("yyyy-MM-dd") ;
asc.ControllInitializeSize(this);
}
private void textBoxBeginTime_DoubleClick(object sender, EventArgs e) {
textBoxNum = 1;
monthCalendar.Visible = true;
monthCalendar.Focus();
}
private void textBoxEndTime_DoubleClick(object sender, EventArgs e) {
textBoxNum = 2;
monthCalendar.Visible = true;
monthCalendar.Focus();
}
private void monthCalendar_DateSelected(object sender, DateRangeEventArgs e) {
if (textBoxNum == 1) {
textBoxBeginTime.Text = this.monthCalendar.SelectionStart.ToString("yyyy-MM-dd",
DateTimeFormatInfo.InvariantInfo);
}
if (textBoxNum == 2) {
string str = this.monthCalendar.SelectionStart.ToString("yyyy-MM-dd", DateTimeFormatInfo.InvariantInfo);
textBoxEndTime.Text = str;
}
monthCalendar.Visible = false;
}
private void QueryForm_SizeChanged(object sender, EventArgs e) {
asc.controlAutoSize(this);
}
private void button1_Click(object sender, EventArgs e)
{
NumberColumn.Visible = false;
IDColumn.Visible = true;
SeqColumn.Visible = true;
DateColumn.Visible = true;
var querySql =
"select [ID],[Sequence],[PhaseCode],[DateTime],[Livestock_Name],[Weight],[SubWeight],[Weight]+ISNULL([SubWeight],0) as [AllWeight] from [WeightTable] ";
DoSelect(querySql, "", " order by [DateTime]");
}
//汇总查询
private void button2_Click(object sender, EventArgs e) {
//阶段号、级别、头数、重量、扣重、净重
NumberColumn.Visible = true;
IDColumn.Visible = false;
SeqColumn.Visible = false;
DateColumn.Visible = false;
string querySql =
"select [PhaseCode],[Livestock_Name],SUM(1) AS [Number],SUM([Weight]) AS [Weight],SUM([SubWeight]) AS [SubWeight],SUM([Weight]+ISNULL([SubWeight],0)) as [AllWeight] from [WeightTable] ";
DoSelect(querySql, " group by [PhaseCode],[Livestock_Name]", "order by [PhaseCode]");
}
private void button3_Click(object sender, EventArgs e) {
//级别、头数、重量、扣重、净重
NumberColumn.Visible = true;
IDColumn.Visible = false;
SeqColumn.Visible = false;
DateColumn.Visible = false;
string querySql =
"select [Livestock_Name],SUM(1) AS [Number],SUM([Weight]) AS [Weight],SUM([SubWeight]) AS [SubWeight],SUM([Weight]+ISNULL([SubWeight],0)) as [AllWeight] from [WeightTable] ";
DoSelect(querySql, " group by [Livestock_Name]", "order by [Livestock_Name]");
}
private void DoSelect(string querySql, string groupBy,string orderBy) {
var sql = new StringBuilder();
sql.Append(querySql);
var isAddBegin = !string.IsNullOrEmpty(this.textBoxBeginTime.Text);
var isAddEnd = !string.IsNullOrEmpty(this.textBoxEndTime.Text);
var condition = new StringBuilder();
//if(isAddBegin||isAddEnd||isAddLevel)
sql.Append("where 1=1 ");
if (isAddBegin)
condition.Append(string.Format("and [DateTime] >= '{0}' ", this.textBoxBeginTime.Text));
else {
condition.Append(string.Format("and [DateTime] >= '{0}' ", DateTime.Today.AddDays(-1).ToShortDateString()));
}
if (!string.IsNullOrWhiteSpace(txtShunXuHao.Text))
{
condition.Append(string.Format("and [Sequence] = '{0}' ", txtShunXuHao.Text));
}
if (isAddEnd)
condition.Append(string.Format("and [DateTime] <= '{0} 23:59:59' ", this.textBoxEndTime.Text));
condition.Append(groupBy);
condition.Append(orderBy);
if (condition.Length > 0)
sql.Append(condition.ToString());
using (ISqlUtil sqlUtil = new SqlUtil(ConfigUtil.ConnectionStr)) {
try {
lock (EncodeString.RwLocker) {
this.mResultDataSet = sqlUtil.ExecuteSql(sql.ToString());
dataGridView1.DataSource = mResultDataSet.Tables[0];
}
sqlUtil.Close();
} catch (Exception ex) {
MessageBox.Show(ex.Message);
}
}
}
private void button4_Click(object sender, EventArgs e) {
if (OutToExcelFromDataGridView("称重数据", dataGridView1, true)) {
MessageBox.Show("导出数据成功!");
}
}
public bool OutToExcelFromDataGridView(string title, DataGridView dgv, bool isShowExcel) {
var titleColumnSpan = 0; //标题的跨列数
var fileName = ""; //保存的excel文件名
int columnIndex; //列索引
if (dgv.Rows.Count == 0)
return false;
/*保存对话框*/
var sfd = new SaveFileDialog();
sfd.Filter = "导出Excel(*.xlsx)|*.xlsx";
sfd.FileName = title + DateTime.Now.ToString("yyyyMMddhhmmss");
if (sfd.ShowDialog() == DialogResult.OK) {
label2.Text = "数据导出中.....";
fileName = sfd.FileName;
/*建立Excel对象*/
var excel = new Application();
excel.Application.Workbooks.Add(true);
excel.Visible = isShowExcel;
/*分析标题的跨列数*/
foreach (DataGridViewColumn column in dgv.Columns) {
if (column.Visible == true)
titleColumnSpan++;
}
/*合并标题单元格*/
Worksheet worksheet = (Worksheet)excel.ActiveSheet;
worksheet.get_Range(worksheet.Cells[1, 1] as Range, worksheet.Cells[1, titleColumnSpan] as Range).Merge();
/*生成标题*/
excel.Cells[1, 1] = title;
SetAlign(excel.Cells[1, 1], XlHAlign.xlHAlignCenter);
//生成字段名称
columnIndex = 1;
for (int i = 0; i < dgv.ColumnCount; i++) {
if (dgv.Columns[i].Visible == true) {
excel.Cells[2, columnIndex] = dgv.Columns[i].HeaderText;
switch (dgv.Columns[i].HeaderText) {
case "时间":
((Range)excel.Cells[2, columnIndex]).ColumnWidth = 20;
break;
case "级别":
((Range)excel.Cells[2, columnIndex]).ColumnWidth = 15;
break;
}
SetAlign(excel.Cells[2, columnIndex], XlHAlign.xlHAlignCenter);
columnIndex++;
}
}
//填充数据
for (int i = 0; i < dgv.RowCount; i++) {
columnIndex = 1;
for (int j = 0; j < dgv.ColumnCount; j++) {
if (dgv.Columns[j].Visible == true) {
if (dgv[j, i].ValueType == typeof(string)) {
excel.Cells[i + 3, columnIndex] = "'" + dgv[j, i].Value;
} else {
excel.Cells[i + 3, columnIndex] = dgv[j, i].Value;
}
SetAlign(excel.Cells[i + 3, columnIndex], XlHAlign.xlHAlignLeft);
columnIndex++;
}
}
}
worksheet.SaveAs(fileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing);
excel.Quit();
GC.Collect();
return true;
}
return false;
}
private static void SetAlign(Range range, XlHAlign a) {
range.HorizontalAlignment = a;
}
}
}

+ 174
- 0
B3ButcherWeightClient/QueryForm.resx View File

@ -0,0 +1,174 @@
<?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.Runtime.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:import namespace="http://www.w3.org/XML/1998/namespace" />
<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" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</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" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="IDColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="SeqColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="DateColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="PhaseColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="LivestockColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="NumberColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="WeightColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="SubWeightColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="RWeightColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="IDColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="SeqColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="DateColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="PhaseColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="LivestockColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="NumberColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="WeightColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="SubWeightColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="RWeightColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

BIN
B3ButcherWeightClient/Resources/loading.gif View File

Before After
Width: 32  |  Height: 32  |  Size: 1.7 KiB

BIN
B3ButcherWeightClient/Resources/warning1.gif View File

Before After
Width: 32  |  Height: 29  |  Size: 1.2 KiB

+ 586
- 0
B3ButcherWeightClient/Setting.Designer.cs View File

@ -0,0 +1,586 @@
namespace B3ButcherWeightClient {
partial class Setting {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.txtDataBits = new System.Windows.Forms.TextBox();
this.txtBaudRate = new System.Windows.Forms.TextBox();
this.txtBComName = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.typeComboBox = new System.Windows.Forms.ComboBox();
this.label13 = new System.Windows.Forms.Label();
this.textBoxPassword = new System.Windows.Forms.TextBox();
this.txtBoxDataBase = new System.Windows.Forms.TextBox();
this.txtBoxUserName = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.txtBServerName = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.button1 = new System.Windows.Forms.Button();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.button2 = new System.Windows.Forms.Button();
this.label8 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label11 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.btnClose = new System.Windows.Forms.Button();
this.btnSave = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.maxTextBox = new System.Windows.Forms.TextBox();
this.minTextBox = new System.Windows.Forms.TextBox();
this.label12 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.cbxAllowChangeLevel = new System.Windows.Forms.CheckBox();
this.subWeightLabel = new System.Windows.Forms.Label();
this.subWeightSettingTextBox = new System.Windows.Forms.TextBox(); this.label15 = new System.Windows.Forms.Label();
this.txtPerDayStartHour = new System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.SuspendLayout();
//
// txtDataBits
//
this.txtDataBits.Location = new System.Drawing.Point(77, 87);
this.txtDataBits.MaxLength = 1;
this.txtDataBits.Name = "txtDataBits";
this.txtDataBits.Size = new System.Drawing.Size(100, 21);
this.txtDataBits.TabIndex = 9;
//
// txtBaudRate
//
this.txtBaudRate.Location = new System.Drawing.Point(77, 56);
this.txtBaudRate.MaxLength = 10;
this.txtBaudRate.Name = "txtBaudRate";
this.txtBaudRate.Size = new System.Drawing.Size(100, 21);
this.txtBaudRate.TabIndex = 8;
//
// txtBComName
//
this.txtBComName.Location = new System.Drawing.Point(77, 25);
this.txtBComName.MaxLength = 10;
this.txtBComName.Name = "txtBComName";
this.txtBComName.Size = new System.Drawing.Size(100, 21);
this.txtBComName.TabIndex = 7;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(6, 90);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 12);
this.label3.TabIndex = 4;
this.label3.Text = "数据位数";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(6, 59);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(41, 12);
this.label2.TabIndex = 5;
this.label2.Text = "波特率";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(6, 28);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 12);
this.label1.TabIndex = 6;
this.label1.Text = "串口名";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.typeComboBox);
this.groupBox1.Controls.Add(this.label13);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.txtDataBits);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.txtBaudRate);
this.groupBox1.Controls.Add(this.txtBComName);
this.groupBox1.Location = new System.Drawing.Point(12, 16);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(188, 147);
this.groupBox1.TabIndex = 22;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "端口设置";
//
// typeComboBox
//
this.typeComboBox.FormattingEnabled = true;
this.typeComboBox.Location = new System.Drawing.Point(77, 123);
this.typeComboBox.Name = "typeComboBox";
this.typeComboBox.Size = new System.Drawing.Size(100, 20);
this.typeComboBox.TabIndex = 26;
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(7, 126);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(41, 12);
this.label13.TabIndex = 25;
this.label13.Text = "称类型";
//
// textBoxPassword
//
this.textBoxPassword.Location = new System.Drawing.Point(79, 126);
this.textBoxPassword.MaxLength = 16;
this.textBoxPassword.Name = "textBoxPassword";
this.textBoxPassword.PasswordChar = '*';
this.textBoxPassword.Size = new System.Drawing.Size(100, 21);
this.textBoxPassword.TabIndex = 15;
//
// txtBoxDataBase
//
this.txtBoxDataBase.Location = new System.Drawing.Point(79, 56);
this.txtBoxDataBase.MaxLength = 30;
this.txtBoxDataBase.Name = "txtBoxDataBase";
this.txtBoxDataBase.Size = new System.Drawing.Size(100, 21);
this.txtBoxDataBase.TabIndex = 12;
//
// txtBoxUserName
//
this.txtBoxUserName.Location = new System.Drawing.Point(79, 87);
this.txtBoxUserName.MaxLength = 20;
this.txtBoxUserName.Name = "txtBoxUserName";
this.txtBoxUserName.Size = new System.Drawing.Size(100, 21);
this.txtBoxUserName.TabIndex = 14;
//
// label6
//
this.label6.AutoSize = true;
this.label6.Location = new System.Drawing.Point(20, 67);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(53, 12);
this.label6.TabIndex = 16;
this.label6.Text = "数据库名";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(20, 129);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(53, 12);
this.label5.TabIndex = 13;
this.label5.Text = "密 码";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(20, 98);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(53, 12);
this.label7.TabIndex = 17;
this.label7.Text = "用 户 名";
//
// txtBServerName
//
this.txtBServerName.Location = new System.Drawing.Point(79, 25);
this.txtBServerName.MaxLength = 100;
this.txtBServerName.Name = "txtBServerName";
this.txtBServerName.Size = new System.Drawing.Size(100, 21);
this.txtBServerName.TabIndex = 11;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(20, 30);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(53, 12);
this.label4.TabIndex = 10;
this.label4.Text = "服务器名";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.button1);
this.groupBox2.Controls.Add(this.label4);
this.groupBox2.Controls.Add(this.txtBServerName);
this.groupBox2.Controls.Add(this.label7);
this.groupBox2.Controls.Add(this.label5);
this.groupBox2.Controls.Add(this.label6);
this.groupBox2.Controls.Add(this.txtBoxUserName);
this.groupBox2.Controls.Add(this.txtBoxDataBase);
this.groupBox2.Controls.Add(this.textBoxPassword);
this.groupBox2.Location = new System.Drawing.Point(217, 16);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(188, 190);
this.groupBox2.TabIndex = 23;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "本地数据库设置";
//
// button1
//
this.button1.Location = new System.Drawing.Point(56, 156);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 25;
this.button1.Text = "升级";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// groupBox3
//
this.groupBox3.Controls.Add(this.button2);
this.groupBox3.Controls.Add(this.label8);
this.groupBox3.Controls.Add(this.textBox1);
this.groupBox3.Controls.Add(this.label9);
this.groupBox3.Controls.Add(this.label10);
this.groupBox3.Controls.Add(this.label11);
this.groupBox3.Controls.Add(this.textBox2);
this.groupBox3.Controls.Add(this.textBox3);
this.groupBox3.Controls.Add(this.textBox4);
this.groupBox3.Location = new System.Drawing.Point(217, 226);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(188, 191);
this.groupBox3.TabIndex = 24;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "远程数据库设置";
//
// button2
//
this.button2.Location = new System.Drawing.Point(56, 162);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 25;
this.button2.Text = "升级";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(20, 33);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(53, 12);
this.label8.TabIndex = 18;
this.label8.Text = "服务器名";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(79, 28);
this.textBox1.MaxLength = 100;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 21);
this.textBox1.TabIndex = 19;
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(20, 101);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(53, 12);
this.label9.TabIndex = 25;
this.label9.Text = "用 户 名";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(20, 132);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(53, 12);
this.label10.TabIndex = 21;
this.label10.Text = "密 码";
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(20, 70);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(53, 12);
this.label11.TabIndex = 24;
this.label11.Text = "数据库名";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(79, 90);
this.textBox2.MaxLength = 20;
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(100, 21);
this.textBox2.TabIndex = 22;
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(79, 59);
this.textBox3.MaxLength = 20;
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(100, 21);
this.textBox3.TabIndex = 20;
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(79, 129);
this.textBox4.MaxLength = 16;
this.textBox4.Name = "textBox4";
this.textBox4.PasswordChar = '*';
this.textBox4.Size = new System.Drawing.Size(100, 21);
this.textBox4.TabIndex = 23;
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(229, 431);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(62, 23);
this.btnClose.TabIndex = 26;
this.btnClose.Text = "关 闭";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnSave
//
this.btnSave.Location = new System.Drawing.Point(134, 431);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(62, 23);
this.btnSave.TabIndex = 25;
this.btnSave.Text = "保 存";
this.btnSave.UseVisualStyleBackColor = true;
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(13, 226);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 23);
this.button3.TabIndex = 27;
this.button3.Text = "级别设置";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// groupBox4
//
this.groupBox4.Controls.Add(this.maxTextBox);
this.groupBox4.Controls.Add(this.minTextBox);
this.groupBox4.Controls.Add(this.label12);
this.groupBox4.Controls.Add(this.label14);
this.groupBox4.Controls.Add(this.radioButton2);
this.groupBox4.Controls.Add(this.radioButton1);
this.groupBox4.Location = new System.Drawing.Point(13, 254);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(187, 122);
this.groupBox4.TabIndex = 28;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "发送方式";
//
// maxTextBox
//
this.maxTextBox.Location = new System.Drawing.Point(69, 50);
this.maxTextBox.Name = "maxTextBox";
this.maxTextBox.Size = new System.Drawing.Size(100, 21);
this.maxTextBox.TabIndex = 3;
//
// minTextBox
//
this.minTextBox.Location = new System.Drawing.Point(69, 19);
this.minTextBox.Name = "minTextBox";
this.minTextBox.Size = new System.Drawing.Size(100, 21);
this.minTextBox.TabIndex = 3;
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(6, 53);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(53, 12);
this.label12.TabIndex = 2;
this.label12.Text = "最大重量";
//
// label14
//
this.label14.AutoSize = true;
this.label14.Location = new System.Drawing.Point(6, 22);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(53, 12);
this.label14.TabIndex = 2;
this.label14.Text = "最小重量";
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(98, 90);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(71, 16);
this.radioButton2.TabIndex = 1;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "单次发送";
this.radioButton2.UseVisualStyleBackColor = true;
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Checked = true;
this.radioButton1.Location = new System.Drawing.Point(8, 90);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(71, 16);
this.radioButton1.TabIndex = 0;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "连续发送";
this.radioButton1.UseVisualStyleBackColor = true;
//
// cbxAllowChangeLevel
//
this.cbxAllowChangeLevel.AutoSize = true;
this.cbxAllowChangeLevel.Location = new System.Drawing.Point(12, 169);
this.cbxAllowChangeLevel.Name = "cbxAllowChangeLevel";
this.cbxAllowChangeLevel.Size = new System.Drawing.Size(96, 16);
this.cbxAllowChangeLevel.TabIndex = 29;
this.cbxAllowChangeLevel.Text = "允许修改级别";
this.cbxAllowChangeLevel.UseVisualStyleBackColor = true;
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(12, 193);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(77, 12);
this.label15.TabIndex = 30;
this.label15.Text = "每天开始时点";
//
// txtPerDayStartHour
//
this.txtPerDayStartHour.Location = new System.Drawing.Point(89, 190);
this.txtPerDayStartHour.MaxLength = 2;
this.txtPerDayStartHour.Name = "txtPerDayStartHour";
this.txtPerDayStartHour.Size = new System.Drawing.Size(41, 21);
this.txtPerDayStartHour.TabIndex = 31;
//
// subWeightLabel
//
this.subWeightLabel.AutoSize = true;
this.subWeightLabel.Location = new System.Drawing.Point(21, 398);
this.subWeightLabel.Name = "subWeightLabel";
this.subWeightLabel.Size = new System.Drawing.Size(29, 12);
this.subWeightLabel.TabIndex = 30;
this.subWeightLabel.Text = "扣重";
//
// subWeightSettingTextBox
//
this.subWeightSettingTextBox.Location = new System.Drawing.Point(82, 395);
this.subWeightSettingTextBox.Name = "subWeightSettingTextBox";
this.subWeightSettingTextBox.Size = new System.Drawing.Size(100, 21);
this.subWeightSettingTextBox.TabIndex = 31;
//
// Setting
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(424, 466);
this.Controls.Add(this.txtPerDayStartHour);
this.Controls.Add(this.label15);
this.Controls.Add(this.subWeightSettingTextBox);
this.Controls.Add(this.subWeightLabel);
this.Controls.Add(this.cbxAllowChangeLevel);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.button3);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnSave);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Name = "Setting";
this.Text = "设置";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.groupBox3.ResumeLayout(false);
this.groupBox3.PerformLayout();
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox txtDataBits;
private System.Windows.Forms.TextBox txtBaudRate;
private System.Windows.Forms.TextBox txtBComName;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox textBoxPassword;
private System.Windows.Forms.TextBox txtBoxDataBase;
private System.Windows.Forms.TextBox txtBoxUserName;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.TextBox txtBServerName;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnSave;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.TextBox minTextBox;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.ComboBox typeComboBox;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.TextBox maxTextBox;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.CheckBox cbxAllowChangeLevel;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.TextBox txtPerDayStartHour;
private System.Windows.Forms.Label subWeightLabel;
private System.Windows.Forms.TextBox subWeightSettingTextBox;
}
}

+ 150
- 0
B3ButcherWeightClient/Setting.cs View File

@ -0,0 +1,150 @@
using System;
using System.IO;
using System.Windows.Forms;
using BO;
using Forks.Utils.IO;
namespace B3ButcherWeightClient {
public partial class Setting : Form {
public Setting() {
InitializeComponent();
typeComboBox.Items.Add("");
typeComboBox.Items.Add("IND560");
typeComboBox.Items.Add("Xk3124");
typeComboBox.Items.Add("XK3130");
typeComboBox.Items.Add("Xk3190A9");
SetConfigControl();
}
// 取得设置的值
private void SetConfigControl() {
using (var reader = FS.OpenReader(ConfigUtil.ConfigFilePath, true)) {
var nutFile = NutFile.Parse(reader);
var ctype = nutFile.AsString(ConfigItem.CType, "");
typeComboBox.SelectedItem = ctype;
txtBComName.Text = nutFile.AsString(ConfigItem.ComName, "COM1");
txtBaudRate.Text = nutFile.AsString(ConfigItem.BaundRate, "9600");
txtDataBits.Text = nutFile.AsString(ConfigItem.DataBits, "8");
txtBServerName.Text = nutFile.AsString(ConfigItem.Server, "");
txtBoxDataBase.Text = nutFile.AsString(ConfigItem.Database, "");
txtBoxUserName.Text = nutFile.AsString(ConfigItem.UserName, "");
textBoxPassword.Text = EncodeString.Encode(nutFile.AsString(ConfigItem.Password, ""));
cbxAllowChangeLevel.Checked = nutFile.AsBool(ConfigItem.AllowChangeLevel, false);
txtPerDayStartHour.Text = nutFile.AsInt32(ConfigItem.PerDayStartHour, 0).ToString();
textBox1.Text = nutFile.AsString(ConfigItem.RemoteServer, "");
textBox3.Text = nutFile.AsString(ConfigItem.RemoteDatabase, "");
textBox2.Text = nutFile.AsString(ConfigItem.RemoteUserName, "");
textBox4.Text = EncodeString.Encode(nutFile.AsString(ConfigItem.RemotePassword, ""));
minTextBox.Text = nutFile.AsString(ConfigItem.MinWeight, "25");
maxTextBox.Text = nutFile.AsString(ConfigItem.MaxWeight, "300");
var readType = nutFile.AsString(ConfigItem.ReadType, "");
if (readType == "0") {
radioButton1.Checked = true;
} else if (readType == "1") {
radioButton2.Checked = true;
}
subWeightSettingTextBox.Text = nutFile.AsString(ConfigItem.SubWeight, "0");
}
}
private void button1_Click(object sender, EventArgs e) {
var database = txtBoxDataBase.Text.Trim();
string conStr;
if (!TryGetConnectStr(database, out conStr))
return;
try {
conStr = UpdateDb.CreateTables(conStr, database);
UpdateDb.UpdateTables(conStr);
MessageBox.Show(@"升级成功!");
} catch (Exception ex) {
MessageBox.Show(string.Format("升级失败!{0}", ex.Message));
}
}
private bool TryGetConnectStr(string database, out string conStr) {
var server = txtBServerName.Text.Trim();
var user = txtBoxUserName.Text.Trim();
var password = textBoxPassword.Text.Trim();
conStr = string.Format("Server={0};Database={1};User ID={2};Password={3};", server, "master", user, password);
if (string.IsNullOrEmpty(server) || string.IsNullOrEmpty(database) || string.IsNullOrEmpty(user) || string.IsNullOrEmpty(password)) {
MessageBox.Show(@"请输入服务器名,数据库名,用户名,密码");
return false;
}
return true;
}
private void btnClose_Click(object sender, EventArgs e) {
Dispose();
}
private void button2_Click(object sender, EventArgs e) {
var database = textBox3.Text.Trim();
string conStr;
if (!TryGetConnectStrSvr(database, out conStr))
return;
try {
conStr = UpdateDb.CreateTables(conStr, database);
UpdateDb.UpdateTables(conStr);
MessageBox.Show(@"升级成功!");
} catch (Exception ex) {
MessageBox.Show(string.Format("升级失败!{0}", ex.Message));
}
}
private bool TryGetConnectStrSvr(string database, out string conStr) {
var server = textBox1.Text.Trim();
var user = textBox2.Text.Trim();
var password = textBox4.Text.Trim();
conStr = string.Format("Server={0};Database={1};User ID={2};Password={3};", server, "master", user, password);
if (string.IsNullOrEmpty(server) || string.IsNullOrEmpty(database) || string.IsNullOrEmpty(user) || string.IsNullOrEmpty(password)) {
MessageBox.Show(@"请输入服务器名,数据库名,用户名,密码");
return false;
}
return true;
}
private void btnSave_Click(object sender, EventArgs e) {
using (TextReader reader = FS.OpenReader(ConfigUtil.ConfigFilePath, true)) {
var nutFile = NutFile.Parse(reader);
nutFile.SetValue(ConfigItem.CType, (string)typeComboBox.SelectedItem);
nutFile.SetValue(ConfigItem.ComName, txtBComName.Text.Trim());
nutFile.SetValue(ConfigItem.BaundRate, txtBaudRate.Text.Trim());
nutFile.SetValue(ConfigItem.DataBits, txtDataBits.Text.Trim());
nutFile.SetValue(ConfigItem.Server, txtBServerName.Text.Trim());
nutFile.SetValue(ConfigItem.Database, txtBoxDataBase.Text.Trim());
nutFile.SetValue(ConfigItem.UserName, txtBoxUserName.Text.Trim());
nutFile.SetValue(ConfigItem.Password, EncodeString.Encode(textBoxPassword.Text.Trim()));
nutFile.SetValue(ConfigItem.AllowChangeLevel, cbxAllowChangeLevel.Checked);
nutFile.SetValue(ConfigItem.PerDayStartHour, Convert.ToInt32(txtPerDayStartHour.Text.Trim()));
nutFile.SetValue(ConfigItem.RemoteServer, textBox1.Text.Trim());
nutFile.SetValue(ConfigItem.RemoteDatabase, textBox3.Text.Trim());
nutFile.SetValue(ConfigItem.RemoteUserName, textBox2.Text.Trim());
nutFile.SetValue(ConfigItem.RemotePassword, EncodeString.Encode(textBox4.Text.Trim()));
nutFile.SetValue(ConfigItem.MinWeight, minTextBox.Text.Trim());
nutFile.SetValue(ConfigItem.MaxWeight, maxTextBox.Text.Trim());
string readType = "0";
if (radioButton2.Checked) {
readType = "1";
}
nutFile.SetValue(ConfigItem.ReadType, readType);
nutFile.SetValue(ConfigItem.SubWeight, subWeightSettingTextBox.Text.Trim());
using (TextWriter writer = FS.OpenWriter(ConfigUtil.ConfigFilePath, createDirsIfNotExist: true)) {
nutFile.Write(writer);
}
}
MessageBox.Show("设置保存成功!");
}
private void button3_Click(object sender, EventArgs e)
{
var form = new Livestock();
form.Show();
}
}
}

+ 120
- 0
B3ButcherWeightClient/Setting.resx View File

@ -0,0 +1,120 @@
<?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.Runtime.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:import namespace="http://www.w3.org/XML/1998/namespace" />
<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" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</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" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

+ 153
- 0
B3ButcherWeightClient/SyncUtil.cs View File

@ -0,0 +1,153 @@
using System;
using System.Collections;
using System.Collections.Generic;
using BO;
using System.Linq;
using Forks.EnterpriseServices.BusinessInterfaces;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.EnterpriseServices.DomainObjects2.DQuery;
using Forks.EnterpriseServices.SqlDoms;
namespace B3ButcherWeightClient {
public class SyncUtil {
static readonly List<long> IdList = new List<long>();
static readonly Dictionary<long, Tuple<DateTime, long>> SequenceList = new Dictionary<long, Tuple<DateTime, long>>();
public static bool TryUpdateServerData(out string msg) {
var success = true;
msg = "同步数据......";
var step = "";
try {
IList dmos;
step = "查询";
using (var localContext = new TransactionContext(Dmo.NewSession(ConfigUtil.ConnectionStr))) {
var dom = new DmoQuery(typeof(WeightTable));
dom.Where.Conditions.Add(DQCondition.EQ("IsExport", false));
dom.Range = SelectRange.Top(50);
dmos = localContext.Session.ExecuteList(dom);
}
if (dmos == null || dmos.Count == 0)
return true;
var ids = dmos.Cast<WeightTable>().Where(weightBo => IdList.Contains(weightBo.ID)).ToList();
foreach (var weightBo in ids) {
dmos.Remove(weightBo);
}
step = "同步";
using (var context = new TransactionContext(Dmo.NewSession(ConfigUtil.RemoteConStr))) {
foreach (WeightTable weightBo in dmos) {
if (weightBo.LastExportFail) {
var dom = new DQueryDom(new JoinAlias(typeof(WeightTable)));
dom.Columns.Add(DQSelectColumn.Field("ID"));
dom.Where.Conditions.Add(DQCondition.EQ("SourceID", weightBo.ID));
var id = context.Session.ExecuteScalar(dom);
if (id != null) {
IdList.Add(weightBo.ID);
continue;
}
}
if (SequenceList.ContainsKey(weightBo.ID)) {
var dom = new DQueryDom(new JoinAlias(typeof(WeightTable)));
dom.Columns.Add(DQSelectColumn.Field("ID"));
dom.Where.Conditions.Add(DQCondition.EQ("SourceID", weightBo.ID));
var id = context.Session.ExecuteScalar(dom);
if (id != null) {
IdList.Add(weightBo.ID);
continue;
}
} else {
SequenceList.Add(weightBo.ID, new Tuple<DateTime, long>(weightBo.DateTime, weightBo.Sequence));
}
var newBo = new WeightTable();
newBo.DateTime = weightBo.DateTime;
newBo.Livestock_ID = weightBo.Livestock_ID;
newBo.Weight = weightBo.Weight;
newBo.GoodsBatchName = weightBo.GoodsBatchName;
newBo.Remark = weightBo.Remark;
newBo.Livestock_Name = weightBo.Livestock_Name;
newBo.SubWeight = weightBo.SubWeight;
newBo.PhaseCode = weightBo.PhaseCode;
newBo.Sequence = weightBo.Sequence;
newBo.IP = weightBo.IP;
newBo.Mac = weightBo.Mac;
newBo.SourceID = weightBo.ID;
context.Session.AddNew(newBo);
}
context.Commit();
}
step = "修改状态";
foreach (WeightTable weightBo in dmos) {
IdList.Add(weightBo.ID);
if (SequenceList.ContainsKey(weightBo.ID)) {
SequenceList.Remove(weightBo.ID);
}
}
using (var localContext = new TransactionContext(Dmo.NewSession(ConfigUtil.ConnectionStr))) {
var sql = string.Format("UPDATE dbo.[WeightTable] SET IsExport =1,LastExportFail = 0 WHERE ID in ({0})", string.Join(",", IdList));
localContext.Session.ExecuteSqlNonQuery(sql);
localContext.Commit();
}
IdList.Clear();
LogUtil.WriteLog(DateTime.Now + ":服务器数据同步成功!");
} catch (Exception ex) {
var er = SequenceList.Keys.ToList();
msg = "服务器数据同步失败!" + ex.Message + "|" + step + string.Join(",", IdList) + "|" + string.Join(",", er);
LogUtil.WriteLog(DateTime.Now + ":" + msg);
if (er.Count > 0)
using (var localContext = new TransactionContext(Dmo.NewSession(ConfigUtil.ConnectionStr))) {
var sql = string.Format("UPDATE dbo.WeightTable SET LastExportFail = 1 WHERE ID in ({0})", string.Join(",", er));
localContext.Session.ExecuteSqlNonQuery(sql);
localContext.Commit();
}
success = false;
}
return success;
}
public static bool TryDeleteServerData(string id, out string msg)
{
try
{
using (var localContext = new TransactionContext(Dmo.NewSession(ConfigUtil.RemoteConStr)))
{
var sql = "delete from dbo.[WeightTable] where SourceID ='" + id +"'";
localContext.Session.ExecuteSqlNonQuery(sql);
localContext.Commit();
}
msg = "";
return true;
}
catch (Exception e)
{
msg = e.ToString();
LogUtil.WriteLog(DateTime.Now + ":" + msg);
return false;
}
}
public static bool TryUpdateLevel(string id, long newLevelId, string newLevelName,out string msg)
{
try
{
using (var localContext = new TransactionContext(Dmo.NewSession(ConfigUtil.RemoteConStr)))
{
var updateSql = "update [WeightTable] set [Livestock_ID]=" + newLevelId + ",[Livestock_Name]='" + newLevelName + "' where SourceID="+id+" ";
localContext.Session.ExecuteSqlNonQuery(updateSql);
localContext.Commit();
}
msg = "";
return true;
}
catch (Exception e)
{
msg = e.ToString();
LogUtil.WriteLog(DateTime.Now + ":" + msg);
return false;
}
}
}
}

+ 34
- 0
B3ButcherWeightClient/WinApiSendMessage.cs View File

@ -0,0 +1,34 @@
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace B3ButcherWeightClient {
public class WinApiSendMessage {
//声明 API 函数
[DllImport("User32.dll", EntryPoint = "SendMessage")]
public static extern int SendMessage(
int hWnd, // handle to destination window
int Msg, // message
int wParam, // first message parameter
int lParam // second message parameter
);
[DllImport("User32.dll", EntryPoint = "FindWindow")]
public static extern int FindWindow(string lpClassName, string lpWindowName);
[DllImport("wininet.dll")]
public extern static bool InternetGetConnectedState(out int connectionDescription, int reservedValue);
const int SND_ASYNC = 1;
const int SND_FileNAME = 0X20000;
[DllImport("winmm.dll", EntryPoint = "PlaySound")]
private static extern int PlaySound(string lpxzName, int hModul, int dwFlags);
public static int WinAPIPlaySound(string fileName) {
int isOk = PlaySound(Application.StartupPath + fileName, 1, SND_FileNAME | SND_ASYNC);
return isOk;
}
}
}

+ 3
- 0
B3ButcherWeightClient/app.config View File

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

BIN
B3ButcherWeightClient/logo.ico View File

Before After

+ 65
- 0
BO/BO.csproj View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{2EAEFC6A-1B91-4D58-A793-B25462CA9225}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BO</RootNamespace>
<AssemblyName>BO</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Forks.EnterpriseServices, Version=3.1.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Forks.EnterpriseServices.dll</HintPath>
</Reference>
<Reference Include="Forks.Utils, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7254430f49d10aae, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\tsref\Debug\Forks.Utils.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="UpdateDb.cs" />
<Compile Include="LoginUser.cs" />
<Compile Include="WeightTable.cs" />
<Compile Include="BOClassAttribute.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</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>

+ 30
- 0
BO/BOClassAttribute.cs View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using Forks.Utils;
namespace BO {
[AttributeUsage(AttributeTargets.Class)]
public sealed class BOClassAttribute : Attribute {
public bool Exclude { get; set; }
public static bool IsBo(Type t) {
var attr = ReflectionUtil.GetAttribute<BOClassAttribute>(t);
if (attr == null) {
return false;
}
return !attr.Exclude;
}
public static IEnumerable<Type> GetBoClasses() {
var asm = typeof(BOClassAttribute).Assembly;
foreach (var t in asm.GetExportedTypes()) {
if (t.IsAbstract) {
continue;
}
if (t.IsClass && IsBo(t)) {
yield return t;
}
}
}
}
}

+ 30
- 0
BO/LoginUser.cs View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Forks.EnterpriseServices;
using Forks.EnterpriseServices.DomainObjects2;
namespace BO {
[LogicName("称重数据")]
[BOClass]
[Serializable]
[MapToTable("LoginUser")]
[KeyField("ID", KeyGenType.identity)]
public class LoginUser {
[LogicName("ID")]
public long ID { get; set; }
[LogicName("用户名")]
[DbColumn(Length = 20)]
public string UserName { get; set; }
[LogicName("密码")]
[DbColumn(Length = 16)]
public byte[] PassWord { get; set; }
[LogicName("角色")]
[DbColumn(Length = 10)]
public string RoleSchema { get; set; }
}
}

+ 36
- 0
BO/Properties/AssemblyInfo.cs View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("BO")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("BO")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("e095cdb9-d868-4864-a495-714d031f9514")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 内部版本号
// 修订号
//
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

+ 99
- 0
BO/UpdateDb.cs View File

@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Forks.EnterpriseServices.BusinessInterfaces;
using Forks.EnterpriseServices.DomainObjects2;
using Forks.Utils.Data;
namespace BO {
public class UpdateDb {
public static string CreateTables(string conStr, string dbName) {
string s;
using (ISqlUtil sqlUtil = new SqlUtil(conStr)) {
var hasDb = (string)sqlUtil.ExecuteScalar("select '1' from master..sysdatabases where name='" + dbName + "'");
if (hasDb == "1") {
s = ChangeDatabase(conStr, dbName);
return s;
}
sqlUtil.ExecuteNonQuery("create database [" + dbName + "] COLLATE Chinese_PRC_CI_AS");
sqlUtil.ExecuteNonQuery("alter database [" + dbName + "] set recovery simple");
if (GetSqlServerMainVersion(sqlUtil) >= 9) {
SetSql2000Comptable(sqlUtil, dbName);
}
s = ChangeDatabase(conStr, dbName);
}
try {
using (ISqlUtil sqlUtil = new SqlUtil(s)) {
Dmo.CreateTables(sqlUtil, GetTypes());
return s;
}
} catch {
SqlConnection.ClearAllPools();
using (var sqlUtil = new SqlUtil(conStr)) {
sqlUtil.ExecuteNonQuery("drop database [" + dbName + "]");
}
throw;
}
}
static int GetSqlServerMainVersion(ISqlUtil sqlUtil) {
string s = (string)sqlUtil.ExecuteScalar("SELECT SERVERPROPERTY('ProductVersion')");
return int.Parse(s.Split(new[] { '.' }, 2)[0]);
}
static void SetSql2000Comptable(ISqlUtil sqlUtil, string dbName) {
using (var cmd = sqlUtil.Connection.CreateCommand()) {
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_dbcmptlevel";
cmd.Parameters.Add(CreateParameter(cmd, "@dbname", DbType.String, dbName));
cmd.Parameters.Add(CreateParameter(cmd, "@new_cmptlevel", DbType.Int32, 80));
cmd.ExecuteNonQuery();
}
}
static IDbDataParameter CreateParameter(IDbCommand cmd, string name, DbType type, object value) {
var result = cmd.CreateParameter();
result.DbType = type;
result.ParameterName = name;
result.Value = value;
return result;
}
static string ChangeDatabase(string conString, string db) {
var con = SqlConnectionString.Parse(conString);
con.Database = db;
return con.ToString();
}
public static void UpdateTables(string conStr) {
using (var context = new TransactionContext(Dmo.NewSession(conStr))) {
AddDefaultUser(context);
}
using (ISqlUtil sqlUtil = new SqlUtil(conStr)) {
Dmo.UpdateTables(sqlUtil, GetTypes());
}
}
private static void AddDefaultUser(TransactionContext context) {
const string sql = "select * from LoginUser";
var obj = context.Session.ExecuteSqlScalar(sql);
if (obj != null)
return;
//-- 创建默认登陆用户
const string insert = "insert dbo.LoginUser(UserName, PassWord, RoleSchema) values('{0}', cast('' as binary), '{1}')";
context.Session.ExecuteSqlNonQuery(string.Format(insert, "system", "system"));
context.Session.ExecuteSqlNonQuery(string.Format(insert, "user1", "operator"));
context.Session.ExecuteSqlNonQuery(string.Format(insert, "set", "operator"));
context.Commit();
}
private static IEnumerable<Type> GetTypes() {
return BOClassAttribute.GetBoClasses();
}
}
}

+ 60
- 0
BO/WeightTable.cs View File

@ -0,0 +1,60 @@
using System;
using System.Data;
using Forks.EnterpriseServices;
using Forks.EnterpriseServices.DataDictionary;
using Forks.EnterpriseServices.DomainObjects2;
namespace BO {
[LogicName("称重数据")]
[BOClass]
[Serializable]
[MapToTable("WeightTable")]
[KeyField("ID", KeyGenType.identity)]
public class WeightTable {
[LogicName("ID")]
public long ID { get; set; }
[LogicName("日期")]
[DbColumn(DbType = SqlDbType.DateTime)]
public DateTime DateTime { get; set; }
[LogicName("级别号")]
public long? Livestock_ID { get; set; }
[LogicName("级别")]
public string Livestock_Name { get; set; }
[LogicName("重量")]
public decimal? Weight { get; set; }
[LogicName("备注")]
[DbColumn(Length = 150)]
public string Remark { get; set; }
[LogicName("扣重")]
public decimal? SubWeight { get; set; }
[LogicName("顺序号")]
public long Sequence { get; set; }
public string IP { get; set; }
[LogicName("阶段号")]
public string PhaseCode { get; set; }
[LogicName("批次")]
public string GoodsBatchName { get; set; }
[DbColumn(DefaultValue = 0)]
public long Mac { get; set; }
[DbColumn(DefaultValue = 0)]
public bool IsExport { get; set; }
[DbColumn(DefaultValue = 0)]
public bool LastExportFail { get; set; }
[DbColumn(Index = IndexType.Normal)]
public long? SourceID { get; set; }
}
}

+ 1168
- 0
Setup/Setup.vdproj
File diff suppressed because it is too large
View File


BIN
新版本注意事项.png View File

Before After
Width: 779  |  Height: 505  |  Size: 56 KiB

BIN
白条称重客户端.docx View File


Loading…
Cancel
Save