问题描述
- 修改密码的模块如何插入主程序?是visual studi
- 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 (cstrconn ); 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(); } } }
解决方案
你主程序中找到用户登录窗体,然后添加一个按钮,粘贴进去。
时间: 2024-12-23 05:03:52