您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > C#登录窗口代码-有图
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Data.OleDb;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.Data.SqlClient;usingSystem.IO;namespaceAC{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}privatevoidbutton1_Click(objectsender,EventArgse){stringuname=this.textBox1.Text.ToString();stringupassword=this.textBox2.Text.ToString();SqlConnectionthisconnection=newSqlConnection(@Server=SQL连接名;IntegratedSecurity=True;+DataBase=数据库名);thisconnection.Open();SqlCommandthiscommand=thisconnection.CreateCommand();thiscommand.CommandText=selectID,PSfrom表名whereID='+uname+';SqlDataReaderthisreader=thiscommand.ExecuteReader();if(thisreader.Read()){if(thisreader[PS].ToString().Trim()==upassword){MessageBox.Show(恭喜您登陆成功!,登陆成功!,MessageBoxButtons.OK,MessageBoxIcon.Information);//yhxxtt=newyhxx();//tt.Show();//this.Close();//关闭当前窗体//newForm1().Hide();this.Visible=false;//当前窗口不可见newForm2().Show();//form2显示newForm2().Show();}else{this.textBox2.Text=;MessageBox.Show(密码错误,请重新输入!,错误,MessageBoxButtons.OK,MessageBoxIcon.Information);}}else{this.textBox1.Text=;this.textBox2.Text=;MessageBox.Show(此用户不存在,请您注册!,注册,MessageBoxButtons.OK,MessageBoxIcon.Information);}thisconnection.Close();thisreader.Close();}//this.Visible=false;//当前窗口不可见//newForm2().Show();//form2显示privatevoidtextBox2_TextChanged(objectsender,EventArgse){}privatevoidgroupBox1_Enter(objectsender,EventArgse){}privatevoidbutton2_Click(objectsender,EventArgse){//this.Visible=false;//当前窗口不可见//newForm2().Show();//form2显示//this.Close();//关闭当前窗体//newForm2().Show();//Form2.show{};//this.Dispose();//释放内存,比第一个好。Application.Exit();//关闭整个程序}privatevoidbutton3_Click(objectsender,EventArgse){this.Visible=false;newForm2().Show();}privatevoidbutton4_Click(objectsender,EventArgse){newForm5().Show();}}}
本文标题:C#登录窗口代码-有图
链接地址:https://www.777doc.com/doc-4694417 .html