📄 frmlogin.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text;
using System.IO;
namespace ShInfo
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class frmLogin : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblName;
private System.Windows.Forms.Label lblTel;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.TextBox txtName;
private System.Windows.Forms.TextBox txtTel;
private System.Windows.Forms.Button btnLogin;
private System.Windows.Forms.Button btnExit;
public static UserInfo use=new UserInfo();
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Timer timer1;
private Sunisoft.IrisSkin.SkinEngine skinEngine1;
public frmLogin()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
this.skinEngine1.SkinFile = "MP10.ssk";
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmLogin));
this.skinEngine1 = new Sunisoft.IrisSkin.SkinEngine(((System.ComponentModel.Component)(this)));
this.lblName = new System.Windows.Forms.Label();
this.lblTel = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.txtName = new System.Windows.Forms.TextBox();
this.txtTel = new System.Windows.Forms.TextBox();
this.btnLogin = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout();
//
// skinEngine1
//
this.skinEngine1.SerialNumber = "";
this.skinEngine1.SkinFile = null;
//
// lblName
//
this.lblName.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.lblName.Image = ((System.Drawing.Image)(resources.GetObject("lblName.Image")));
this.lblName.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.lblName.Location = new System.Drawing.Point(64, 352);
this.lblName.Name = "lblName";
this.lblName.Size = new System.Drawing.Size(64, 24);
this.lblName.TabIndex = 0;
this.lblName.Text = "姓名:";
this.lblName.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
//
// lblTel
//
this.lblTel.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.lblTel.Image = ((System.Drawing.Image)(resources.GetObject("lblTel.Image")));
this.lblTel.ImageAlign = System.Drawing.ContentAlignment.TopRight;
this.lblTel.Location = new System.Drawing.Point(304, 352);
this.lblTel.Name = "lblTel";
this.lblTel.Size = new System.Drawing.Size(88, 24);
this.lblTel.TabIndex = 1;
this.lblTel.Text = "手机号码:";
this.lblTel.TextAlign = System.Drawing.ContentAlignment.BottomLeft;
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(584, 344);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 2;
this.pictureBox1.TabStop = false;
//
// txtName
//
this.txtName.AutoSize = false;
this.txtName.Location = new System.Drawing.Point(104, 352);
this.txtName.MaxLength = 6;
this.txtName.Name = "txtName";
this.txtName.Size = new System.Drawing.Size(144, 24);
this.txtName.TabIndex = 3;
this.txtName.Text = "";
this.txtName.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtName_KeyPress);
this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged);
this.txtName.Leave += new System.EventHandler(this.txtName_Leave);
//
// txtTel
//
this.txtTel.AutoSize = false;
this.txtTel.Location = new System.Drawing.Point(376, 352);
this.txtTel.MaxLength = 11;
this.txtTel.Name = "txtTel";
this.txtTel.Size = new System.Drawing.Size(144, 24);
this.txtTel.TabIndex = 4;
this.txtTel.Text = "";
this.txtTel.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtTel_KeyPress);
this.txtTel.Leave += new System.EventHandler(this.txtTel_Leave);
//
// btnLogin
//
this.btnLogin.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.btnLogin.Location = new System.Drawing.Point(168, 408);
this.btnLogin.Name = "btnLogin";
this.btnLogin.Size = new System.Drawing.Size(96, 24);
this.btnLogin.TabIndex = 5;
this.btnLogin.Text = "登陆(&L)";
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
//
// btnExit
//
this.btnExit.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.btnExit.Location = new System.Drawing.Point(336, 408);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(96, 23);
this.btnExit.TabIndex = 6;
this.btnExit.Text = "取消(&Q)";
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 90;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// frmLogin
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
this.ClientSize = new System.Drawing.Size(584, 449);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnLogin);
this.Controls.Add(this.txtTel);
this.Controls.Add(this.txtName);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.lblTel);
this.Controls.Add(this.lblName);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(592, 496);
this.MinimizeBox = false;
this.Name = "frmLogin";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "登陆窗口";
this.Load += new System.EventHandler(this.frmLogin_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new frmLogin());
}
private void frmLogin_Load(object sender, System.EventArgs e)
{
this.Opacity =0;
}
private void btnLogin_Click(object sender, System.EventArgs e)
{
if(this.txtName.Text.Length!=0&&this.txtTel.Text.Length!=0)
{
string aa=this.txtTel.Text;
if(aa.Substring(0,2)=="13"||
aa.Substring(0,3)=="150"||
aa.Substring(0,3)=="156"||
aa.Substring(0,3)=="158"||
aa.Substring(0,3)=="159")
{
WLogin aaa=new WLogin();
use.Uname=this.txtName.Text;
use.Unum=this.txtTel.Text;
aaa.Allusers(use);
this.txtName.Clear();
this.txtTel.Clear();
MessageBox.Show("登陆成功","提示:");
frmMain M=new frmMain();
M.Show();
this.Hide();
}
else
{
MessageBox.Show("手机号码输入错误","提示:");
this.txtTel.Clear();
this.txtTel.Focus();
}
}
else
{
if(this.txtName==null)
{
MessageBox.Show("姓名不能为空","提示:");
this.txtName.Focus();
}
else
{
MessageBox.Show("电话号码不能我为空","提示:");
this.txtTel.Focus();
}
}
}
private void btnExit_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void txtTel_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
e.Handled=e.KeyChar<'0'||e.KeyChar>'9';
if(e.KeyChar==(char)8)
e.Handled=false;
}
private void txtName_Leave(object sender, System.EventArgs e)
{
if(this.txtName.Text.Length==0)
{
MessageBox.Show("姓名不能为空","提示:");
this.txtName.Focus();
}
}
private void txtTel_Leave(object sender, System.EventArgs e)
{
if(this.txtTel.Text.Length<11||this.txtTel.Text.Length==0)
{
MessageBox.Show("手机号码为空或输入错误,请重新输入!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
this.txtTel.Clear();
this.txtTel.Focus();
}
}
private void txtName_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
e.Handled=e.KeyChar<'a'||e.KeyChar>'z';
if(e.KeyChar==(char)8)
e.Handled=false;
}
private void txtName_TextChanged(object sender, System.EventArgs e)
{
}
private void timer1_Tick(object sender, System.EventArgs e)
{
if (this.Opacity < 1)
{
this.Opacity += 0.03;
}
else
{
timer1.Enabled = false;
}
}
private void notifyIcon1_Click(object sender, System.EventArgs e)
{
}
private void menuItem1_Click(object sender, System.EventArgs e)
{
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
if(MessageBox.Show("你要退出吗?","提示:",MessageBoxButtons.YesNo)==DialogResult.Yes)
{
Application.Exit();
}
else
{
return;
}
}
private void menuItem4_Click(object sender, System.EventArgs e)
{
this.skinEngine1.SkinFile = "vista1.ssk";
}
private void menuItem5_Click(object sender, System.EventArgs e)
{
this.skinEngine1.SkinFile = "Vista2_color1.ssk";
}
private void menuItem6_Click(object sender, System.EventArgs e)
{
this.skinEngine1.SkinFile = "XPOrange.ssk";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -