欢迎来到天天文库
浏览记录
ID:15158414
大小:57.00 KB
页数:5页
时间:2018-08-01
《登录分级验证模块详细代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、登录分级验证模块详细代码连接数据库的类(自己编写的):conn.cs详细代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Data.SqlClient;namespaceWindowsApplication1{classconn{privatestringIP;privatestringDbName;privatestringDbUser;privatestringKey;publicconn(){//数据库服务器
2、名字:"3D470F5FC44F4EF",数据库名字:"testDB",登录数据库账号:"sa",登录数据库密码:"sa"IP="3D470F5FC44F4EF";DbName="testDB";DbUser="sa";Key="sa";}publicSqlConnectioncreatConn(){SqlConnectionthisConnection=newSqlConnection(@"Server="+IP+";userid="+DbUser+";initialcatalog="+DbName+";passwo
3、rd="+Key);thisConnection.Open();returnthisConnection;}}}登录主窗体:login.cs详细代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;5usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Data.SqlClient;namesp
4、aceWindowsApplication1{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}privatevoidbutton1_Click(objectsender,EventArgse){conncon=newconn();SqlConnectionsqlConnection=con.creatConn();SqlCommandcmd=newSqlCommand("SELECT*FROMLoginWHEREName='"+this
5、.textBox1.Text+"'andPwd='"+this.textBox2.Text+"'",sqlConnection);SqlDataReaderreader=cmd.ExecuteReader();stringdj="";stringdep="";stringpanduan="";if(reader.Read()){dj=(string)reader["dj"];dep=(string)reader["dep"];panduan=dep+dj;if(panduan=="系统管理系统管理员"){panduan
6、=dj;}if(panduan=="学工办学工领导"){panduan=dj;}MessageBox.Show("欢迎您,"+panduan+"","智能化管理系统提示");switch(panduan){case"系统管理员":5Form2frm=newForm2();frm.Show();this.Hide();break;case"学工领导":Form1frm1=newForm1();frm1.Show();this.Hide();break;case"生活权益部干事":Form1a=newForm1();a.S
7、how();this.Hide();break;case"生活权益部部长":Form2b=newForm2();b.Show();this.Hide();break;case"女生部部长":Form1c=newForm1();c.Show();this.Hide();break;case"女生部干事":Form1d=newForm1();d.Show();this.Hide();break;case"体育部部长":Form1bb=newForm1();bb.Show();this.Hide();break;case"体
8、育部干事":Form1f=newForm1();5f.Show();this.Hide();break;case"学习部部长":Form1g=newForm1();g.Show();this.Hide();break;case"学习部干事":Form1h=newForm1();h.Show();this.Hide();break;
此文档下载收益归作者所有