📄 loan.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
namespace timuku
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.RadioButton optongxue;
private System.Windows.Forms.RadioButton opguanliyuan;
private System.Windows.Forms.TextBox txtadmin;
private System.Windows.Forms.TextBox txtpass;
private OleDbConnection conn = null;
private OleDbCommand comm=null;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// 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.button1 = new System.Windows.Forms.Button();
this.optongxue = new System.Windows.Forms.RadioButton();
this.txtadmin = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.txtpass = new System.Windows.Forms.TextBox();
this.opguanliyuan = new System.Windows.Forms.RadioButton();
this.button2 = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(26, 189);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(64, 32);
this.button1.TabIndex = 12;
this.button1.Text = "确定 ";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// optongxue
//
this.optongxue.Location = new System.Drawing.Point(42, 149);
this.optongxue.Name = "optongxue";
this.optongxue.Size = new System.Drawing.Size(64, 24);
this.optongxue.TabIndex = 10;
this.optongxue.Text = "同学";
this.optongxue.CheckedChanged += new System.EventHandler(this.optongxue_CheckedChanged);
//
// txtadmin
//
this.txtadmin.Location = new System.Drawing.Point(90, 53);
this.txtadmin.Name = "txtadmin";
this.txtadmin.Size = new System.Drawing.Size(192, 21);
this.txtadmin.TabIndex = 8;
this.txtadmin.Text = "";
//
// label1
//
this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.Location = new System.Drawing.Point(10, 45);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(64, 32);
this.label1.TabIndex = 5;
this.label1.Text = "用户名";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.Location = new System.Drawing.Point(10, 101);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 32);
this.label2.TabIndex = 6;
this.label2.Text = "密 码";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// txtpass
//
this.txtpass.Location = new System.Drawing.Point(90, 101);
this.txtpass.Name = "txtpass";
this.txtpass.PasswordChar = '*';
this.txtpass.Size = new System.Drawing.Size(192, 21);
this.txtpass.TabIndex = 7;
this.txtpass.Text = "";
//
// opguanliyuan
//
this.opguanliyuan.Location = new System.Drawing.Point(170, 149);
this.opguanliyuan.Name = "opguanliyuan";
this.opguanliyuan.Size = new System.Drawing.Size(64, 24);
this.opguanliyuan.TabIndex = 9;
this.opguanliyuan.Text = "管理员";
this.opguanliyuan.CheckedChanged += new System.EventHandler(this.opguanliyuan_CheckedChanged);
//
// button2
//
this.button2.Location = new System.Drawing.Point(162, 189);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(64, 32);
this.button2.TabIndex = 11;
this.button2.Text = "退出";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// groupBox1
//
this.groupBox1.Location = new System.Drawing.Point(18, 133);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(264, 48);
this.groupBox1.TabIndex = 13;
this.groupBox1.TabStop = false;
//
// label3
//
this.label3.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label3.Location = new System.Drawing.Point(24, 16);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(256, 24);
this.label3.TabIndex = 14;
this.label3.Text = "登陆界面";
this.label3.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.label3.Click += new System.EventHandler(this.label3_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(288, 238);
this.Controls.Add(this.label3);
this.Controls.Add(this.button1);
this.Controls.Add(this.optongxue);
this.Controls.Add(this.txtadmin);
this.Controls.Add(this.label1);
this.Controls.Add(this.label2);
this.Controls.Add(this.txtpass);
this.Controls.Add(this.opguanliyuan);
this.Controls.Add(this.button2);
this.Controls.Add(this.groupBox1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
if(opguanliyuan.Checked)
{
string pass=txtpass.Text;
this.conn=new OleDbConnection();
conn.ConnectionString=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=score.mdb ";
string sqlstring="Select count(*) as num From passworld where 用户名='admin'and 密码='"+pass+"'";
this.comm=new OleDbCommand(sqlstring,conn);
conn.Open();
OleDbDataReader dr=comm.ExecuteReader();
dr.Read();
txtpass.Text="";
int cc=(int)(dr["num"]);
if (cc==0)
{
MessageBox.Show("用户名或者密码输入错误!请重新输入!");
}
else
{
guanliyuan gly=new guanliyuan();
gly.Show();
}
conn.Close();
}
if(optongxue.Checked)
{
string user=txtadmin.Text; //定义用户名
string pass=txtpass.Text;//定义密码
this.conn=new OleDbConnection(); //连接数据库
conn.ConnectionString=@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=score.mdb "; //连接数据库score表
string sqlstring="Select count(*) as num From passworld where 用户名='"+user+"'and 密码='"+pass+"'";//利用SQL里面的语言进行控制用户名和密码
this.comm=new OleDbCommand(sqlstring,conn);//数据库识别器
conn.Open();//打开
OleDbDataReader dr=comm.ExecuteReader();//重载数据源
dr.Read(); //开始读记录
txtpass.Text="";
int ss=(int)(dr["num"]); //控制刚才的记录
if (ss==0)//输入的记录是否和数据库表里的记录相等
{
MessageBox.Show("用户名或者密码输入错误!请重新输入!");
}
else
{//正确跳转到xuesheng窗体界面中
xuesheng r=new xuesheng();
r.Show();
}
conn.Close();//关闭数据库连接
}
}
private void opguanliyuan_CheckedChanged(object sender, System.EventArgs e)
{
txtadmin.Text="admin"; //显示管理员的名称
}
private void optongxue_CheckedChanged(object sender, System.EventArgs e)
{
txtadmin.Text="汤定潭";
}
private void button2_Click(object sender, System.EventArgs e)
{
this.Close(); //关闭窗体
}
private void label3_Click(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -