首页 登陆界面代码[试题]

登陆界面代码[试题]

举报
开通vip

登陆界面代码[试题]登陆界面代码[试题] 登陆界面代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.OleDb; namespace WindowsFormsA...

登陆界面代码[试题]
登陆界面代码[试 快递公司问题件快递公司问题件货款处理关于圆的周长面积重点题型关于解方程组的题及答案关于南海问题 ] 登陆界面代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.OleDb; namespace WindowsFormsApplication1 { public partial class Form1 : Form { private static OleDbConnection oleConnection1 = null; OleDbConnection connection=new OleDbConnection("Data Source=itasset.mdb;Jet OLEDB:Engine Type=5;Provider=Microsoft.Jet.OLEDB.4.0;"); //获得数据库连接 public static OleDbConnection getConnection() { // if(oleConnection1==null) // { oleConnection1 = new OleDbConnection("Data Source=itasset.mdb;Jet OLEDB:Engine Type=5;Provider=Microsoft.Jet.OLEDB.4.0;"); oleConnection1.Open(); // } return oleConnection1; } public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { try { string mysql = "select * from userinfo where UserID = '" + comboBox1.Text + "' and Password= '" + textBox1.Text + "'"; //Sql查询语句 OleDbDataAdapter myada = new OleDbDataAdapter(mysql, connection); DataTable mydt = new DataTable(); myada.Fill(mydt); int i = mydt.Rows.Count; if (i >= 1) { Form2 myf = new Form2(); myf.Show(); this.closs(); //显示主界面 //myf.label1.Text = "欢迎 " + comboBox1.Text + " 登录主界面 ,其登录密码是: " + textBox1.Text; } else { MessageBox.Show("用户名或密码不正确,请重新输入~", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //提示对话框 comboBox1.Text = ""; textBox1.Text = ""; } } catch (Exception er) { MessageBox.Show(er.ToString()); } } private void Form1_Load(object sender, EventArgs e) { if (oleConnection1==null) oleConnection1=Form1.getConnection(); //取出系统的所有用户名 //显示在下拉列表,这样用户登录的时候 //选择用户名就可以了,不用再输入用户名了 string sql="select UserID from userinfo"; OleDbCommand cmd = new OleDbCommand(sql,oleConnection1); OleDbDataReader dr = cmd.ExecuteReader(); int flag = 0; while(dr.Read()) { this.comboBox1.Items.Add(dr.GetString(0)); flag++; } //如果系统存在用户,则默认选中第一个用户 if (flag>0) this.comboBox1.SelectedIndex=0; dr.Close(); cmd.Dispose(); } } }
本文档为【登陆界面代码[试题]】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_633808
暂无简介~
格式:doc
大小:16KB
软件:Word
页数:4
分类:企业经营
上传时间:2017-10-17
浏览量:18