public ActionResult newUser() { String email = ""; email = Convert.ToString(Request.QueryString["email"]); if (email != "") { userDAO userObjDao = new userDAO(); user userObj = userObjDao.getUserByEmail(email); ViewBag.txtId = userObj.txtId; ViewBag.userImage = userObj.userImage; ViewBag.txtName = userObj.txtName; ViewBag.txtLogin = userObj.txtLogin; ViewBag.txtPassword = userObj.txtPassword; ViewBag.txtEmail = userObj.txtEmail; ViewBag.cmbGender = userObj.cmbGender; ViewBag.txtAddress = userObj.txtAddress; ViewBag.txtAge = userObj.txtAge; ViewBag.txtCnic = userObj.txtCnic; ViewBag.dateDob = userObj.dateDob.ToString("yyyy-MM-dd"); ViewBag.chkCricket = userObj.chkCricket; ViewBag.chkHockey = userObj.chkHockey; ViewBag.chkChess = userObj.chkChess; return(View()); } return(View()); }
public ActionResult Login(User viewModel) { //check to make sure user is accessing ciew in the browser if (ModelState.IsValid) { //instantiate a new user named _user // User _user = new User(); //run the login stored procedure using my view model userDAO _user1 = _userDataAccess.LoginUser(_Mapper.Map(viewModel)); if (viewModel.password == _user1.Password) { //Put the _user1 values into the session variable Session["UserID"] = _user1.login_ID; Session["RoleID"] = _user1.role_ID; Session["RoleName"] = _user1.roleName; return(RedirectToAction("ViewPlayers", "Player")); } else { //return register user return(RedirectToAction("Index", "Home")); } } else { return(RedirectToAction("Login", "user")); } }
public editProfileView() { InitializeComponent(); conn = connection.GetInstance(); userDAO = new userDAO(conn.GetConnection()); }
public int AddUser() { userDAO user = new userDAO(); int result = user.Insert(this); return(result); }
public int getLastUserId() { userDAO dao = new userDAO(); int result = dao.getLastUserId(); return(result); }
public ActionResult home() { userDAO userObjDao = new userDAO(); List <user> userList = userObjDao.getAllUsers(); ViewBag.userList = userList; return(View()); }
public List <string> getTeachersTeachingClasses(string user_ID) { List <string> obj = new List <string>(); userDAO userdao = new userDAO(); obj = userdao.getTeachersTeachingClasses(user_ID); return(obj); }
public List <accessLogItem> getAccessLogById(string user_ID) { List <accessLogItem> obj = new List <accessLogItem>(); userDAO userdao = new userDAO(); obj = userdao.getAccessLogById(user_ID); return(obj); }
public registerView() { InitializeComponent(); conn = connection.GetInstance(); userDAO = new userDAO(conn.GetConnection()); log_username.Focus(); }
public login_WIN() { InitializeComponent(); conn = connection.GetInstance(); userDAO = new userDAO(conn.GetConnection()); }
public cariDokterView() { InitializeComponent(); conn = connection.GetInstance(); userDAO = new userDAO(conn.GetConnection()); filltolst(); }
public ActionResult UpdateUser(User _UserInfo) { if ((int)Session["Role_ID"] == 3 || (int)Session["Role_ID"] == 2) { userDAO _recievedUser = _mapper.SingleUser(_UserInfo); _UserDataAccess.UpdateUser(_recievedUser); } return(RedirectToAction("UserView")); }
public ActionResult DeleteUser(int Delete_User) { if ((int)Session["Role_ID"] == 3) { userDAO _DeleteUser = new userDAO(); _DeleteUser.User_ID = Delete_User; _UserDataAccess.DeleteUser(_DeleteUser); } return(RedirectToAction("UserView")); }
public userDAO Map(User _createListToMap) { userDAO _userToLog = new userDAO(); _userToLog.userName = _createListToMap.userName; _userToLog.Password = _createListToMap.password; _userToLog.login_ID = _createListToMap.login_ID; _userToLog.role_ID = _createListToMap.role_ID; return(_userToLog); }
public User Map(userDAO _createListToMap) { User _userToLog = new User(); _userToLog.userName = _createListToMap.userName; _userToLog.password = _createListToMap.Password; _userToLog.login_ID = _createListToMap.login_ID; _userToLog.role_ID = _createListToMap.role_ID; return(_userToLog); }
public List <userDAO> GetAllUsers() { List <userDAO> _userlist = new List <userDAO>(); try { //esablishing the connection for the database using (SqlConnection _connection = new SqlConnection(connectionstring)) { //establishing the command to pass to the database and defining the command using (SqlCommand _command = new SqlCommand("sp_ReadAllUsers", _connection)) { _command.CommandType = CommandType.StoredProcedure; //connect to the database _connection.Open(); //open the SQL data reader using (SqlDataReader _reader = _command.ExecuteReader()) { //loop through the dataset or command and write each element to the _playerToList using the player object class while (_reader.Read()) { userDAO _userToList = new userDAO(); _userToList.login_ID = _reader.GetInt32(0); _userToList.userName = _reader.GetString(1); _userToList.Password = _reader.GetString(2); _userToList.role_ID = _reader.GetInt32(3); _userlist.Add(_userToList); } } } } } catch (Exception error) { string message = string.Format("Time: {0}", DateTime.Now.ToString("")); message += Environment.NewLine; message += "---------------------------------------------------------"; message += Environment.NewLine; message += string.Format("message {0}", error.Message); message += Environment.NewLine; message += string.Format("Stack Trace {0}", error.StackTrace); message += Environment.NewLine; message += string.Format("Source: {0}", error.Source); message += Environment.NewLine; message += string.Format("TargetSite: {0}", error.TargetSite.ToString()); message += Environment.NewLine; message += "---------------------------------------------------------"; message += Environment.NewLine; //using (StreamWriter _writer = new StreamWriter("C:\\Users\admin2\\Desktop\\errorstream", true)) // { // _writer.WriteLine(message); // } } return(_userlist); }
public userDAO GetUserByloginID(int login_ID) { userDAO _userToGet = new userDAO(); try { //esablishing the connection for the database using (SqlConnection _connection = new SqlConnection(connectionstring)) { //establishing the command to pass to the database and defining the command using (SqlCommand _command = new SqlCommand("sp_GetUserByloginID", _connection)) { //this specifies what type of command is being used _command.CommandType = CommandType.StoredProcedure; //here is where values are going to be passed to the command _command.Parameters.AddWithValue("@login_ID", login_ID); //here is where the connection is open _connection.Open(); //this executes the command _command.ExecuteNonQuery(); using (SqlDataReader _reader = _command.ExecuteReader()) { //loop through the dataset or command and write each element to the _playerToList using the player object class while (_reader.Read()) { _userToGet.login_ID = _reader.GetInt32(0); _userToGet.userName = _reader.GetString(1); _userToGet.Password = _reader.GetString(2); _userToGet.role_ID = _reader.GetInt32(3); } } } } } catch (Exception error) { string message = string.Format("Time: {0}", DateTime.Now.ToString("")); message += Environment.NewLine; message += "---------------------------------------------------------"; message += Environment.NewLine; message += string.Format("message {0}", error.Message); message += Environment.NewLine; message += string.Format("Stack Trace {0}", error.StackTrace); message += Environment.NewLine; message += string.Format("Source: {0}", error.Source); message += Environment.NewLine; message += string.Format("TargetSite: {0}", error.TargetSite.ToString()); message += Environment.NewLine; message += "---------------------------------------------------------"; message += Environment.NewLine; } return(_userToGet); }
public ActionResult home() { String email = Convert.ToString(Request.QueryString["email"]); userDAO userObjDao = new userDAO(); user userObj = userObjDao.getUserByEmail(email); ViewBag.txtName = userObj.txtName; //String applicationBasePath=System.IO.Path.GetDirectoryName() ViewBag.userImage = userObj.userImage; ViewBag.txtEmail = email; return(View()); }
public void updatePwd(string user_ID, string pwd) { string salt; Crypto_BO crypto = new Crypto_BO(); crypto.password_crypto(user_ID, pwd); pwd = crypto.hashedPassword; salt = crypto.salt; userDAO userdao = new userDAO(); userdao.updatePwd(user_ID, pwd, salt); }
public ActionResult UserLogin(User Login) { if (ModelState.IsValid) { userDAO ValidateUser = new userDAO(); ValidateUser = _UserDataAccess.Login(_mapper.SingleUser(Login)); Session["User_ID"] = ValidateUser.User_ID; Session["Username"] = ValidateUser.Username; Session["Password"] = ValidateUser.Password; Session["Role_ID"] = ValidateUser.Role_ID; } return(RedirectToAction("ManyView", "Home")); }
public User SelectUser(userDAO _SelectUserToMap) { User UserToReturn = new User(); { User _userToView = new User(); _userToView.User_ID = _SelectUserToMap.User_ID; _userToView.Username = _SelectUserToMap.Username; _userToView.Password = _SelectUserToMap.Password; _userToView.Role_ID = _SelectUserToMap.Role_ID; UserToReturn = _userToView; } return(UserToReturn); }
public userDAO SingleUser(User _SingleUserToMap) { userDAO UserToReturn = new userDAO(); { userDAO _userToView = new userDAO(); _userToView.User_ID = _SingleUserToMap.User_ID; _userToView.Username = _SingleUserToMap.Username; _userToView.Password = _SingleUserToMap.Password; _userToView.Role_ID = _SingleUserToMap.Role_ID; UserToReturn = _userToView; } return(UserToReturn); }
public userDAO LoginUser(userDAO _userLogin) { userDAO _loginUser = new userDAO(); try { using (SqlConnection _connection = new SqlConnection(connectionstring)) { using (SqlCommand _command = new SqlCommand("sp_Login", _connection)) { _command.CommandType = CommandType.StoredProcedure; _command.Parameters.AddWithValue("@userName", _userLogin.userName); _connection.Open(); using (SqlDataReader _reader = _command.ExecuteReader()) { while (_reader.Read()) { _loginUser.login_ID = _reader.GetInt32(0); _loginUser.userName = _reader.GetString(1); _loginUser.Password = _reader.GetString(2); _loginUser.role_ID = _reader.GetInt32(3); } } _connection.Close(); } } } catch (Exception error) { string message = string.Format("Time: {0}", DateTime.Now.ToString("")); message += Environment.NewLine; message += "---------------------------------------------------------"; message += Environment.NewLine; message += string.Format("message {0}", error.Message); message += Environment.NewLine; message += string.Format("Stack Trace {0}", error.StackTrace); message += Environment.NewLine; message += string.Format("Source: {0}", error.Source); message += Environment.NewLine; message += string.Format("TargetSite: {0}", error.TargetSite.ToString()); message += Environment.NewLine; message += "---------------------------------------------------------"; message += Environment.NewLine; } return(_loginUser); }
public ActionResult RegisterUser(User newUser) { //if ((int)Session["Role_ID"] == 3 || (int)Session["Role_ID"] == 2) { newUser.Role_ID = 1; userDAO UserToCreate = _mapper.SingleUser(newUser); _UserDataAccess.Createuser(UserToCreate); /*userDAO CreateCart1 = new userDAO(); * _UserDataAccess.CreateShoppingCartOnRegister1(CreateCart1); * shoppingcartDAO CreateCart2 = new shoppingcartDAO(); * _shoppingDataAccess.CreateShoppingCartOnRegister2(CreateCart2);*/ } return(RedirectToAction("UserLogin")); }
public user getUserById(string user_ID) { user obj = new user(); userDAO userdao = new userDAO(); obj = userdao.getUserById(user_ID); if (obj == null) { return(null); //user does not exist } else { return(obj); } }
public ActionResult Login(user userObj) { userDAO userObjDao = new userDAO(); String email = userObjDao.validateUser(userObj); if (email != null) { return(Redirect("/home/home?email=" + email)); } else { ViewBag.txtLogin = userObj.txtLogin; ViewBag.msg = "Incorrect Info"; } return(View()); }
//CHANGE TO USER public bool UpdateUser(userDAO UserToUpdate) { bool success = false; try { using (SqlConnection _connection = new SqlConnection(connectionstring)) { using (SqlCommand _command = new SqlCommand("sp_UpdateUser", _connection)) { //this specifies what type of command is being used _command.CommandType = CommandType.StoredProcedure; //here is where values are going to be passed to the command _command.Parameters.AddWithValue("@login_ID", UserToUpdate.login_ID); _command.Parameters.AddWithValue("@userName", UserToUpdate.userName); _command.Parameters.AddWithValue("@Password", UserToUpdate.Password); _command.Parameters.AddWithValue("@role_ID", UserToUpdate.role_ID); //here is where the connection is open _connection.Open(); //this executes the command _command.ExecuteNonQuery(); success = true; _connection.Close(); } } } catch (Exception error) { string message = string.Format("Time: {0}", DateTime.Now.ToString("")); message += Environment.NewLine; message += "---------------------------------------------------------"; message += Environment.NewLine; message += string.Format("message {0}", error.Message); message += Environment.NewLine; message += string.Format("Stack Trace {0}", error.StackTrace); message += Environment.NewLine; message += string.Format("Source: {0}", error.Source); message += Environment.NewLine; message += string.Format("TargetSite: {0}", error.TargetSite.ToString()); message += Environment.NewLine; message += "---------------------------------------------------------"; message += Environment.NewLine; } return(success); }
private void button1_Click(object sender, EventArgs e) { if (txtPass.Text == "" || txtUser.Text == "") { MessageBox.Show("Mời nhập đầy đủ thông tin !!!"); } else { userDAO user = new userDAO(); int result = user.login(txtUser.Text, txtPass.Text); if (result != 0) { frmmenu frmmenu = new frmmenu(); frmmenu.Show(); } //show loi } }
private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtPass.Text) | string.IsNullOrWhiteSpace(txtUser.Text)) { MessageBox.Show("Hãy điền đẩy đủ mật khẩu và tên đăng nhập trước!!"); return; } else { userDAO user = new userDAO(); int result = user.login(txtUser.Text, txtPass.Text); if (result != 0) { frmmenu frmmenu = new frmmenu(); frmmenu.Show(); } //show loi } }
//static string connectionstrings = ConfigurationManager.ConnectionStrings["BasketballDB"].ConnectionString; public void CreateUser(userDAO _userCreate) { userDAO _CreateUser = new userDAO(); try { using (SqlConnection _connection = new SqlConnection(connectionstring)) { using (SqlCommand _command = new SqlCommand("sp_createUser", _connection)) { _command.CommandType = CommandType.StoredProcedure; _command.Parameters.AddWithValue("@userName", _userCreate.userName); _command.Parameters.AddWithValue("@Password", _userCreate.Password); _connection.Open(); _command.ExecuteNonQuery(); _connection.Close(); _connection.Dispose(); } } } catch (Exception error) { string message = string.Format("Time: {0}", DateTime.Now.ToString("")); message += Environment.NewLine; message += "---------------------------------------------------------"; message += Environment.NewLine; message += string.Format("message {0}", error.Message); message += Environment.NewLine; message += string.Format("Stack Trace {0}", error.StackTrace); message += Environment.NewLine; message += string.Format("Source: {0}", error.Source); message += Environment.NewLine; message += string.Format("TargetSite: {0}", error.TargetSite.ToString()); message += Environment.NewLine; message += "---------------------------------------------------------"; message += Environment.NewLine; } }