目 录
摘要………………………………………………………………………………………………1
一 绪论………………………………………………………………………………………1

2.2.1系统功能模块设计

2.2.2数据流程图
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
//download by http://www.codefans.net
namespace CkglS1
{
///
/// login 的摘要说明。
///
public class login : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox text1;
private System.Windows.Forms.TextBox text2;
///
/// 必需的设计器变量。
///
private System.ComponentModel.Container components = null;
public login()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
///
/// 清理所有正在使用的资源。
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
///
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
///
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(login));
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.text2 = new System.Windows.Forms.TextBox();
this.text1 = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(-3, -2);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(241, 100);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.text2);
this.groupBox1.Controls.Add(this.text1);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.groupBox1.Location = new System.Drawing.Point(5, 104);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(242, 89);
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
//
// text2
//
this.text2.Location = new System.Drawing.Point(77, 53);
this.text2.Name = "text2";
this.text2.PasswordChar = '*';
this.text2.Size = new System.Drawing.Size(156, 21);
this.text2.TabIndex = 3;
this.text2.Text = "123456";
//
// text1
//
this.text1.Location = new System.Drawing.Point(77, 20);
this.text1.Name = "text1";
this.text1.Size = new System.Drawing.Size(156, 21);
this.text1.TabIndex = 2;
this.text1.Text = "admin";
//
// label2
//
this.label2.Location = new System.Drawing.Point(6, 56);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 15);
this.label2.TabIndex = 1;
this.label2.Text = "密 码:";
//
// label1
//
this.label1.Location = new System.Drawing.Point(6, 26);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(64, 15);
this.label1.TabIndex = 0;
this.label1.Text = "用户名:";
//
// button1
//
this.button1.Location = new System.Drawing.Point(82, 199);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 2;
this.button1.Text = "登录";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(163, 199);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 3;
this.button2.Text = "退出";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// login
//
this.AcceptButton = this.button1;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(259, 228);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.pictureBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "login";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "用户登录";
this.Closed += new System.EventHandler(this.login_Closed);
this.Load += new System.EventHandler(this.login_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
public bool _log=false;
int _count=0;
private void button2_Click(object sender, System.EventArgs e)
{
Application.Exit();
}
private void button1_Click(object sender, System.EventArgs e)
{
if(text1.Text=="")
{
MessageBox.Show("请输入用户名。","登录提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
text1.Focus();
}
else
{
_count++;
string _name,_pass;
_name=text1.Text.Trim();
_pass=text2.Text.Trim();
c_form.myad=new SqlDataAdapter("select pass from yh where name='"+_name+"'",c_form.conn);
c_form.myad.Fill(c_form.mydata,"yhdl");
if(c_form.mydata.Tables["yhdl"].Rows.Count==0)
{
if(_count==3)
{
MessageBox.Show("输入三次错误,自动退出登录。","登录提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
Application.Exit();
}
else
{
MessageBox.Show("用户名错误,请重新输入。","登录提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
text1.Focus();
}
}
else
{
string _passstr=c_form.mydata.Tables["yhdl"].Rows[0][0].ToString().Trim();
if(_passstr!=_pass)
{
if(_count==3)
{
MessageBox.Show("输入三次错误,自动退出登录。","登录提示",MessageBoxButtons.OK,MessageBoxIcon.Stop);
Application.Exit();
}
else
{
MessageBox.Show("密码错误,请重新输入。","登录提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
text1.Focus();
}
}
else
{
c_form._name=_name;
_log=true;
this.Close();
}
}
}
}
private void login_Closed(object sender, System.EventArgs e)
{
c_form.mydata.Tables.Clear();
if(_log==false)
Application.Exit();
}
private void login_Load(object sender, EventArgs e)
{
}
}
}

















