public ActionResult HomePage(userLogin login) { users usr = new users(); SqlConnection cn = new SqlConnection(); cn.ConnectionString = @"Data Source = (localdb)\MsSqlLocalDb; Initial Catalog = JKDec20; Integrated Security = True;"; cn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = "select * from users where LoginName =" + login.LoginName; SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { usr.UserId = Convert.ToInt32(dr["UserId"]); usr.LoginName = dr["LoginName"].ToString(); usr.Password = dr["Password"].ToString(); usr.FullName = dr["FullName"].ToString(); usr.Email = dr["Email"].ToString(); usr.CityId = Convert.ToInt32(dr["CityId"]); usr.Phone = dr["Phone"].ToString(); } dr.Close(); cn.Close(); return(View(usr)); }
protected void btnSave_Click(object sender, EventArgs e) { Dictionary <string, string> dic = initDatadic(); userLogin ul = new userLogin(); int intresult = 0; intresult = ul.update(dic, "userLogin", "username", username.Text.Trim()); initinfo(); Alert alert = new Alert(); if (intresult == 1) { alert.Icon = Icon.Information; alert.Message = "数据保存成功"; } else { alert.MessageBoxIcon = MessageBoxIcon.Error; alert.Message = "数据保存失败"; } alert.Show(); }
// public ActionResult Login(loginModel model) { if (ModelState.IsValid) { var dao = new userDao(); var result = dao.Login(model.userName, encryptor.MD5Hash(model.passWord)); if (result == 1) { var user = dao.getById(model.userName); var userSession = new userLogin(); userSession.userName = user.userName; userSession.userID = user.Id; Session.Add(commonConst.user_session, userSession); return(RedirectToAction("Index", "Home")); } else if (result == -2) { ModelState.AddModelError("", "Bạn không có quyền vào trang này !"); } else if (result == 0) { ModelState.AddModelError("", "Tài khoản không tồn tại !"); } else if (result == -1) { ModelState.AddModelError("", "Tài khoản đang bị khóa !"); } else { ModelState.AddModelError("", "Đăng nhập không đúng !"); } } return(View("Index")); }
public ActionResult Create([Bind(Include = "UserID,Name,Surname,Username,FK_TitleID,FK_GenderID,FK_RelationshipStatusIdn,FK_ActiveID,FK_CityID,LoginID, userLogin.UserPassword")] myUser myUser, string UserPassword) { userLogin ulogin = new userLogin(); var hasedValue = ComputeSha256Hash(UserPassword); string newHased = hasedValue.Substring(0, 49); if (ModelState.IsValid) { userLogin ul = new userLogin(); ul.UserPassword = newHased; ul.Username = myUser.Username; ul.LoginType = false; db.myUsers.Add(myUser); db.userLogins.Add(ul); db.SaveChanges(); return(RedirectToAction("TopicSelect", "BaeCoach")); } ViewBag.FK_ActiveID = new SelectList(db.Actives, "ActiveID", "ActiveDescription", myUser.FK_ActiveID); ViewBag.FK_CityID = new SelectList(db.Cities, "Id", "Name", myUser.FK_CityID); ViewBag.FK_GenderID = new SelectList(db.Genders, "GenderID", "GenderDescription", myUser.FK_GenderID); ViewBag.FK_RelationshipStatusIdn = new SelectList(db.RelationshipStatus, "RelationshipStatusID", "RelationshipStatusDescription", myUser.FK_RelationshipStatusIdn); ViewBag.FK_TitleID = new SelectList(db.Titles, "TitleID", "Titledescription", myUser.FK_TitleID); ViewBag.LoginID = new SelectList(db.userLogins, "UserLoginID", "Username", myUser.LoginID); return(View(myUser)); }
//[ValidateAntiForgeryToken] public async Task <IActionResult> Edit(int id, [FromBody] userLogin userLogin) { if (id != userLogin.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userLogin); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!userLoginExists(userLogin.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(userLogin)); }
//用户个人信息 protected void UserProfile_Click(object sender, EventArgs e) { userLogin ul = new userLogin(); System.Data.DataTable dt = ul.getUserinfo(SessionUserName); if (dt != null && dt.Rows.Count > 0) { DataRow r = dt.Rows[0]; string strUserinfo = "<div>" + "<p>" + "<a href =\"http://book.douban.com/subject/25943598/\" style = \"font-size: 18px\" target =\"_blank\"><b>" + r["fullname"].ToString().Trim() + "</b></a>" + "</p>" + "<p>出生于" + r["birdate"].ToString() + " 手机:" + r["telephone"].ToString() + " 家庭住址:" + r["address"].ToString() + "</p>" + "<p>" + "所属部门:" + r["department"].ToString() + " 工号:" + r["staffno"].ToString() + "</p></div>"; txtUserinfo.Text = Server.HtmlEncode(strUserinfo); windowUserInfo.Hidden = false; PageContext.RegisterStartupScript("refresh();"); } }
// U ovaj returnUrl spremamo stranicu s koje je user preusmjeren na login // ako želi pristupiti nekoj metodi koja zahtjeva da je prijavljeni,kad se prijavi // onda ga vraćamo na stranicu kojoj je htio pristupiti public ActionResult Login(string returnUrl) { userLogin user = new userLogin(); ViewBag.ReturnUrl = returnUrl; return(View()); }
public JsonResult GetAdminMess() { string adminmess = ""; if (Session[commonConst.user_client] != null) { userLogin a = Session[commonConst.user_client] as userLogin; ViewBag.Name = a.Name_user; } if (Session[commonConst.user_employee] != null) { userLogin a = Session[commonConst.user_employee] as userLogin; ViewBag.NameEmployee = a.Name_user; adminmess = a.Name_user; } var dao = new ChatDao(); var result = dao.getAllMessAdmin(adminmess); return(Json( result, JsonRequestBehavior.AllowGet )); }
public bool GetUserlogin(userLogin objuserLogin) { try { con = SqlConnectionBuilder.OpenSqlConnectiion(); query = "[dbo].[giveLoginAccess]"; ` com = new SqlCommand(query, con); com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@password", objuserLogin.Password); com.Parameters.AddWithValue("@userName", objuserLogin.userName); SqlDataAdapter adp = new SqlDataAdapter(); adp.SelectCommand = com; DataTable loginDT = new DataTable(); adp.Fill(loginDT); userLogin ObjUserlogin = new userLogin(); if (loginDT != null) { return(true); } else { return(false); } } catch (Exception ex) { throw ex; } }
public ActionResult IndexPost(userLogin users) { userLogin login = new userLogin(); if (ModelState.IsValid) { using (userContext db = new userContext()) { var user = db.userLogins.Where(x => x.uName.Equals(users.uName) && x.Password.Equals(users.Password)).FirstOrDefault(); if (user != null) { //Session["Username"] = users.uName; Session.Add("UserName", users.uName); FormsAuthentication.SetAuthCookie(users.uName, true); ViewBag.LoginSuccess = "Login Successfully"; return(RedirectToAction("Index", "Profile")); } else { ViewBag.LoginMessage = "Login Failed Username/Password incorrect"; return(View()); } } } return(View()); }
public UserRegistrationFormModel saveUserInfo([FromBody] UserRegistrationFormModel userRegistrationFM) { using (BlogEntities entities = new BlogEntities()) { user tmpUser = new user(); tmpUser.name = userRegistrationFM.firstName; tmpUser.lastname = userRegistrationFM.lastName; tmpUser.birthdate = userRegistrationFM.birthDate; tmpUser.created = userRegistrationFM.created; tmpUser.updated = userRegistrationFM.updated; tmpUser.status = userRegistrationFM.status; tmpUser.email = userRegistrationFM.email; userLogin tmpUserLogin = new userLogin(); tmpUserLogin.username = userRegistrationFM.userName; tmpUserLogin.password = userRegistrationFM.password; tmpUserLogin.user = tmpUser; entities.users.Add(tmpUser); entities.userLogins.Add(tmpUserLogin); entities.SaveChanges(); } return(userRegistrationFM); }
private void initinfo(string strID) { userLogin ul = new userLogin(); System.Data.DataTable dt = ul.getEditdata(strID); DataRow r = dt.Rows[0]; editID.Text = strID; fullname.Text = r["fullname"].ToString().Trim(); username.Text = r["username"].ToString().Trim(); password.Text = r["password"].ToString().Trim(); sex.SelectedValue = r["sex"].ToString().Trim(); department.SelectedValue = r["department"].ToString().Trim(); staffno.Text = r["staffno"].ToString().Trim(); DateTime seldate; if (System.DateTime.TryParse(r["birdate"].ToString().Trim(), out seldate)) { birdate.SelectedDate = seldate; } telephone.Text = r["telephone"].ToString().Trim(); address.Text = r["address"].ToString().Trim(); }
private void displaydetailinfo(string strID) { userLogin ul = new userLogin(); System.Data.DataTable dt = ul.getEditdata(strID); string strhtml = "空白详细信息"; if (dt != null && dt.Rows.Count > 0) { System.Data.DataRow r = dt.Rows[0]; strhtml = "<div style=\"line-height:27px;\">" + "姓名:" + r["fullname"].ToString().Trim() + "<br/>" + "部门:" + r["department"].ToString().Trim() + "<br/>" + "工号:" + r["staffno"].ToString().Trim() + "<br/>" + "账号:" + r["username"].ToString().Trim() + "<br/>" + "密码:" + r["password"].ToString().Trim() + "<br/>" + "性别:" + r["sex"].ToString().Trim() + "<br/>" + "生日:" + r["birdate"].ToString().Trim() + "<br/>" + "电话:" + r["telephone"].ToString().Trim() + "<br/>" + "<div style=\"word-break:break-all;\">地址:" + r["address"].ToString().Trim() + "</div>" + "注册人:" + r["regperson"].ToString().Trim() + "<br/>" + "日期:" + r["regdate"].ToString().Trim() + "<br/>" + "ID:" + r["ID"].ToString().Trim() + "<br/>" + "</div>"; } detailinfo.Text = strhtml; }
public ActionResult UserLogin(userLogin userLogin) { if (ModelState.IsValid) // this is check validity { using (Appoinment_Entities appoinment_Entities_db = new Appoinment_Entities()) { var userCredentials = appoinment_Entities_db.userLogins.Where(a => a.UserName.Equals(userLogin.UserName) && a.Password.Equals(userLogin.Password)).FirstOrDefault(); if (userCredentials != null) { Session["LogedUserID"] = userCredentials.UserID.ToString(); Session["LogedUserFullname"] = userCredentials.FullName.ToString(); Session["LoggedRoleID"] = userCredentials.RoleID.ToString(); if (Convert.ToInt32(Session["LoggedRoleID"].ToString()) == 1) { return(RedirectToAction("CreateUser", userLogin.UserID)); } else if (Convert.ToInt32(Session["LoggedRoleID"].ToString()) == 2) { return(RedirectToAction("ShowAppointment")); } else if (Convert.ToInt32(Session["LoggedRoleID"].ToString()) == 3) { return(RedirectToAction("CreateAppointment")); } } return(View("Index")); } } return(View(userLogin)); }
protected void btnDelete_Click(object sender, EventArgs e) { int[] intRowindexarray = mainGrid.SelectedRowIndexArray; if (intRowindexarray.Length > 0) { userLogin ul = new userLogin(); object[] keys = mainGrid.DataKeys[intRowindexarray[0]]; string strID = keys[0].ToString(); Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("ID", " cast(ID as varchar(36))='" + strID + "' "); int intresult = ul.deletebycondition("userLogin", dic); setPageContent(1); Alert alert = new Alert(); if (intresult > 0) { alert.Icon = Icon.Information; alert.Message = "成功移除数据"; } else { alert.MessageBoxIcon = MessageBoxIcon.Error; alert.Message = "数据移除失败"; } alert.Show(); } }
public ActionResult Login(LoginModel model) { if (ModelState.IsValid) { var dao = new userDao(); var result = dao.LoginUser(model.UserName, Encryptor.MD5Hash(model.Password)); if (result == 1) { var user = dao.GetById(model.UserName); var userSession = new userLogin(); userSession.UserName = user.TenTaiKhoan; userSession.UserID = user.MaUser; Session.Add(CommonConstants.USER_SESSION, userSession); return(Redirect("/Home/Index")); } else if (result == 0) { ModelState.AddModelError("", "Tài khoản không tồn tại"); } else if (result == -1) { ModelState.AddModelError("", "Tài khoản bị khóa"); } else if (result == -2) { ModelState.AddModelError("", "Mật khẩu không đúng"); } else { ModelState.AddModelError("", "Đăng Nhập Không Đúng"); } } return(View(model)); }
// GET api/<controller> public IEnumerable <Users> Get() { using (userLogin le = new userLogin()) { return(le.Users.ToList()); } }
//public void giveLoginAccess() //{ // DataHandler objDataHandler = new DataHandler(); // //DataTable loginTable = new DataTable(); // List<Employee> lstEmployee = new List<Employee>(); // lstEmployee = objDataHandler.GetLoginDetails(); // List<Employee> lstEmployeeFiltered = new List<Employee>(); // lstEmployeeFiltered = (from lstt in lstEmployee // where lstt.EmpName.Equals(textBoxUserNameLF.ToString().Trim()) && lstt.Password.Equals(textBoxPasswordLF.Text.Trim().ToString()) // select lstt).ToList(); // if(lstEmployeeFiltered.Count()> 0) // { // MessageBox.Show("Done"); // } // else // { // MessageBox.Show("Failed"); // } //} public void login() { bool x; userLogin objuserLogin = new userLogin(); objuserLogin.userName = txtuserName.Text.ToString(); objuserLogin.Password = txtPassword.Text.ToString(); EmpManger obj = new EmpManger(); x = obj.Login(objuserLogin); if (x == true) { MessageBox.Show("login succesful !"); userName = txtuserName.Text.ToString(); SystemForm objSystemForm = new SystemForm(userName); objSystemForm.Show(); this.Hide(); } else { MessageBox.Show("login fail !"); } }
private string setToken(userLogin user) { user.Token = Guid.NewGuid().ToString(); _context.Update(user); _context.SaveChanges(); return(user.Token); }
public ActionResult Login(userLogin login, string ReturnUrl = "") { string message = ""; using (DataquadEntities dc = new DataquadEntities()) { var v = dc.userDetails.Where(a => a.emailId == login.emailId).FirstOrDefault(); if (v != null) { if (!v.isEmailVerified) { ViewBag.Message = "Please verify your email first"; return(View()); } if (string.Compare(Crypto.Hash(login.password), v.password) == 0) { int timeout = login.RememberMe ? 525600 : 20; // 525600 min = 1 year var ticket = new FormsAuthenticationTicket(login.emailId, login.RememberMe, timeout); string encrypted = FormsAuthentication.Encrypt(ticket); var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted); cookie.Expires = DateTime.Now.AddMinutes(timeout); cookie.HttpOnly = true; Response.Cookies.Add(cookie); if (Url.IsLocalUrl(ReturnUrl)) { return(Redirect(ReturnUrl)); } else { using (DataquadEntities db = new DataquadEntities()) { var xyz = db.userPersonalDetails.Where(x => x.userId == v.userId).FirstOrDefault(); if (xyz != null) { return(RedirectToAction("LogOn", "Account", new { ID = xyz.userId })); } else { return(RedirectToAction("CreateProfile", "Account", new { id = v.userId })); } } } } else { message = "Invalid credential provided"; } } else { message = "Invalid credential provided"; } } ViewBag.Message = message; return(View()); }
public ActionResult Login(userLogin login) { if (login.LoginName == null || login.Password == null) { return(View()); } else { SqlConnection cn = new SqlConnection(); cn.ConnectionString = @"Data Source = (localdb)\MsSqlLocalDb; Initial Catalog = JKDec20; Integrated Security = True;MultipleActiveResultSets=true"; cn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = "select * from students where LoginName = @LoginName and Password = @Password"; cmd.Parameters.AddWithValue("@LoginName", login.LoginName); cmd.Parameters.AddWithValue("@Password", login.Password); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { Session["LoginName"] = login.LoginName; Session["Password"] = login.Password; HttpCookie objCookie = new HttpCookie("DarkChoco"); /* objCookie.Values["LoginName"] = login.LoginName; * objCookie.Values["Password"] = login.Password; * objCookie.Expires = DateTime.Now.AddDays(1); * objCookie.HttpOnly = true; * Response.Cookies.Add(objCookie);*/ if (login.RememberMe == true) { objCookie.Expires = DateTime.Now.AddDays(1); objCookie.Values["LoginName"] = login.LoginName; objCookie.Values["Password"] = login.Password; objCookie.HttpOnly = true; Response.Cookies.Add(objCookie); } else { objCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(objCookie); } return(RedirectToAction("HomePage", "Home")); } else { return(RedirectToAction("Login")); } dr.Close(); } }
public JsonResult Index() { var user = new userLogin(); user.Email = "*****@*****.**"; user.Password = "******"; return(Json(user)); }
// POST: api/Login public HttpResponseMessage Login(userLogin value) { var login = LoginBll.getLogin(value); var json = Newtonsoft.Json.JsonConvert.SerializeObject(login); HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(json, Encoding.GetEncoding("UTF-8"), "application/json") }; //这里是去掉反斜杠再放回出去,json就只剩下双引号。 return(result); }
public ActionResult sign_In(userLogin lg) { if (lg.userNme.Equals("*****@*****.**") && lg.userPssword.Equals("123456")) { return(View("dashboard")); } else { return(View("Invalid")); } }
// GET: Admin/Information public ActionResult Index() { if (Session[commonConst.user_employee] == null) { return(RedirectToAction("Login", "Index")); } userLogin userLogin = Session[commonConst.user_employee] as userLogin; ViewBag.ID = userLogin.userID; return(View()); }
//Log in to MH : Tested : OK public string Login() { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; LoginCamelot lgnOK = new LoginCamelot(); try { string webAddr = "https://mh.trimble-app.uk:443/camelot_prod/wrd/run/SPDEDJSONSERVICE.LOGIN"; //string webAddr = "https://mh-uat.trimble-app.uk:443/camelot_uat/wrd/run/SPDEDJSONSERVICE.LOGIN"; var httpWebRequest = (HttpWebRequest)WebRequest.Create(webAddr); httpWebRequest.ContentType = "text/json; charset=utf-8"; httpWebRequest.Method = "POST"; httpWebRequest.Accept = "text/json"; userLogin lgn = new userLogin { method = "login", username = "******", password = "******" }; // var jsonscrpt = new JavaScriptSerializer().Serialize(lgn); var jsonscrpt = JsonConvert.SerializeObject(lgn); using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { streamWriter.Write(jsonscrpt); streamWriter.Flush(); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { var responseText = streamReader.ReadToEnd(); Console.WriteLine(responseText); try { lgnOK = Newtonsoft.Json.JsonConvert.DeserializeObject <LoginCamelot>(responseText); } catch (Exception exc) { Console.WriteLine(exc.Message); } } return(lgnOK.sessionID); } catch (WebException ex) { using (StreamWriter sw = File.AppendText(ConfigurationSettings.AppSettings["logfile"].ToString())) { sw.WriteLine("\nexception message : " + ex.Message + Environment.NewLine + "Exception : " + ex.StackTrace); sw.Close(); } return(""); } }
public HttpResponseMessage loginAuth(userLogin value) { var endpoint = URL + "/accounts:signInWithPassword?key=" + keyfire; var client = new HttpClient(); userLogin p = new userLogin { email = value.email, password = value.password, returnSecureToken = true }; var response = client.PostAsJsonAsync(endpoint, p).Result; client.Dispose(); return(response); }
public ActionResult CreateAppointment() { Appoinment_Entities appoinment_Entities_db = new Appoinment_Entities(); List <doctorDetail> doctorDetailsList = new List <doctorDetail>(); //appointment app = new appointment(); userLogin login = new userLogin(); var drafts = appoinment_Entities_db.userLogins.Where(x => x.RoleID == 2).ToList(); if (drafts.Count != 0) { foreach (var doc in drafts) { doctorDetail docdetail = new doctorDetail(); var docId = appoinment_Entities_db.doctorDetails.Where( i => i.doctor_Id == doc.UserID).Single(); var userName = appoinment_Entities_db.userLogins.Where( i => i.UserID == docId.doctor_Id).Single().FullName; docdetail.startTime = docId.startTime; docdetail.doctor_Id = docId.doctor_Id; docdetail.endTime = docId.endTime; docdetail.Doctor_Name = userName; List <string> timeIntervals = new List <string>(); TimeSpan? approvedSlots = new TimeSpan(); //var approvedSlots; var slots = appoinment_Entities_db.appointmentInfoes.Where(x => x.doctor_Id == docdetail.doctor_Id && x.appointment_Status == true).ToList(); DateTime date = Convert.ToDateTime(docId.startTime); DateTime endDate = Convert.ToDateTime(docId.endTime); while (date < endDate) { timeIntervals.Add(date.ToString("hh:mm:ss")); date = date.AddMinutes(15); } docdetail.Interval = timeIntervals.Select(x => new SelectListItem() { Value = x, Text = x }).ToList(); foreach (var approvedTime in slots) { docdetail.Interval.RemoveAll(c => c.Value == Convert.ToString(approvedTime.appointment_Time)); } doctorDetailsList.Add(docdetail); } } return(View(doctorDetailsList)); }
public ActionResult ValidateAndLogin(userLogin ut) { var obj = myRepository.Login(ut); if (obj != null) { Session["Key"] = obj; return(RedirectToAction("../Home/Account")); } else { return(RedirectToAction("../User/Login")); } }
protected void btnSave_Click(object sender, EventArgs e) { Dictionary <string, string> dic = initDatadic(); string strID = editID.Text.ToString().Trim(); userLogin ul = new userLogin(); int intresult = 0; if (strID == "") { dic.Add("ID", Guid.NewGuid().ToString()); string strusername = dic["username"].ToString().Trim(); if (ul.isExistdata("userLogin", "username", strusername, "username").Trim() != "") { Alert.Show(strusername + " 用户账号已经存在!"); } else { intresult = ul.add(dic, "userLogin"); } } else { intresult = ul.update(dic, "userLogin", "ID", strID); } if (CurPage.Text.Trim() == "") { setPageContent(1); } else { setPageContent(5); } Alert alert = new Alert(); if (intresult == 1) { alert.Icon = Icon.Information; alert.Message = "数据保存成功"; } else { alert.MessageBoxIcon = MessageBoxIcon.Error; alert.Message = "数据保存失败"; } alert.Show(); }