standinterfaceframe.cs
来自「独立完成考勤管理软件加打卡系统(C#) 是打卡加管理系统软件 」· CS 代码 · 共 1,369 行 · 第 1/4 页
CS
1,369 行
this.btnCanel.Name = "btnCanel";
this.btnCanel.Size = new System.Drawing.Size(72, 24);
this.btnCanel.TabIndex = 25;
this.btnCanel.Text = "清理日志";
this.btnCanel.Click += new System.EventHandler(this.btnCanel_Click);
this.btnCanel.MouseEnter += new System.EventHandler(this.BtnCloseCom_MouseEnter);
this.btnCanel.MouseLeave += new System.EventHandler(this.BtnCloseCom_MouseLeave);
//
// textBrushText
//
this.textBrushText.DropDownStyle = System.Windows.Forms.ComboBoxStyle.Simple;
this.textBrushText.Location = new System.Drawing.Point(232, 208);
this.textBrushText.Name = "textBrushText";
this.textBrushText.Size = new System.Drawing.Size(168, 20);
this.textBrushText.TabIndex = 27;
this.textBrushText.MouseEnter += new System.EventHandler(this.textBrushText_MouseEnter);
this.textBrushText.MouseLeave += new System.EventHandler(this.textBrushText_MouseLeave);
//
// groupBox1
//
//this.groupBox1.Controls.Add(this.axMSComm2);
this.groupBox1.Controls.Add(this.textInformation);
this.groupBox1.Cursor = System.Windows.Forms.Cursors.Hand;
this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.groupBox1.Location = new System.Drawing.Point(0, 304);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(520, 88);
this.groupBox1.TabIndex = 28;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "使用说明";
//
// axMSComm2
//
// this.axMSComm2.ContainingControl = this;
// this.axMSComm2.Enabled = true;
// this.axMSComm2.Location = new System.Drawing.Point(224, 32);
// this.axMSComm2.Name = "axMSComm2";
// this.axMSComm2.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axMSComm2.OcxState")));
// this.axMSComm2.Size = new System.Drawing.Size(38, 38);
// this.axMSComm2.TabIndex = 1;
// this.axMSComm2.OnComm += new System.EventHandler(this.axMSComm2_OnComm);
//
// textInformation
//
this.textInformation.BackColor = System.Drawing.SystemColors.HighlightText;
this.textInformation.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.textInformation.Location = new System.Drawing.Point(3, 16);
this.textInformation.Multiline = true;
this.textInformation.Name = "textInformation";
this.textInformation.ReadOnly = true;
this.textInformation.Size = new System.Drawing.Size(517, 72);
this.textInformation.TabIndex = 0;
this.textInformation.Text = "";
this.textInformation.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// btnUnCome
//
this.btnUnCome.BackColor = System.Drawing.Color.White;
this.btnUnCome.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnUnCome.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnUnCome.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.btnUnCome.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(64)));
this.btnUnCome.Location = new System.Drawing.Point(424, 144);
this.btnUnCome.Name = "btnUnCome";
this.btnUnCome.Size = new System.Drawing.Size(72, 24);
this.btnUnCome.TabIndex = 29;
this.btnUnCome.Text = "未到";
this.btnUnCome.Click += new System.EventHandler(this.btnUnCome_Click);
this.btnUnCome.MouseEnter += new System.EventHandler(this.BtnCloseCom_MouseEnter);
this.btnUnCome.MouseLeave += new System.EventHandler(this.BtnCloseCom_MouseLeave);
//
// StandInterfaceFrame
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(514, 389);
this.Controls.Add(this.btnUnCome);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.textBrushText);
this.Controls.Add(this.textTime);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.textReceive);
this.Controls.Add(this.btnCanel);
this.Controls.Add(this.btnCome);
this.Controls.Add(this.btnLate);
this.Controls.Add(this.label5);
this.Controls.Add(this.btnAdd);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnOpenCom);
this.Controls.Add(this.btnResevice);
this.Controls.Add(this.BtnCloseCom);
this.Controls.Add(this.label2);
this.Controls.Add(this.pictureBox1);
this.Cursor = System.Windows.Forms.Cursors.Hand;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "StandInterfaceFrame";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "StandInterfaceFrame";
this.Load += new System.EventHandler(this.StandInterfaceFrame_Load);
this.Closed += new System.EventHandler(this.StandInterfaceFrame_Closed);
this.groupBox1.ResumeLayout(false);
//((System.ComponentModel.ISupportInitialize)(this.axMSComm2)).EndInit();
this.ResumeLayout(false);
}
#endregion
#region 事件初始化...
private void StandInterfaceFrame_Load(object sender, System.EventArgs e)
{
#region 变量初始化...
this.timer.Enabled=false;
this.BtnCloseCom.Enabled=false;
this.BtnCloseCom.ForeColor=Color.Blue;
this.btnAdd.Enabled=false;
this.btnCome.Enabled=false;
this.btnLate.Enabled=false;
this.btnUnCome.Enabled=false;
this.btnOpenCom.ForeColor=Color.Black;
this.btnUnCome.ForeColor=Color.Blue;
this.btnAdd.ForeColor=Color.Blue;
this.btnLate.ForeColor=Color.Blue;
this.btnCome.ForeColor=Color.Blue;
this.textReceive.Focus();
this.textInformation.Text="此程序功能不全面,能够取进行刷卡,判断迟到,读取卡号等等一系列化功能...";
DataTable employeeStr=new DataTable();
try
{
#region employeeStr
employeeStr=selectEmployeeCount();
#endregion
#region 初始化TextBrushText控件...
DataTable datetable=new DataTable();
datetable=returnDate();
if(datetable.Rows.Count>0)
{
for(int i=0;i<datetable.Rows.Count;i++)
{
this.textBrushText.Items.Add(datetable.Rows[i][0].ToString().Trim());
}
}
else
{
return;
}
this.textBrushText.Text=System.DateTime.Now.ToLongDateString();
#endregion
}
catch(Exception ere)
{
MessageBox.Show(ere.ToString());
}
#endregion
#region 初始化MSComm1控件
// this.axMSComm1.PortOpen=true;
// btnOpenCom_Click(sender,e);
#endregion
}
#endregion
#region 判断按钮是否有效
private void buttonEnableIsNot(bool blEnable)
{
if(blEnable.Equals(false))
{
this.btnAdd.Enabled=false;
this.btnCome.Enabled=false;
this.btnLate.Enabled=false;
}
else
{
this.btnAdd.Enabled=true;
this.btnCome.Enabled=true;
this.btnLate.Enabled=true;
}
}
#endregion
#region MSCOMM控件自动事件....
private void axMSComm_OnComm(object sender, System.EventArgs e)
{
btnResevice_Click(sender,e);
if(!(this.textReceive.Text.Equals("")))
{
this.btnAdd_Click(sender,e);
}
}
#endregion
#region 时间控制触发...
private void timer_Tick(object sender, System.EventArgs e)
{
//this.axMSComm_OnComm(sender,e);
}
#endregion
#region 窗体右上角关闭按钮事件...
private void StandInterfaceFrame_Closed(object sender, System.EventArgs e)
{
DialogResult result=MessageBox.Show(this,"是否关闭窗体!!!","提示信息",MessageBoxButtons.YesNo,MessageBoxIcon.Information);
if(result.Equals(DialogResult.Yes))
{
// BtnCloseCom_Click(sender,e);
Close();
}
else
{
return;
}
}
#endregion
#region 打开端口事件...
private void btnOpenCom_Click(object sender, System.EventArgs e)
{
OpenPortOpen();
}
#endregion
#region 读取卡号事件...
private void btnResevice_Click(object sender, System.EventArgs e)
{
}
#endregion
#region 关闭端口事件...
private void BtnCloseCom_Click(object sender, System.EventArgs e)
{
ClosePortOpen();
}
#endregion
#region 端口打开的函数...
private void OpenPortOpen()
{
try
{
//this.axMSComm2.PortOpen=true;
this.btnOpenCom.FlatStyle=FlatStyle.Standard;
this.btnOpenCom.Enabled=false;
this.BtnCloseCom.Enabled=true;
this.BtnCloseCom.ForeColor=Color.Black;
this.btnOpenCom.ForeColor=Color.Blue;
MessageBox.Show(this,"串口已经打开啦!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
catch(Exception exe)
{
MessageBox.Show(exe.ToString());
}
}
#endregion
#region 处理非卡号的函数
private bool CheckBrushID(string temp)
{
bool f=false;
if(!(temp.StartsWith("39")))
{
MessageBox.Show(this,"此卡机不正确啊!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
f=true;
}
return f;
}
#endregion
#region 处理不显示卡机号
private string dealShowStr(string temp)
{
string showString="";
if(temp.StartsWith("39"))
{
showString=temp.Replace(temp.Substring(0,2).ToString(),"**").Trim();
}
return showString;
}
#endregion
#region 接收卡号函数..
private void ReseivceID()
{
try
{
// if(this.axMSComm2.InBufferCount>0)
// {
// this.textBox1.Text=this.axMSComm2.InBufferCount.ToString();
// try
// {
// #region 接收卡机号码...
// string temp="";
// byte[] strBuffer=new byte[this.axMSComm2.InBufferCount];
// strBuffer=(byte[])this.axMSComm2.Input;
// for(int i=0;i<strBuffer.Length;i++)
// {
// if(strBuffer[i].ToString("X").Length<=1)
// {
// temp+="0"+strBuffer[i].ToString("X");
// }
// else
// {
// temp+=strBuffer[i].ToString("X");
// }
// }
// #endregion
// #region 处理非卡号
// if(this.CheckBrushID(temp).Equals(true))
// {
// MessageBox.Show(this,"请你与新华易公司联系啊!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
// return;
// }
// else
// {
// #region 处理不显示卡机号
// string tempString=this.dealShowStr(temp);
// #endregion
// this.textReceive.Text=tempString;
// }
// #endregion
// strReserice=this.textReceive.Text;
// this.axMSComm2.InBufferCount=0;
// this.axMSComm2.OutBufferCount=0;
// }
// catch(System.FormatException ele)
// {
// MessageBox.Show(ele.ToString());
// }
// }
// else
// {
// MessageBox.Show(this,"缓冲区内没有任何数据!!!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Information);
// this.axMSComm2.InBufferCount=0;
// this.axMSComm2.OutBufferCount=0;
// return;
// }
}
catch(Exception exe)
{
MessageBox.Show(exe.ToString());
}
}
#endregion
#region 关闭串口端口并清理缓存函数...
private void ClosePortOpen()
{
try
{
//this.axMSComm2.PortOpen=false;
this.btnOpenCom.FlatStyle=FlatStyle.Flat;
this.btnOpenCom.Enabled=true;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?