conn.Open(); if( txtname .Text==""||txtpassword .Text=="") MessageBox.Show ("请不要遗漏信息!"); if (rbtnmanager.Checked) { string cstr="select * from 用户登录 where 类别='管理员'and 用户名='"+txtname.Text.Trim ()+"'and 密码='"+txtpassword .Text.Trim ()+"'"; SqlCommand comm=new SqlCommand (cstr,conn ); SqlDataReader dr=comm.ExecuteReader (); if (dr.Read()) { sn = txtname.Text.Trim(); fr4.Show(); this.Visible = false; } else { MessageBox.Show("输入有误,请重新输入!"); txtname.Text = ""; txtpassword.Text = ""; } } if (rbtnteacher.Checked) { string cstr = "select * from 用户登录 where 类别='教师'and 用户名='" + txtname.Text.Trim() + "'and 密码='" + txtpassword.Text.Trim() + "'"; SqlCommand comm = new SqlCommand(cstr, conn); SqlDataReader dr = comm.ExecuteReader(); if (dr.Read()) { sn = txtname.Text.Trim(); sub = dr.GetValue(3).ToString (); fr3.Show(); this.Visible = false; } else { MessageBox.Show("输入有误,请重新输入!"); txtname.Text = ""; txtpassword.Text = ""; } } if (rbtnstudent.Checked) { string cstr = "select * from 用户登录 where 类别='学生'and 用户名='" + txtname.Text.Trim() + "'and 密码='" + txtpassword.Text.Trim() + "'"; SqlCommand comm = new SqlCommand(cstr, conn); SqlDataReader dr = comm.ExecuteReader(); if (dr.Read()) { sn = txtname.Text.Trim();fr2.Show(); this.Visible=false ; } else { MessageBox.Show("输入有误,请重新输入!"); txtname.Text = ""; txtpassword.Text = ""; } } conn.Close(); conn.Dispose(); } private void button2_Click(object sender, EventArgs e) { Application.Exit(); } private void timer1_Tick(object sender, EventArgs e) { label1.Text = "当前时间为:" +DateTime.Now .ToLongDateString() +" "+DateTime.Now.ToLongTimeString(); } } }
1条回答 默认 最新
- threenewbee 2015-12-29 03:55关注
你主程序中找到用户登录窗体,然后添加一个按钮,粘贴进去。
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 无线电能传输系统MATLAB仿真问题
- ¥50 如何用脚本实现输入法的热键设置
- ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
- ¥30 深度学习,前后端连接
- ¥15 孟德尔随机化结果不一致
- ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
- ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
- ¥15 谁有desed数据集呀
- ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
- ¥15 关于#hadoop#的问题