新手求教
一个系统,进入登入界面后跳出别的界面,那个登入界面怎么自动关掉?private void Lobt_Login_Click(object sender, EventArgs e)
{
SqlConnection con = MysqlConnection();
con.Open();
String str = "select Uname ,Upass,Utype from S_user where Uname=@Uname and Upass=@Upass and Utype=@Utype";
SqlCommand sqlCommand1 = new SqlCommand(str,con);
if (Lotb_Uname.Text == "" || Lotb_Upass.Text == "" || Locb_Utype.Text == "")
{
MessageBox.Show("请将信息补充完整!");
}
else
{
try
{
sqlCommand1.Parameters.AddWithValue("@Uname", Lotb_Uname.Text);
sqlCommand1.Parameters.AddWithValue("@Upass", Lotb_Upass.Text);
sqlCommand1.Parameters.AddWithValue("@Utype", Locb_Utype.Text);
SqlDataReader sdr = sqlCommand1.ExecuteReader();
bool b = sdr.Read();
name = Lotb_Uname.Text;
if (b == false)
{
MessageBox.Show("输入错误!请重新输入!");
}
else
{
PersenInfo[] personInfo =
{
new StudentInfo (Lotb_Uname.Text, Lotb_Upass.Text),
new TeacherInfo(Lotb_Uname.Text, Lotb_Upass.Text),
new ManagerInfo(Lotb_Uname.Text, Lotb_Upass.Text),
};
if (Locb_Utype.Text == "管理员")
{
personInfo[2].Show();
}
else
{
if (Locb_Utype.Text == "学生")
{
// Student stu = new Student();
// stu.Show();
personInfo[0].Show();
}
else
{
//Teacher tea = new Teacher();
//tea.Show();
personInfo[1].Show();
}
}
}
sdr.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
sqlCommand1.Parameters.RemoveAt("@Uname");
sqlCommand1.Parameters.RemoveAt("@Upass");
sqlCommand1.Parameters.RemoveAt("@Utype");
con.Close();
}
}
Lotb_Uname.Text = "";
Lotb_Upass.Text = "";
Locb_Utype.Text = "";
}
在哪里加代码可以解决这个问题啊?
求高手指教。