chore: 初始化东安动力MES采集程序

This commit is contained in:
yexingqiang
2026-05-29 13:57:19 +08:00
commit b5c49a5d86
1121 changed files with 168795 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{269C9CBC-4958-4E4D-B43B-307C1D09D87F}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>PrintBarCode</RootNamespace>
<AssemblyName>PrintBarCode</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DB.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="PrintBarCodeForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="PrintBarCodeForm.Designer.cs">
<DependentUpon>PrintBarCodeForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="PrintBarCodeForm.resx">
<DependentUpon>PrintBarCodeForm.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>
<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>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

10
PrintBarCode/App.config Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="ConnectionString_MES" value="server=124.220.15.242\MSSQLSERVER2012,1433;User ID=meswork;Password=126.com;database=MacroinfBasicDB_BQ;Connection Reset=FALSE"/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
</configuration>

168
PrintBarCode/DB.cs Normal file
View File

@@ -0,0 +1,168 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PrintBarCode
{
public partial class PrintBarCodeForm
{
private DataTable PrintLogInset(string partNo, int partCount, int beginNumber, DateTime proDate)
{
// ALTER PROCEDURE[dbo].[北汽福田打印条码日志_增加]
// @零件号 nvarchar(50),
//@数量 int,
//@开始号码 int,
//@日期 date
DataTable dt = new DataTable();
string procedureName = "北汽福田打印条码日志_增加";
SqlParameter[] sqlParameters = new SqlParameter[4];
//string columnPartName = "column18";
sqlParameters[0] = new System.Data.SqlClient.SqlParameter("@零件号", partNo);
sqlParameters[1] = new System.Data.SqlClient.SqlParameter("@数量", partCount);
sqlParameters[2] = new System.Data.SqlClient.SqlParameter("@开始号码", beginNumber);
sqlParameters[3] = new System.Data.SqlClient.SqlParameter("@日期", proDate);
ExecuteStoredProcedure(procedureName, ConnectString_MES, ref sqlParameters, out dt);
return dt;
}
private DataTable PrintSnInset(string sn, string partNo, int partCount, int beginNumber, DateTime proDate)
{
// ALTER PROCEDURE[dbo].[北汽福田打印条码变速器序列号_增加]
// @变速器序列号 nvarchar(50),
//@零件号 nvarchar(50),
//@数量 int,
//@开始号码 int,
//@日期 date
DataTable dt = new DataTable();
string procedureName = "北汽福田打印条码变速器序列号_增加";
SqlParameter[] sqlParameters = new SqlParameter[5];
//string columnPartName = "column18";
sqlParameters[0] = new System.Data.SqlClient.SqlParameter("@变速器序列号", sn);
sqlParameters[1] = new System.Data.SqlClient.SqlParameter("@零件号", partNo);
sqlParameters[2] = new System.Data.SqlClient.SqlParameter("@数量", partCount);
sqlParameters[3] = new System.Data.SqlClient.SqlParameter("@开始号码", beginNumber);
sqlParameters[4] = new System.Data.SqlClient.SqlParameter("@日期", proDate);
ExecuteStoredProcedure(procedureName, ConnectString_MES, ref sqlParameters, out dt);
return dt;
}
private DataTable PrintSnUpdate(string sn, string partNo, int partCount, int beginNumber, DateTime proDate)
{
DataTable dt = new DataTable();
string procedureName = "北汽福田打印条码变速器序列号_更新";
SqlParameter[] sqlParameters = new SqlParameter[5];
//string columnPartName = "column18";
sqlParameters[0] = new System.Data.SqlClient.SqlParameter("@变速器序列号", sn);
sqlParameters[1] = new System.Data.SqlClient.SqlParameter("@零件号", partNo);
sqlParameters[2] = new System.Data.SqlClient.SqlParameter("@数量", partCount);
sqlParameters[3] = new System.Data.SqlClient.SqlParameter("@开始号码", beginNumber);
sqlParameters[4] = new System.Data.SqlClient.SqlParameter("@日期", proDate);
ExecuteStoredProcedure(procedureName, ConnectString_MES, ref sqlParameters, out dt);
return dt;
}
/// <summary>
/// 0:没有打印过
/// 1打印过
/// </summary>
/// <param name="sn"></param>
/// <returns></returns>
private int PrintSnIsPrinted(string sn)
{
//北汽福田打印条码变速器序列号_是否打印过
// @变速器序列号 nvarchar(50),
DataTable dt = new DataTable();
string procedureName = "北汽福田打印条码变速器序列号_是否打印过";
SqlParameter[] sqlParameters = new SqlParameter[1];
//string columnPartName = "column18";
sqlParameters[0] = new System.Data.SqlClient.SqlParameter("@变速器序列号", sn);
ExecuteStoredProcedure(procedureName, ConnectString_MES, ref sqlParameters, out dt);
int count;
count = Convert.ToInt32(dt.Rows[0][0]);
return count;
}
/// <summary>
/// @工位号 nvarchar(50),
/// @TagValue nvarchar(50),
/// @变量类型代码 nvarchar(50)
/// </summary>
/// <param name="opName"></param>
/// <param name="tagValue"></param>
/// <param name="tagTypeID"></param>
private void OpNameMonitorInsert(string opName,string tagValue,string tagTypeID)
{
string procedureName = "北汽福田工位状态监控_增加";
SqlParameter[] sqlParameters = new SqlParameter[3];
sqlParameters[0] = new System.Data.SqlClient.SqlParameter("@opName", opName);
sqlParameters[1] = new System.Data.SqlClient.SqlParameter("@tagValue", tagValue);
sqlParameters[2] = new System.Data.SqlClient.SqlParameter("@tagTypeID", tagTypeID);
ExecuteStoredProcedure(procedureName, ConnectString_MES, ref sqlParameters);
}
public static bool ExecuteStoredProcedure(string procedureName, string connectionString, ref SqlParameter[] sqlParameters)
{
DataTable dt;
return ExecuteStoredProcedure(procedureName, connectionString, ref sqlParameters, out dt);
}
public static bool ExecuteStoredProcedure(string procedureName, string connectionString, ref SqlParameter[] sqlParameters, out DataTable dt)
{
bool result = false;
string errorMessage;
errorMessage = "";
dt = new DataTable();
using (SqlConnection conn = new SqlConnection(connectionString))
{
try
{
conn.Open();
using (SqlDataAdapter dsCommand = new SqlDataAdapter())
{
dsCommand.SelectCommand = new SqlCommand(procedureName, conn);
dsCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
dsCommand.SelectCommand.CommandTimeout = 0;
if (sqlParameters != null)
{
for (int i = 0; i < sqlParameters.Length; i++)
{
dsCommand.SelectCommand.Parameters.Add(sqlParameters[i]);
}
}
dsCommand.Fill(dt);
}
result = true;
}
catch (Exception e)
{
errorMessage = e.ToString();
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
return result;
}
}
}

261
PrintBarCode/PrintBarCodeForm.Designer.cs generated Normal file
View File

@@ -0,0 +1,261 @@
namespace PrintBarCode
{
partial class PrintBarCodeForm
{
/// <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.label1 = new System.Windows.Forms.Label();
this.comboBox_PartNNo = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.numericUpDown_Count = new System.Windows.Forms.NumericUpDown();
this.numericUpDown_BeginNumber = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
this.listBox1 = new System.Windows.Forms.ListBox();
this.button_Print = new System.Windows.Forms.Button();
this.button_PreView = new System.Windows.Forms.Button();
this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
this.button_M_SnOne = new System.Windows.Forms.Button();
this.textBox_SN = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.button_SaveToProductPlan = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown_Count)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown_BeginNumber)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(29, 35);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 12);
this.label1.TabIndex = 0;
this.label1.Text = "零件号";
//
// comboBox_PartNNo
//
this.comboBox_PartNNo.FormattingEnabled = true;
this.comboBox_PartNNo.Location = new System.Drawing.Point(90, 32);
this.comboBox_PartNNo.Name = "comboBox_PartNNo";
this.comboBox_PartNNo.Size = new System.Drawing.Size(219, 20);
this.comboBox_PartNNo.TabIndex = 1;
this.comboBox_PartNNo.Text = "1335 001 016";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(332, 35);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(29, 12);
this.label2.TabIndex = 0;
this.label2.Text = "数量";
//
// numericUpDown_Count
//
this.numericUpDown_Count.Location = new System.Drawing.Point(368, 30);
this.numericUpDown_Count.Maximum = new decimal(new int[] {
10000,
0,
0,
0});
this.numericUpDown_Count.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDown_Count.Name = "numericUpDown_Count";
this.numericUpDown_Count.Size = new System.Drawing.Size(120, 21);
this.numericUpDown_Count.TabIndex = 2;
this.numericUpDown_Count.Value = new decimal(new int[] {
10,
0,
0,
0});
//
// numericUpDown_BeginNumber
//
this.numericUpDown_BeginNumber.Location = new System.Drawing.Point(90, 69);
this.numericUpDown_BeginNumber.Maximum = new decimal(new int[] {
1000000000,
0,
0,
0});
this.numericUpDown_BeginNumber.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDown_BeginNumber.Name = "numericUpDown_BeginNumber";
this.numericUpDown_BeginNumber.Size = new System.Drawing.Size(219, 21);
this.numericUpDown_BeginNumber.TabIndex = 2;
this.numericUpDown_BeginNumber.Value = new decimal(new int[] {
30000001,
0,
0,
0});
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(29, 78);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(53, 12);
this.label3.TabIndex = 0;
this.label3.Text = "开始号码";
//
// listBox1
//
this.listBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
this.listBox1.FormattingEnabled = true;
this.listBox1.Location = new System.Drawing.Point(31, 137);
this.listBox1.Name = "listBox1";
this.listBox1.ScrollAlwaysVisible = true;
this.listBox1.Size = new System.Drawing.Size(457, 290);
this.listBox1.TabIndex = 3;
this.listBox1.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.listBox1_DrawItem);
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
//
// button_Print
//
this.button_Print.Location = new System.Drawing.Point(545, 327);
this.button_Print.Name = "button_Print";
this.button_Print.Size = new System.Drawing.Size(149, 91);
this.button_Print.TabIndex = 4;
this.button_Print.Text = "打印条码";
this.button_Print.UseVisualStyleBackColor = true;
this.button_Print.Click += new System.EventHandler(this.button_Print_Click);
//
// button_PreView
//
this.button_PreView.Location = new System.Drawing.Point(368, 69);
this.button_PreView.Name = "button_PreView";
this.button_PreView.Size = new System.Drawing.Size(120, 23);
this.button_PreView.TabIndex = 5;
this.button_PreView.Text = "预览";
this.button_PreView.UseVisualStyleBackColor = true;
this.button_PreView.Click += new System.EventHandler(this.button_PreView_Click);
//
// dateTimePicker1
//
this.dateTimePicker1.Location = new System.Drawing.Point(582, 29);
this.dateTimePicker1.Name = "dateTimePicker1";
this.dateTimePicker1.Size = new System.Drawing.Size(138, 21);
this.dateTimePicker1.TabIndex = 6;
//
// button_M_SnOne
//
this.button_M_SnOne.Location = new System.Drawing.Point(545, 137);
this.button_M_SnOne.Name = "button_M_SnOne";
this.button_M_SnOne.Size = new System.Drawing.Size(149, 91);
this.button_M_SnOne.TabIndex = 4;
this.button_M_SnOne.Text = "手动单条打印条码";
this.button_M_SnOne.UseVisualStyleBackColor = true;
this.button_M_SnOne.Click += new System.EventHandler(this.button_M_SnOne_Click);
//
// textBox_SN
//
this.textBox_SN.Location = new System.Drawing.Point(90, 101);
this.textBox_SN.Name = "textBox_SN";
this.textBox_SN.Size = new System.Drawing.Size(398, 21);
this.textBox_SN.TabIndex = 7;
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(29, 104);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(41, 12);
this.label4.TabIndex = 0;
this.label4.Text = "序列号";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(513, 35);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(53, 12);
this.label5.TabIndex = 0;
this.label5.Text = "生产日期";
//
// button_SaveToProductPlan
//
this.button_SaveToProductPlan.Location = new System.Drawing.Point(582, 66);
this.button_SaveToProductPlan.Name = "button_SaveToProductPlan";
this.button_SaveToProductPlan.Size = new System.Drawing.Size(138, 23);
this.button_SaveToProductPlan.TabIndex = 8;
this.button_SaveToProductPlan.Text = "保存到生产计划";
this.button_SaveToProductPlan.UseVisualStyleBackColor = true;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(741, 450);
this.Controls.Add(this.button_SaveToProductPlan);
this.Controls.Add(this.textBox_SN);
this.Controls.Add(this.dateTimePicker1);
this.Controls.Add(this.button_PreView);
this.Controls.Add(this.button_M_SnOne);
this.Controls.Add(this.button_Print);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.numericUpDown_BeginNumber);
this.Controls.Add(this.numericUpDown_Count);
this.Controls.Add(this.comboBox_PartNNo);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label5);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "打印变速器序列号条码";
((System.ComponentModel.ISupportInitialize)(this.numericUpDown_Count)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown_BeginNumber)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox comboBox_PartNNo;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.NumericUpDown numericUpDown_Count;
private System.Windows.Forms.NumericUpDown numericUpDown_BeginNumber;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Button button_Print;
private System.Windows.Forms.Button button_PreView;
private System.Windows.Forms.DateTimePicker dateTimePicker1;
private System.Windows.Forms.Button button_M_SnOne;
private System.Windows.Forms.TextBox textBox_SN;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Button button_SaveToProductPlan;
}
}

View File

@@ -0,0 +1,214 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PrintBarCode
{
public partial class PrintBarCodeForm : Form
{
public static string ConnectString_MES = ConfigurationManager.AppSettings["ConnectionString_MES"];
Hashtable hsSnIsPrinted = new Hashtable ();
bool IsSnIsPrintedOK=true;
public PrintBarCodeForm()
{
InitializeComponent();
dateTimePicker1.Value= DateTime.Now;
}
private void button_Print_Click(object sender, EventArgs e)
{
string partNo;
int partCount;
int beginNumber;
DateTime proDate;
partNo = comboBox_PartNNo.Text;
partCount =(int) numericUpDown_Count.Value;
beginNumber = (int)numericUpDown_BeginNumber.Value;
proDate = dateTimePicker1.Value;
if(listBox1.Items.Count<1)
{
MessageBox.Show("请先点击变速器序列号预览按钮");
return;
}
if(!IsSnIsPrintedOK)
{
MessageBox.Show("变速器序列号有重复打印的,请选择手动方式打印");
return;
}
PrintLogInset(partNo, partCount, beginNumber, proDate);
//InitLiatBox1();
PrintSnList();
}
private void PrintSnList()
{
foreach(var sn in listBox1.Items)
{
PrintSnToPrinter(sn.ToString());
}
}
private void PrintSnToPrinter(string sn)
{
string partNo;
int partCount;
int beginNumber;
DateTime proDate;
partNo = comboBox_PartNNo.Text;
partCount = (int)numericUpDown_Count.Value;
beginNumber = (int)numericUpDown_BeginNumber.Value;
proDate = dateTimePicker1.Value;
if (IsSnIsCanPrinted(sn.ToString()))
{
PrintBarCode(sn.ToString());
PrintSnInset(sn.ToString(), partNo, partCount, beginNumber, proDate);
}
else
{
if (MessageBox.Show("变速器序列号已经打印过", "变速器序列号已经打印过,是否重复打印", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
PrintBarCode(sn.ToString());
PrintSnUpdate(sn.ToString(), partNo, partCount, beginNumber, proDate);
}
}
}
private void PrintBarCode(string barCode) { }
private void InitLiatBox1()
{
string partNo;
int partCount;
int beginNumber;
DateTime proDate;
partNo = comboBox_PartNNo.Text;
partCount = (int)numericUpDown_Count.Value;
beginNumber = (int)numericUpDown_BeginNumber.Value;
proDate = dateTimePicker1.Value;
List<string> list = CreatePartList(partNo, partCount, beginNumber, proDate);
hsSnIsPrinted.Clear();
listBox1.Items.Clear();
foreach (var item in list)
{
listBox1.Items.Add(item);
if(!IsSnIsCanPrinted(item))
{
IsSnIsPrintedOK = false;
}
int count;
count = PrintSnIsPrinted(item);
hsSnIsPrinted.Add(item, count);
}
}
private bool IsSnIsCanPrinted(string sn)
{
int count;
count = PrintSnIsPrinted(sn);
if (count > 0)
{
IsSnIsPrintedOK = false;
return false;
}
return true;
}
private List<string> CreatePartList(string partNo, int partCount, int beginNumber, DateTime proDate)
{
List<string> list = new List<string>();
string proDateString;
string sn;
proDateString = proDate.ToString("ddMMyyyy");
for(int i = beginNumber;i< beginNumber+ partCount;i++)
{
sn = i.ToString("00000000");
list.Add(partNo + "*" + proDateString + "*" + sn);
}
return list;
}
private void button_PreView_Click(object sender, EventArgs e)
{
InitLiatBox1();
}
private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
{
e.DrawBackground(); //先调用基类实现
if (e.Index < 0) //form load 的时候return
return;
int count = Convert.ToInt32( hsSnIsPrinted[listBox1.Items[e.Index].ToString()]);
if(count > 0 ) {
e.Graphics.DrawString(listBox1.Items[e.Index].ToString(),
e.Font, Brushes.Red, e.Bounds);
}
else
{
e.Graphics.DrawString(listBox1.Items[e.Index].ToString(),
e.Font, Brushes.Black, e.Bounds);
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
//form load 的时候return
string item;
item = ((ListBox) sender).SelectedItem.ToString();
textBox_SN.Text = item;
}
private void button_M_SnOne_Click(object sender, EventArgs e)
{
string sn;
sn = textBox_SN.Text;
if(sn.Length > 10)
{
PrintSnToPrinter(sn);
}
else
{
MessageBox.Show("请选择打印条码变速器序列号");
}
}
}
}

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>

22
PrintBarCode/Program.cs Normal file
View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PrintBarCode
{
internal static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new PrintBarCodeForm());
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("PrintBarCode")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PrintBarCode")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("269c9cbc-4958-4e4d-b43b-307c1d09d87f")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace PrintBarCode.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.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("PrintBarCode.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;
}
}
}
}

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>

View File

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

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>