public ActionResult RegisterView(UserInformation info) { rusername = info.Username; rpwd = info.Password; rloginID = info.LoginID; remail = info.Email; rqq = info.QQ; rtel = info.Tel; rtime = DateTime.Now.ToString(); ViewData["regtest"] = info; /*string text1 = "insert into user_information (username,loginID,password,flag,email,qq,tel,registertime,type1) values ('" + rusername + "','" + rloginID + "','" + rpwd + "',1,'" + remail + "','" + rqq + "','" + rtel + + "','" + rtime + "','员工')"; + Response.Write("<script>alert('" + text1 + "');</script>");*/ try { RegisterConn.Open(); string rpwd1 = MD5Str.MD5(rpwd); MySqlCommand RegisterCmd = RegisterConn.CreateCommand(); RegisterCmd.CommandText = "insert into user_information (username,loginID,password,flag,email,qq,tel,registertime,type1) values ('" + rusername + "','" + rloginID + "','" + rpwd1 + "',1,'" + remail + "','" + rqq + "','" + rtel + "','" + rtime + "','员工')"; int res = 0; res = RegisterCmd.ExecuteNonQuery(); if (res > 0) { res = 0; RegisterCmd.CommandText = "insert into user (username,password,name,type1) values ('" + rusername + "','" + rpwd1 + "','" + rloginID + "','员工')"; res = RegisterCmd.ExecuteNonQuery(); if (res > 0) { Response.Write("<script>alert('Register Success.');</script>"); RegisterConn.Close(); return(RedirectToAction("RegSuccess")); } } return(View()); } catch (Exception exception) { string ex = exception.ToString(); //return View(ex); return(RedirectToAction("RegFailed")); //MessageBox.Show(exception.ToString(), "异常提示"); //mySqlConnector.Close(); //MessageBox.Show("数据库连接异常!","异常提示"); } }
public ActionResult UpdateView(UserInformation updateUser) { HttpCookie ReadCookie = Request.Cookies.Get("Remeuser"); u_username = ReadCookie.Values["UserName"].ToString(); upwd = updateUser.Password; uloginID = updateUser.LoginID; uemail = updateUser.Email; uqq = updateUser.QQ; utel = updateUser.Tel; string upwd2 = MD5Str.MD5(upwd); string text = "update user_information set password = '******',loginID = '" + uloginID + "',email = '" + uemail + "',qq = '" + uqq + "',tel = '" + utel + "' where username = '******'"; //Response.Write("<script>alert(' 到底bug在哪呢? ');</script>"); Response.Write("<script>alert(' name,loginID = " + u_username + "');</script>"); ViewBag.MysqlText = text.ToString(); try { //Response.Write("<script>alert(' name,loginID = " + u_username + "," + uloginID + "');</script>"); UpdateConn.Open(); string upwd1 = MD5Str.MD5(upwd); MySqlCommand updateInfoCmd = UpdateConn.CreateCommand(); updateInfoCmd.CommandText = "update user_information set password = '******',loginID = '" + uloginID + "',email = '" + uemail + "',qq = '" + uqq + "',tel = '" + utel + "' where username = '******'"; int res = 0; res = updateInfoCmd.ExecuteNonQuery(); if (res > 0) { res = 0; updateInfoCmd.CommandText = "update user set password = '******',name = '" + uloginID + "' where username = '******'"; res = updateInfoCmd.ExecuteNonQuery(); if (res > 0) { HttpCookie RememberCookie = new HttpCookie("RemeUser"); RememberCookie["UserName"] = u_username; RememberCookie["UserPwd"] = upwd; Response.Cookies.Add(RememberCookie); //Response.Write("<script>alert('Update User's Info Success.');</script>"); UpdateConn.Close(); return(RedirectToAction("UpdateSuccess")); } } else { UpdateConn.Close(); return(RedirectToAction("UpdateFailed")); } return(View()); } catch (Exception e) { string ss = e.ToString(); Console.WriteLine(ss); return(View(ss)); //return RedirectToAction("UpdateFailed"); throw; } return(View()); }
public ActionResult AdminLoginExcessive(Admin_Info info) { au1 = info.Username; ap1 = info.Password; try { loginConnection.Open(); MySqlCommand CheckLoginCmd = loginConnection.CreateCommand(); CheckLoginCmd.CommandText = "select * from admin_userinfo where adminname = '" + au1 + "'"; MySqlDataReader CheckLoginReader = CheckLoginCmd.ExecuteReader(); string pwd11 = MD5Str.MD5(ap1); while (CheckLoginReader.Read()) { ap2 = CheckLoginReader["password"].ToString(); } if (ap2 == pwd11) { //Session["uinfo"] = user; //ViewData["test1"] = user; HttpCookie RememberCookie = new HttpCookie("RemeAdminUser"); RememberCookie["UserName"] = au1; RememberCookie["UserPwd"] = ap1; RememberCookie.Expires = DateTime.Now.AddDays(3); //RememberCookie.Value = "username"; //RememberCookie.Expires = DateTime.Now; Response.Cookies.Add(RememberCookie); //Response.Write("<script>alert('"+ RemCheck.ToString() + "');</script>"); loginConnection.Close(); return(RedirectToAction("../BackManager/Index")); /*else * { * HttpCookie RememberCookie = new HttpCookie("RemeUser"); * * RememberCookie.Expires = DateTime.Now.AddDays(-1); * * * Response.Cookies.Add(RememberCookie); * Response.Write("<script>alert('Login Success.');</script>"); * loginConnection.Close(); * }*/ } else { //return RedirectToAction("Index"); //Response.Write("<script>alert('Login Failed,your username or password is error.');</script>"); loginConnection.Close(); return(RedirectToAction("ErrorView")); } return(View()); } catch (Exception exception) { string ex = exception.ToString(); return(View(ex)); //return RedirectToAction("ErrorView"); } //return View(); }
public ActionResult LoginPage(User user) { name1 = user.Username; pwd1 = user.Password; if (name1 == "" || pwd1 == "") { //Response.Write("<script>alert('Login Failed,your username or password can not be empty!');</script>"); return(RedirectToAction("ErrorView")); } try { loginConnection.Open(); MySqlCommand CheckLoginCmd = loginConnection.CreateCommand(); CheckLoginCmd.CommandText = "select * from user where username = '******'"; MySqlDataReader CheckLoginReader = CheckLoginCmd.ExecuteReader(); string pwd11 = MD5Str.MD5(pwd1); while (CheckLoginReader.Read()) { pwd2 = CheckLoginReader["password"].ToString(); } if (pwd2 == pwd11) { //Session["uinfo"] = user; ViewData["test1"] = user; HttpCookie RememberCookie = new HttpCookie("RemeUser"); RememberCookie["UserName"] = name1; RememberCookie["UserPwd"] = pwd1; RememberCookie.Expires = DateTime.Now.AddDays(3); //RememberCookie.Value = "username"; //RememberCookie.Expires = DateTime.Now; Response.Cookies.Add(RememberCookie); //Response.Write("<script>alert('"+ RemCheck.ToString() + "');</script>"); loginConnection.Close(); return(RedirectToAction("../MemberLogon/Jumpto")); /*else * { * HttpCookie RememberCookie = new HttpCookie("RemeUser"); * * RememberCookie.Expires = DateTime.Now.AddDays(-1); * * * Response.Cookies.Add(RememberCookie); * Response.Write("<script>alert('Login Success.');</script>"); * loginConnection.Close(); * }*/ } else { //return RedirectToAction("Index"); //Response.Write("<script>alert('Login Failed,your username or password is error.');</script>"); loginConnection.Close(); return(RedirectToAction("ErrorView")); } return(View()); } catch (Exception exception) { string ex = exception.ToString(); //return View(ex); return(RedirectToAction("ErrorView")); } }