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();}}}

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功