📄 mains.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlServerCe;
using Lib;
namespace AssetCheck
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Mains : System.Windows.Forms.Form
{
public static string SelfNO="";
private System.Windows.Forms.Button btnCheck;
private System.Windows.Forms.Button btnDataIn;
private System.Windows.Forms.Button btnCloseMachine;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnOpen;
public static string Pass="";
public Mains()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btnCheck = new System.Windows.Forms.Button();
this.btnCloseMachine = new System.Windows.Forms.Button();
this.btnDataIn = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button();
this.btnOpen = new System.Windows.Forms.Button();
//
// btnCheck
//
this.btnCheck.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Bold);
this.btnCheck.Location = new System.Drawing.Point(28, 2);
this.btnCheck.Size = new System.Drawing.Size(182, 38);
this.btnCheck.Text = "1.盘点管理";
this.btnCheck.Click += new System.EventHandler(this.btnCheck_Click);
//
// btnCloseMachine
//
this.btnCloseMachine.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Bold);
this.btnCloseMachine.Location = new System.Drawing.Point(28, 160);
this.btnCloseMachine.Size = new System.Drawing.Size(182, 38);
this.btnCloseMachine.Text = "<.关 机";
this.btnCloseMachine.Click += new System.EventHandler(this.btnCloseMachine_Click);
//
// btnDataIn
//
this.btnDataIn.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Bold);
this.btnDataIn.Location = new System.Drawing.Point(28, 40);
this.btnDataIn.Size = new System.Drawing.Size(182, 38);
this.btnDataIn.Text = "2.数据导入";
this.btnDataIn.Click += new System.EventHandler(this.btnDataIn_Click);
//
// btnClose
//
this.btnClose.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Bold);
this.btnClose.Location = new System.Drawing.Point(28, 119);
this.btnClose.Size = new System.Drawing.Size(182, 38);
this.btnClose.Text = "4.关闭背光";
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// btnOpen
//
this.btnOpen.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Bold);
this.btnOpen.Location = new System.Drawing.Point(28, 79);
this.btnOpen.Size = new System.Drawing.Size(182, 38);
this.btnOpen.Text = "3.打开背光";
this.btnOpen.Click += new System.EventHandler(this.btnOpen_Click);
//
// Mains
//
this.ClientSize = new System.Drawing.Size(242, 197);
this.ControlBox = false;
this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnOpen);
this.Controls.Add(this.btnDataIn);
this.Controls.Add(this.btnCloseMachine);
this.Controls.Add(this.btnCheck);
this.Font = new System.Drawing.Font("宋体", 18F, System.Drawing.FontStyle.Bold);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Text = "欢迎使用本系统";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Mains_KeyDown);
this.Closing += new System.ComponentModel.CancelEventHandler(this.Mains_Closing);
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Mains_KeyPress);
this.Load += new System.EventHandler(this.Mains_Load);
this.Closed += new System.EventHandler(this.Mains_Closed);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
static void Main()
{
/*Login login = new Login();
try
{
if (login.ShowDialog()==DialogResult.OK)
{
Application.Run(new Mains());
}
else
{
Application.Exit();
}
}
finally
{
login.Dispose();
}*/
Application.Run(new Mains());
}
private void Mains_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar==(char)49)
{
btnCheck_Click(sender,e);
}
if (e.KeyChar==(char)50)
{
btnDataIn_Click(sender,e);
}
if (e.KeyChar==(char)51)
{
btnOpen_Click(sender,e);
}
if (e.KeyChar==(char)52)
{
btnClose_Click(sender,e);
}
if ((e.KeyChar==(char)27) )
{
this.Close();
}
}
private void Mains_Load(object sender, System.EventArgs e)
{
Login login = new Login();
try
{
if (login.ShowDialog()==DialogResult.OK)
{
}
else
{
Application.Exit();
return;
}
}
finally
{
login.Dispose();
}
if (!Login.bl)
{
if (!Libs.DataBase.SetDataBase())
{
Application.Exit();
return;
}
}
}
private void Mains_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
E.Beep("",50,2670,2);
E.MessageShow(false,"你是要退出本系统吗?");
if (!YNMessage.YN)
{
e.Cancel=true;
return;
}
}
private void Mains_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyData==Keys.F2)
{
string IDTemp=Lib.E.GetUN(Lib.E.GetMID());
E.Beep("",50,2670,2);
E.MessageShow(true,"ID: "+IDTemp+"00400");
}
if (e.KeyData==Keys.F1)
{
E.Beep("",50,2670,2);
E.MessageShow(true,"版本:\n2006-09-08 10:47:25");
}
if (e.KeyData==Keys.Left )
{
btnCloseMachine_Click(sender,e);
}
}
private void btnCheck_Click(object sender, System.EventArgs e)
{
CheckChoose checkChoose=new CheckChoose();
try
{
checkChoose.ShowDialog();
}
finally
{
checkChoose.Dispose();
}
}
private void button1_Click(object sender, System.EventArgs e)
{
Close();
}
private void btnDataIn_Click(object sender, System.EventArgs e)
{
if (E.conn.State==ConnectionState.Open)
{
E.conn.Close();
}
if (!Libs.DataBase.SetDataBase())
{
Application.Exit();
return;
}
}
private void btnCloseMachine_Click(object sender, System.EventArgs e)
{
this.Close();
//E.Suspend();
}
private void btnOpen_Click(object sender, System.EventArgs e)
{
E.BacklightOn();
}
private void btnClose_Click(object sender, System.EventArgs e)
{
E.BacklightOff();
}
private void Mains_Closed(object sender, System.EventArgs e)
{
E.Dispose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -