【发布时间】:2019-10-11 02:59:10
【问题描述】:
在表格 1 中
public void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=.\ALLENSQL;Initial Catalog=TITOMSLogin;Integrated Security=True");
SqlDataAdapter sdf = new SqlDataAdapter("select usertype, fullname, position from login where username= '" + txtuser.Text + "' and password='" + txtpass.Text + "'", con);
DataTable dt = new DataTable();
sdf.Fill(dt);
string fullname = dt.Rows[0]["FullName"].ToString();
string position = dt.Rows[0]["Position"].ToString();
if (dt.Rows.Count == 1)
{
this.Hide();
if (dt.Rows[0]["Usertype"].ToString() == "Admin")
{
Form2Admin ss = new Form2Admin(position + ": " + fullname);
Form3Admin sa = new Form3Admin(position + ": " + fullname);
Form5 sw = new Form5(position + ": " + fullname);
ss.Show();
sa.Hide();
sw.Hide();
}
现在此代码在其他形式中不起作用
private void button2_Click(object sender, EventArgs e)
{
this.Hide();
Form3Admin.Show();
}
这是我想要实现的场景:
- 按登录后form2会出现,form 3和form 4被隐藏。
- 按下表格 2 中的按钮(表格 2 将隐藏,表格 3 将显示)。
- 按下表格 3 中的按钮(表格 3 将隐藏,表格 4 将显示)。
- 按下表格 4 中的按钮(表格 4 将隐藏,表格 2 将显示,但之前写入的所有数据必须仍然存在)等等。
【问题讨论】: