protected void btn_Register_Click(object sender, EventArgs e) { AdminInfoBLL aib = new AdminInfoBLL(); SuperAdminInfoBLL saib = new SuperAdminInfoBLL(); List <AdminInfoModel> lAim = aib.GetAdminInfon(); List <SuperAdminInfoModel> lSaim = saib.GetSuperAdminInfo(); //用于判断用户是否存在 bool isRegistered = false; //信息不为空 if (tb_AdminName.Text != "" && tb_Password.Text != "" && tb_Confirm.Text != "" && tb_SAdminName.Text != "" && tb_SPassword.Text != "") { //判断用户名是否存在 for (int i = 0; i < lAim.Count; i++) { if (tb_AdminName.Text == lAim[i].AdminName) { isRegistered = true; } } //用户不存在 if (!isRegistered) { //两次密码一致 if (tb_Password.Text == tb_Confirm.Text) { for (int j = 0; j < lSaim.Count; j++) { //超级管理员用户和密码正确 if (tb_SAdminName.Text == lSaim[j].SAdminName && tb_SPassword.Text == lSaim[j].SPassword) { aib.AddAdmin(tb_AdminName.Text, tb_Password.Text); Response.Write(@"<script>alert('注册成功');</script>"); Response.Write(@"<script>location.href='Login.aspx';</script>"); } //超级管理员用户和密码错误 else { Response.Write(@"<script>alert('超级管理员用户或密码错误');</script>"); } } } //两次密码不一致 else { Response.Write(@"<script>alert('两次输入的密码不一致');</script>"); } } //用户存在 else { Response.Write(@"<script>alert('该用户已存在');</script>"); } } //信息为空 else { Response.Write(@"<script>alert('请将输入完整信息');</script>"); } }
private void btn_Login_Click(object sender, EventArgs e) { AdminInfoBLL aib = new AdminInfoBLL(); List <AdminInfoModel> lAim = aib.GetAdminInfon(); //用于判断用户名是否正确 bool isAdminExit = false; //用于判断密码是否正确 bool isPasswordRight = false; //用户名和密码不为空 if (tb_AdminName.Text != "" && tb_Password.Text != "") { for (int i = 0; i < lAim.Count; i++) { //判断用户名是否正确 if (tb_AdminName.Text == lAim[i].AdminName) { isAdminExit = true; } } if (isAdminExit) //用户名存在(用户名填写正确) { for (int j = 0; j < lAim.Count; j++) { if (tb_Password.Text == lAim[j].Password) //判断密码是否正确 { isPasswordRight = true; } } if (isPasswordRight)//密码正确 { this.Hide(); new Form_StdInfo().ShowDialog(); Application.ExitThread(); } else//密码错误 { MessageBox.Show("密码错误"); } } else //用户名不存在(用户名填写错误) { MessageBox.Show("该用户不存在,请检查用户名是否正确"); } } else //用户名或密码为空 { MessageBox.Show("请输入用户名或密码"); } }
protected void btn_Login_Click(object sender, EventArgs e) { AdminInfoBLL aib = new AdminInfoBLL(); List <AdminInfoModel> lAim = aib.GetAdminInfon(); //用于判断用户名是否正确 bool isAdminExit = false; //用于判断密码是否正确 bool isPasswordRight = false; //用户名和密码不为空 if (tb_AdminName.Text != "" && tb_Password.Text != "") { for (int i = 0; i < lAim.Count; i++) { //判断用户名是否正确 if (tb_AdminName.Text == lAim[i].AdminName) { isAdminExit = true; } } if (isAdminExit) //用户名存在(用户名填写正确) { for (int j = 0; j < lAim.Count; j++) { if (tb_Password.Text == lAim[j].Password) //判断密码是否正确 { isPasswordRight = true; } } if (isPasswordRight)//密码正确 { Response.Write(@"<script>location.href='Handler_ShowStdInfo.ashx';</script>"); } else//密码错误 { Response.Write(@"<script>alert('密码错误');</script>"); } } else //用户名不存在(用户名填写错误) { Response.Write(@"<script>alert('该用户不存在,请检查用户名是否正确');</script>"); } } else //用户名或密码为空 { Response.Write(@"<script>alert('请输入用户名或密码');</script>"); } }
private void btn_Register_Click(object sender, EventArgs e) { AdminInfoBLL aib = new AdminInfoBLL(); SuperAdminInfoBLL saib = new SuperAdminInfoBLL(); List <AdminInfoModel> lAim = aib.GetAdminInfon(); List <SuperAdminInfoModel> lSaim = saib.GetSuperAdminInfo(); //用于判断用户是否存在 bool isRegistered = false; //信息不为空 if (tb_AdminName.Text != "" && tb_Password.Text != "" && tb_Confirm.Text != "" && tb_SAdminName.Text != "" && tb_SPassword.Text != "") { //判断用户名是否存在 for (int i = 0; i < lAim.Count; i++) { if (tb_AdminName.Text == lAim[i].AdminName) { isRegistered = true; } } //用户不存在 if (!isRegistered) { //两次密码一致 if (tb_Password.Text == tb_Confirm.Text) { for (int j = 0; j < lSaim.Count; j++) { //超级管理员用户和密码正确 if (tb_SAdminName.Text == lSaim[j].SAdminName && tb_SPassword.Text == lSaim[j].SPassword) { aib.AddAdmin(tb_AdminName.Text, tb_Password.Text); MessageBox.Show("注册成功"); this.Hide(); new Form_Login().ShowDialog(); Application.ExitThread(); } //超级管理员用户和密码错误 else { MessageBox.Show("超级管理员用户或密码错误"); } } } //两次密码不一致 else { MessageBox.Show("两次输入的密码不一致"); } } //用户存在 else { MessageBox.Show("该用户已存在"); } } //信息为空 else { MessageBox.Show("请将输入完整信息"); } }