📄 brushkaidframe.cs
字号:
this.Controls.Add(this.TitleLabel);
this.Controls.Add(this.btnClear);
this.Controls.Add(this.NameText);
this.Controls.Add(this.listBox);
this.Controls.Add(this.textListBox);
this.Controls.Add(this.textBox);
this.Controls.Add(this.textBrushText);
this.Controls.Add(this.textTextText);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "BrushKaIDFrame";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "BrushKaIDFrame";
this.toolTip.SetToolTip(this, "右键关闭窗体");
this.Closing += new System.ComponentModel.CancelEventHandler(this.BrushKaIDFrame_Closing);
this.Load += new System.EventHandler(this.BrushKaIDFrame_Load);
((System.ComponentModel.ISupportInitialize)(this.brushIDSet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.axMSComm2)).EndInit();
this.ResumeLayout(false);
}
#endregion
#region 窗体初始化...
private void BrushKaIDFrame_Load(object sender, System.EventArgs e)
{
#region 初始化变量...
this.btnOpen.Enabled=true;
this.btnClose.Enabled=false;
this.btnClear.Enabled=false;
this.StitictisLabel.Text="统计: 0 个";
#endregion
#region 串口初始化...
this.axMSComm2.PortOpen=true;
axMSComm2.SThreshold=6;
axMSComm2.RThreshold=6;
if(this.axMSComm2.InBufferCount>0)
{
axMSComm2_OnComm(sender,e);
this.axMSComm2.InBufferCount=0;
this.axMSComm2.OutBufferCount=0;
}
else
{
this.axMSComm2.InBufferCount=0;
this.axMSComm2.OutBufferCount=0;
return;
}
#endregion
}
#endregion
#region 光标移动变化...
private void btnOpen_MouseLeave(object sender, System.EventArgs e)
{
Button button=(Button)sender;
button.FlatStyle=FlatStyle.Flat;
button.ForeColor=Color.Blue;
}
private void btnOpen_MouseEnter(object sender, System.EventArgs e)
{
Button button=(Button)sender;
button.FlatStyle=FlatStyle.Standard;
button.ForeColor=Color.Black;
}
private void btnOpenPort_MouseLeave(object sender, System.EventArgs e)
{
Button button=(Button)sender;
button.FlatStyle=FlatStyle.Flat;
}
private void btnOpenPort_MouseEnter(object sender, System.EventArgs e)
{
Button button=(Button)sender;
button.FlatStyle=FlatStyle.Standard;
}
#endregion
#region 打开端口...
private void btnOpen_Click(object sender, System.EventArgs e)
{
OpenPortOpen();
}
#endregion
#region 关闭端口...
private void btnClose_Click(object sender, System.EventArgs e)
{
ClosePortOpen();
}
#endregion
#region 当前日期与时间事件...
private void CurrentTime_Tick(object sender, System.EventArgs e)
{
this.DateLabel.Text="日期:"+System.DateTime.Now.ToLongDateString();
this.TimeLabel.Text="时间:"+this.dealTime().Trim();
}
#endregion
#region 右键菜单事件...
private void menuClose_Click(object sender, System.EventArgs e)
{
//this.axMSComm4.PortOpen=false;
this.Dispose();
}
#endregion
#region 接收卡区改变事件...
private void textBrushText_TextChanged(object sender, System.EventArgs e)
{
}
#endregion
#region 打开端口函数...
private void OpenPortOpen()
{
try
{
this.axMSComm2.PortOpen=true;
this.StitictisLabel.Text="统计:0个";
this.textBrushText.Text="";
MessageBox.Show(this,"串口已经打开啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.btnOpen.Enabled=false;
this.btnClose.Enabled=true;
}
catch(Exception exe)
{
MessageBox.Show(exe.ToString());
}
}
#endregion
#region 关闭端口函数...
private void ClosePortOpen()
{
try
{
this.axMSComm2.PortOpen=false;
MessageBox.Show(this,"串口已经关闭啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.btnClose.Enabled=false;
this.btnOpen.Enabled=true;
this.btnClear.Enabled=true;
BrushCounts=this.brushCount;
brushCount=0;
this.StitictisLabel.Text="统计:"+this.brushCount.ToString().Trim()+"个";
}
catch(Exception exe)
{
MessageBox.Show(exe.ToString());
}
}
#endregion
#region 接收卡号函数...
private void ReseivceID()
{
try
{
#region 接收原字符串
string temp=reserceID();
#endregion
#region 处理非卡号
if(this.CheckBrushID(temp).Equals(true))
{
MessageBox.Show(this,"请你与新华易公司联系啊!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
#endregion
#region 正确卡号...
else
{
string stritem="",t="",tempID="";
if(temp.Length<12)
{
MessageBox.Show(this,"此卡号不正常而已!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
if(temp.Length>12 || temp.Length.Equals(12))
{
int k=temp.Length/12;
p=k;
for(int i=0;i<k;i++)
{
stritem=temp.Substring(i*12,12);
t=deal8String(stritem);
tempID=WindowsApplication.HexToTen.HexToTen.Hex2Ten(t);
this.textListBox.Items.Add(tempID);
this.listBox.Items.Add(tempID);
empStr=this.brushEvent().Trim();
// MessageBox.Show(empStr);
brushIDText();
brushCount++;
// BrushIDHistory();
}
}
#region 注释...
// #region 截取字符串...
// string tempString=deal8String(temp);
// #endregion
// #region 转换十进制数...
// string tempStr=WindowsApplication.HexToTen.HexToTen.Hex2Ten(tempString);
// #endregion
// #region 显示字符串...
// this.textListBox.Items.Add(tempStr.Trim());
// this.listBox.Items.Add(tempStr.Trim());
// #endregion
#endregion
}
#endregion
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
#endregion
#region reserceID();
private string reserceID()
{
string str="";
try
{
if(axMSComm2.InBufferCount<=0)
{
this.axMSComm2.InBufferCount=0;
this.axMSComm2.OutBufferCount=0;
return string.Empty;
}
else
{
#region 声明数组用来存储号码....
byte[] strBuffer=new byte[this.axMSComm2.InBufferCount];
#endregion
#region 声明变量....
strBuffer=(byte[])this.axMSComm2.Input;
#endregion
for(int i=0;i<strBuffer.Length;i++)
{
if(strBuffer[i].ToString("X").Length<=1)
{
str+=strBuffer[i].ToString("X2").Trim();
}
else
{
str+=strBuffer[i].ToString("X").Trim();
}
}
}
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
return str;
}
#endregion
#region reserveID()
private string reserveID()
{
string str="";
try
{
if(axMSComm2.InBufferCount>0)
{
#region 声明数组用来存储号码....
byte[] strBufferA=new byte[this.axMSComm2.InBufferCount];
#endregion
#region 声明变量....
strBufferA=(byte[])this.axMSComm2.Input;
#endregion
for(int k=0;k<strBufferA.Length;k++)
{
if(strBufferA[k].ToString("X").Length<=1)
{
str+=strBufferA[k].ToString("X2").Trim();
}
else
{
str+=strBufferA[k].ToString("X").Trim();
}
}
}
else
{
this.axMSComm2.InBufferCount=0;
this.axMSComm2.OutBufferCount=0;
return string.Empty;
}
}
catch(Exception ele)
{
MessageBox.Show(this,ele.ToString(),"提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
return str;
}
#endregion
#region 处理时间变量
private String dealTime()
{
#region 时间变量..
int hour=System.DateTime.Now.Hour;
int minute=System.DateTime.Now.Minute;
int second=System.DateTime.Now.Second;
#endregion
string currentTimeStr="";
int h=1;
int w=1;
int y=1;
int r=1;
// MessageBox.Show(hour.ToString());
if(hour>=13 && hour<=23)
{
h=hour-12;
#region 如果时,分,秒都小于10...
if(h<10 && minute<10 && second<10) //如果时,分,秒都小于10例如:02:01:01
{
currentTimeStr="0"+h.ToString()+":0"+minute.ToString()+":0"+second.ToString()+""+"PM";
}
#endregion
#region 如果时小于10,分小于10,秒大于10
else if(h<10 && minute<10 && second>=10)//05;02;28
{
currentTimeStr="0"+h.ToString()+":0"+minute.ToString()+":"+second.ToString()+""+"PM";
}
#endregion
#region 如果时小于10,分大于10,秒小于10 //01:21:01
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -