public ActionResult Login(LoginDto objloginDto) { string s = null; try { LoginManager objLoginManager = new LoginManager(); ParticipantDto objReturn = new ParticipantDto(); objReturn = objLoginManager.CheckLogin(objloginDto); if (objReturn.Email != null) { Session["Uid"] = objReturn.UserID; Session["UserName"] = objReturn.FirstName + " " + objReturn.LastName; return(RedirectToAction("Index")); } else { return(Content("Invalid Username/Password")); } } catch (Exception ex) { s = ex.Message; s += ex.Source; s += ex.InnerException.Message; } return(Content(s)); }
private void loginButton_Click(object sender, EventArgs e) { User aUser = new User(); aUser.UserName = userNameTextBox.Text; aUser.Password = passwordTextBox.Text; if (userNameTextBox.Text == String.Empty) { messageLabel.Text = "Enter username."; } else if (passwordTextBox.Text == String.Empty) { messageLabel.Text = "Enter password."; } else { bool isLoginOk = aLoginManager.CheckLogin(aUser); if (isLoginOk) { MessageBox.Show("Welcome " + aUser.UserName); this.Hide(); HomeUI aHomeUi = new HomeUI(aUser.UserName); aHomeUi.Show(); } else { messageLabel.Text = "Username or Password incorrect"; } } }
public ActionResult Login(LoginDto objloginDto) { LoginManager objLoginManager = new LoginManager(); if (objLoginManager.CheckLogin(objloginDto)) { return(RedirectToAction("Index")); } else { return(Content("Invalid Username/Password")); } }
private void loginButton_Click(object sender, EventArgs e) { if (this.idloginText.TextLength == 0 || this.passloginText.TextLength == 0) { statusLogin.Visible = true; this.statusLogin.ForeColor = Color.Red; this.statusLogin.Text = "Enter your id and password"; } else { DataTable dt = new DataTable(); dt = lm.CheckLogin(this.idloginText.Text, this.passloginText.Text); if (dt.Rows.Count > 0) { idLabel.Visible = false; passLabel.Visible = false; idloginText.Visible = false; passloginText.Visible = false; loginButton.Visible = false; statusLogin.Visible = false; logoutButton.Visible = true; sellButton.Visible = true; position = dt.Rows[0][2].ToString(); if (dt.Rows[0][2].ToString() == "Supervisor" || dt.Rows[0][2].ToString() == "Owner") { staffButton.Visible = true; shopButton.Visible = true; stockButton.Visible = true; } else { staffButton.Visible = false; shopButton.Visible = false; stockButton.Visible = false; } } else { statusLogin.Visible = true; this.statusLogin.ForeColor = Color.Red; this.statusLogin.Text = "Account doesn't exists"; } } }
private void btnLogin_Click(object sender, EventArgs e) { if (txtLoginName.Text.Trim() == "") { MessageBox.Show("账号输入不能为空"); txtLoginName.Focus(); } else if (txtLoginPwd.Text.Trim() == "") { MessageBox.Show("密码不可为空"); txtLoginPwd.Focus(); } else if (!LoginManager.CheckLogin(this.txtLoginName.Text.Trim(), this.txtLoginPwd.Text.Trim())) { MessageBox.Show("用户名或密码不存在!", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { MainForm mainForm = new MainForm(); mainForm.Show(); this.Hide(); } }
private void loginBtn_Click(object sender, EventArgs e) { #region 登录逻辑 if (string.IsNullOrEmpty(this.comboBox1.Text.Trim())) { toolTip1.Show("请输入用户名!", this.comboBox1, 1000); this.comboBox1.Focus(); return; } if (string.IsNullOrEmpty(this.pwdTbx.Text)) { toolTip1.Show("请输入密码!", this.pwdTbx, 1000); this.pwdTbx.Focus(); return; } //登录 try { bool flag = LoginManager.CheckLogin(new LoginUser(this.comboBox1.Text, this.pwdTbx.Text)); if (flag) { //保存登录名及密码 login_name = this.comboBox1.Text.Trim(); login_pro = LoginManager.GetPro(login_name); mainForm.Enabled = true; mainForm.label1.Visible = true; mainForm.label13.Text = login_name; mainForm.label13.Visible = true; mainForm.label3.Visible = true; if (login_pro == "0") { mainForm.pro.Visible = true; mainForm.pro.Text = "管理员"; } if (login_pro == "1") { mainForm.pro.Visible = true; mainForm.pro.Text = "普通用户"; } this.Hide(); //先读取 判断文件中有无 该name 有则不写 没有再写入 防止重复 string rs = Read(path); if (rs.Contains(login_name)) { //配置文件已有该name 不再写入 登录即可 } else { //写入 try { StreamWriter sw = new StreamWriter(path, true);//加true 则逐行追加 否则会替换原来的数据 只保存一行 sw.WriteLine(login_name); sw.Dispose(); } catch (Exception) { MessageBox.Show("未找到配置文件或文件被占用"); } } } else { MessageBox.Show(" Sorry! 用户名或密码输入错误。", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (SqlException ex) { MessageBox.Show("数据库异常:" + ex.Message); } #endregion }
public ActionResult CheckLogin(Employee emp) { LoginManager login = new LoginManager(); return(Json(login.CheckLogin(emp))); }
public bool CheckLogin(Register register) { LoginManager login = new LoginManager(); return(login.CheckLogin(register)); }