private void 强制命令ToolStripMenuItem_Click(object sender, EventArgs e) { string getEmployee = "select enum, position, username, password from employee"; SqlDataAdapter adapter = new SqlDataAdapter(getEmployee, HotelCon); dataset.Clear(); adapter.Fill(dataset, "employee"); if (Program.currentId == "") { MessageBox.Show("请先登录", "提示"); } else { bool admin = false; for (int i = 0; i < dataset.Tables["employee"].Rows.Count; i++) { string num = dataset.Tables["employee"].Rows[i][0].ToString().Trim(); string position = dataset.Tables["employee"].Rows[i][1].ToString().Trim(); if (Program.currentId == num && (position == "总经理" || position == "管理员")) { changestyle(); BackgroundImage = Properties.Resources.big; admin = true; panel1.Controls.Clear(); forceManage fm = new forceManage { TopLevel = false, FormBorderStyle = FormBorderStyle.None }; panel1.Controls.Add(fm); fm.Show(); break; } } if (!admin) { this.panel1.Controls.Clear(); adminLogin al = new adminLogin(1); al.ShowDialog(this); } } }
private void button1_Click(object sender, EventArgs e) { if (sta == 1)//修改房价状态时的验证 { bool flag = false; for (int i = 0; i < dataset.Tables["employee"].Rows.Count; i++) { string username = dataset.Tables["employee"].Rows[i][2].ToString().Trim(); string password = dataset.Tables["employee"].Rows[i][3].ToString().Trim(); string position = dataset.Tables["employee"].Rows[i][1].ToString().Trim(); if (textBox1.Text == username && textBox2.Text == password && (position == "总经理" || position == "管理员")) { flag = true; forceManage fm = new forceManage { TopLevel = false, FormBorderStyle = FormBorderStyle.None }; Form_home fh = (Form_home)Owner; fh.BackgroundImage = Properties.Resources.big; fh.panel1.Controls.Clear(); fh.panel1.Controls.Add(fm); fh.changestyle(); fm.Show(); Close(); break; } } if (!flag) { MessageBox.Show("账号或密码错误", "警告"); textBox1.Text = textBox2.Text = ""; } } if (sta == 2) //修改密码时的验证 { bool flag = false; for (int i = 0; i < dataset.Tables["employee"].Rows.Count; i++) { string username = dataset.Tables["employee"].Rows[i][2].ToString().Trim(); string password = dataset.Tables["employee"].Rows[i][3].ToString().Trim(); string position = dataset.Tables["employee"].Rows[i][1].ToString().Trim(); if (textBox1.Text == username && textBox2.Text == password && (position == "总经理" || position == "管理员")) { flag = true; changePassword cp = new changePassword { TopLevel = false, FormBorderStyle = FormBorderStyle.None }; Form_home fh = (Form_home)Owner.Owner; fh.panel1.Controls.Clear(); fh.panel1.Controls.Add(cp); fh.BackgroundImage = Properties.Resources.big; fh.changestyle(); cp.Show(); Close(); break; } } if (!flag) { MessageBox.Show("账号或密码错误", "警告"); textBox1.Text = textBox2.Text = ""; } } }