コード例 #1
0
        private void txbx_log_btn_Click(object sender, EventArgs e)
        {
            //adding input information to Login_User class//
            Login_User log_user = new Login_User();

            log_user.Login_Email    = txbx_log_email.Text;
            log_user.Login_Password = txbx_log_password.Text;

            ArrayList users = UserDB.GetAllData();

            foreach (User user in users)
            {
                //checking txbx_inputs information have in Login_User database//
                if (user.Email == txbx_log_email.Text && user.Password == txbx_log_password.Text)
                {
                    MessageBox.Show("Sistemə uğurlu daxil oldunuz");
                    CompanyVacanciesForm comVacForm = new CompanyVacanciesForm();
                    comVacForm.Show();
                    Visible = false;
                }
                else
                {
                    MessageBox.Show("Elektron poçt ünvanız yaxud şifrəniz yanlışdır");
                }
            }
        }
コード例 #2
0
        private void dtgvUser_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dtgvUser.Columns[e.ColumnIndex].Name == "btnEdit")
            {
                DataGridViewRow row        = dtgvUser.SelectedCells[0].OwningRow;
                Login_User      login_User = new Login_User();
                login_User.STT      = int.Parse(row.Cells["STT"].Value.ToString());
                login_User.TaiKhoan = row.Cells["TaiKhoan"].Value.ToString();
                login_User.MatKhau  = row.Cells["MatKhau"].Value.ToString();
                login_User.HoTen    = row.Cells["HoTen"].Value.ToString();
                login_User.SDT      = row.Cells["SDT"].Value.ToString();
                login_User.LoaiDN   = row.Cells["LoaiDN"].Value.ToString();


                EditUser editform = new EditUser(login_User);
                editform.ShowDialog();
            }
            else if (dtgvUser.Columns[e.ColumnIndex].Name == "btnDelete")
            {
                DialogResult dialogResult = MessageBox.Show("Bạn có chắc là muốn làm việc này", "WARNING", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    DataGridViewRow row = dtgvUser.SelectedCells[0].OwningRow;
                    values[0] = row.Cells["STT"].Value.ToString();

                    login_UserBUS.DeleteUser(values[0]);
                    MessageBox.Show("Delete complete.");
                }
                else if (dialogResult == DialogResult.No)
                {
                    //do something else
                }
            }
            LoadData();
        }
コード例 #3
0
        public IActionResult Login_User(Login_User user)
        {
            if (ModelState.IsValid)
            {
                var userInDb = dbContext.User.FirstOrDefault(u => u.Email == user.email);
                if (userInDb == null)
                {
                    ModelState.AddModelError("email", "Invalid Email");
                    return(View("Login"));
                }
                var hasher = new PasswordHasher <Login_User>();
                var result = hasher.VerifyHashedPassword(user, userInDb.Password, user.password);

                if (result == 0)
                {
                    ModelState.AddModelError("password", "Invalid Password");
                    return(View("Login"));
                }
                else
                {
                    HttpContext.Session.SetInt32("UserID", userInDb.UserId);
                    HttpContext.Session.SetString("Username", userInDb.FirstName);
                    int?logged_in_user = HttpContext.Session.GetInt32("UserID");
                    return(Redirect($"account/{logged_in_user}"));
                }
            }
            return(View("Index"));
        }
コード例 #4
0
ファイル: UserController.cs プロジェクト: thobzabuyi/pcm
        public ActionResult Login(Login_User user, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var username = user.Username;
                var password = user.Password;

                var userModel     = new UserModel();
                var loggedInAgent = userModel.DoLogin(username, password);

                if (loggedInAgent == null)
                {
                    ModelState.AddModelError("", "The Username or Password is incorrect! Please try again!");
                }
                else
                {
                    FormsAuthentication.SetAuthCookie(username, false);
                    Session.Remove("CurrentUser");
                    Session.Remove("MenuLayout");
                    Session.Add("CurrentUser", loggedInAgent);

                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return(Redirect(returnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
            }

            return(View(user));
        }
コード例 #5
0
        public ActionResult Index(Login_User user)
        {
            //if (!User.Identity.IsAuthenticated)
            //{
            //var db = new LocalDbContext.LocalDb();
            //var result = (from u in db.Login_User
            //    where u.Username == user.Username && u.Password == user.Password
            //    select u).FirstOrDefault();
            //if (result != null)
            //{
            //AuthUtil.Register(user.Username, user.Password);
            //return Redirect(Request.UrlReferrer.ToString());
            //}
            //    return View();
            //}

            var result = AuthUtil.SignIn(user.Username, user.Password, true);

            if (result)
            {
                return(Redirect(Request.UrlReferrer.ToString()));
            }
            ViewBag.ResponseMessage = "Wrong username or password";
            return(View());
        }
コード例 #6
0
        public ActionResult DeleteConfirmed(int id)
        {
            Login_User login_User = db.Login_User.Find(id);

            db.Login_User.Remove(login_User);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #7
0
        // xóa giáo viên theo ID
        public int DeleteUser(Login_User user)
        {
            string sql            = string.Format("delete from DangNhap where STT = @a1");
            List <SqlParameter> p = new List <SqlParameter>();

            p.Add(new SqlParameter("@a1", user.STT));

            return(DATA.Instance.WriteData(sql, p));
        }
コード例 #8
0
        public DataTable CheckUser(Login_User user)
        {
            string sql            = "EXEC CheckIDPass @a1,@a2";
            List <SqlParameter> p = new List <SqlParameter>();

            p.Add(new SqlParameter("@a1", user.TaiKhoan));
            p.Add(new SqlParameter("@a2", user.MatKhau));

            return(DATA.Instance.ReadAllData(sql, p));
        }
コード例 #9
0
 public ActionResult Edit([Bind(Include = "REGID,Society_Name,Email,Password")] Login_User login_User)
 {
     if (ModelState.IsValid)
     {
         db.Entry(login_User).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(login_User));
 }
コード例 #10
0
 public DataTable SearchUserIfName(Login_User user)
 {
     try
     {
         return(login_UserDAO.SearchUserIfName(user));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #11
0
        public ActionResult Create([Bind(Include = "REGID,Society_Name,Email,Password")] Login_User login_User)
        {
            if (ModelState.IsValid)
            {
                db.Login_User.Add(login_User);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(login_User));
        }
コード例 #12
0
        public int InsertUser(Login_User user)
        {
            try
            {
                //Xử lý chính(nghiệp vụ)

                //Xử lý dữ liệu
                return(login_UserDAO.InsertUser(user));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #13
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtSearch.Text != "")
            {
                Login_User login_User = new Login_User();
                login_User.HoTen = txtSearch.Text;

                dtgvUser.DataSource = login_UserBUS.SearchUserIfName(login_User);
            }
            else
            {
                LoadData();
            }
        }
コード例 #14
0
        void AddUser()
        {
            // khởi tạo đối tượng.
            Login_User Login_User = new Login_User();

            // thêm dữ liệu cho đối tượng
            Login_User.HoTen    = txtName.Text;
            Login_User.TaiKhoan = txtUser.Text;
            Login_User.MatKhau  = txtPass.Text;
            Login_User.SDT      = txtPhone.Text;
            Login_User.LoaiDN   = cbxDecentralization.Text;
            // gọi đến BUS để xử lý (thêm vào CSDL)
            login_UserBUS.InsertUser(Login_User);
        }
コード例 #15
0
        // thêm mới giáo viên
        public int RepearUser(Login_User user)
        {
            string sql            = string.Format("UPDATE DangNhap SET TaiKhoan = @a1, MatKhau = @a2,HoTen = @a3,SDT = @a4,LoaiDN = @a5  where STT = @a6");
            List <SqlParameter> p = new List <SqlParameter>();

            p.Add(new SqlParameter("@a1", user.TaiKhoan));
            p.Add(new SqlParameter("@a2", user.MatKhau));
            p.Add(new SqlParameter("@a3", user.HoTen));
            p.Add(new SqlParameter("@a4", user.SDT));
            p.Add(new SqlParameter("@a5", user.LoaiDN));
            p.Add(new SqlParameter("@a6", user.STT));

            return(DATA.Instance.WriteData(sql, p));
        }
コード例 #16
0
        // GET: Login_User/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Login_User login_User = db.Login_User.Find(id);

            if (login_User == null)
            {
                return(HttpNotFound());
            }
            return(View(login_User));
        }
コード例 #17
0
        public int DeleteUser(string STT)
        {
            try
            {
                Login_User user = new Login_User();
                user.STT = int.Parse(STT);

                //Xử lý dữ liệu
                return(login_UserDAO.DeleteUser(user));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #18
0
        public DataTable SearchUserIfId(string IDUser)
        {
            try
            {
                Login_User user = new Login_User();
                user.STT = int.Parse(IDUser);


                return(login_UserDAO.SearchUserIfId(user));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #19
0
        public EditUser(Login_User login_User)
        {
            InitializeComponent();

            List <string> values = new List <string>();

            values.Add(login_User.STT.ToString());
            values.Add(login_User.TaiKhoan);
            values.Add(login_User.MatKhau);
            values.Add(login_User.HoTen);
            values.Add(login_User.SDT);
            values.Add(login_User.LoaiDN);

            //load dữ liệu
            Load_Data(values);
        }
コード例 #20
0
        public DataTable CheckUser(string User, string Pass)
        {
            try
            {
                Login_User user = new Login_User();
                user.TaiKhoan = User;
                user.MatKhau  = Pass;

                //Xử lý dữ liệu
                return(login_UserDAO.CheckUser(user));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #21
0
        void SetAutoLogin(Login_User user)
        {
            if (!Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\InTime"))
            {
                Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\InTime");
            }
            if (!File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\InTime\\auto.log"))
            {
                File.Create(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\InTime\\auto.log");
            }


            StreamWriter streamWriter = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\InTime\\auto.log");

            streamWriter.WriteLine(user.Login);
            streamWriter.WriteLine(user.Password);
            streamWriter.Close();
        }
コード例 #22
0
        private void dtgvUser_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            // F1 : Thêm
            if (e.KeyCode == Keys.F1)
            {
                LoadAnimation();
            }
            // F4: sửa
            else if (e.KeyCode == Keys.F4)
            {
                DataGridViewRow row        = dtgvUser.SelectedCells[0].OwningRow;
                Login_User      login_User = new Login_User();
                login_User.STT      = int.Parse(row.Cells["STT"].Value.ToString());
                login_User.TaiKhoan = row.Cells["TaiKhoan"].Value.ToString();
                login_User.MatKhau  = row.Cells["MatKhau"].Value.ToString();
                login_User.HoTen    = row.Cells["HoTen"].Value.ToString();
                login_User.SDT      = row.Cells["SDT"].Value.ToString();
                login_User.LoaiDN   = row.Cells["LoaiDN"].Value.ToString();


                EditUser editform = new EditUser(login_User);
                editform.ShowDialog();
            }
            // F8 : xóa
            else if (e.KeyCode == Keys.F8)
            {
                DialogResult dialogResult = MessageBox.Show("Bạn có chắc là muốn làm việc này", "WARNING", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    DataGridViewRow row = dtgvUser.SelectedCells[0].OwningRow;
                    values[0] = row.Cells["STT"].Value.ToString();

                    login_UserBUS.DeleteUser(values[0]);
                    MessageBox.Show("Delete complete.");
                }
                else if (dialogResult == DialogResult.No)
                {
                    //do something else
                }
            }


            LoadData();
        }
コード例 #23
0
        private async void LoginBtnMouseDown(object sender, MouseButtonEventArgs e)
        {
            try
            {
                if ((LoginBox.Text == String.Empty || LoginPassBox.Password == String.Empty) ||
                    (LoginBox.Text == String.Empty && LoginPassBox.Password == String.Empty))
                {
                    ErrorText.Text          = "One or more fields should be \n; signed. Please, try again.";
                    NetworkError.Visibility = Visibility.Visible;
                }
                else
                {
                    loadBord.Visibility = Visibility.Visible;
                    Console.WriteLine("asd");
                    Service1Client client  = new Service1Client();
                    Login_User     logUser = new Login_User {
                        Image = null, ExtensionData = null, Login = LoginBox.Text, Password = LoginPassBox.Password, Email = null
                    };
                    Console.WriteLine(logUser.Password);
                    Client_User user = await client.TryLoginAsync(logUser);

                    SetAutoLogin(logUser);
                    OnWindowClosed?.Invoke(user);
                    this.Close();
                }
            }
            catch (FaultException <LoginFailed> exception)
            {
                ErrorText.Text          = exception.Detail.Message;
                NetworkError.Visibility = Visibility.Visible;
                loadBord.Visibility     = Visibility.Hidden;
                return;
            }
            catch
            {
                ErrorText.Text          = "Network issues. Please check your\ninternet connection and try again.";
                loadBord.Visibility     = Visibility.Hidden;
                NetworkError.Visibility = Visibility.Visible;
                return;
            }
            loadBord.Visibility     = Visibility.Hidden;
            NetworkError.Visibility = Visibility.Hidden;
        }
コード例 #24
0
        /// <summary>
        /// sửa thông tin đăng nhập
        /// </summary>
        /// <param name="STT"></param>
        /// <param name="TaiKhoan"></param>
        /// <param name="MatKhau"></param>
        /// <param name="HoTen"></param>
        /// <param name="SDT"></param>
        /// <param name="LoaiDN"></param>
        /// <returns></returns>
        public int RepearUser(List <string> values)
        {
            // tạo ra biến ghi nhận lỗi
            string strError = "";

            try
            {
                //Xử lý chính(nghiệp vụ)
                Login_User user = new Login_User();
                user.TaiKhoan = values[1];
                user.MatKhau  = values[2];
                user.HoTen    = values[3];
                user.SDT      = values[4];
                user.LoaiDN   = values[5];
                strError      = "Text not number1";
                user.STT      = int.Parse(values[0]);

                //Xử lý dữ liệu
                return(login_UserDAO.RepearUser(user));
            }
            catch (Exception ex)
            {
                switch (strError)
                {
                case "Text not number1":
                {
                    MessageBox.Show("Chương trình không nhận kí tự chữ .@0", "WARNING RepearUser");

                    break;
                }

                default:
                {
                    break;
                }
                }

                return(0);
            }
        }
コード例 #25
0
ファイル: ExamController.cs プロジェクト: garyjohnson48/Exam
        public IActionResult Process_Login(Login_User user)
        {
            if (ModelState.IsValid)
            {
                var val = user.Email;
                HttpContext.Session.SetString("userid", val);

                Console.WriteLine(HttpContext.Session.GetString("userid"));
                Console.WriteLine("Model state seems to be valid");


                User ValidateUser = _context.users
                                    .FirstOrDefault(d => d.Email == user.Email);
                if (ValidateUser == null)
                {
                    Console.WriteLine("User is null");
                    ModelState.AddModelError("Email", "Invalid Email/Password");
                    return(View("Login"));
                }

                var hasher = new PasswordHasher <Login_User>();

                // verify provided password against hash stored in db
                var result = hasher.VerifyHashedPassword(user, ValidateUser.Password, user.Password);

                // result can be compared to 0 for failure
                if (result == 0)
                {
                    Console.WriteLine("Password is returning 0");
                    // handle failure (this should be similar to how "existing email" is handled)
                    ModelState.AddModelError("Password", "Password Incorrect");
                    return(View("Login"));
                }


                return(RedirectToAction("Bright_Ideas"));
            }
            Console.WriteLine("Model state seems to be invalid");
            return(View("Login"));
        }
コード例 #26
0
 public ActionResult Register(Login_User user)
 {
     AuthUtil.Register(user.Username, user.Password);
     return(Redirect("/Home/Index"));
 }
コード例 #27
0
ファイル: UserController.cs プロジェクト: thobzabuyi/pcm
        // GET: User
        public ActionResult Login()
        {
            var loginUser = new Login_User();

            return(View(loginUser));
        }
コード例 #28
0
        public DataTable SearchUserIfName(Login_User user)
        {
            string sql = string.Format("select *  from DangNhap  where HoTen like N'%{0}%' ", user.HoTen);

            return(DATA.Instance.ReadAllData(sql, null));
        }
コード例 #29
0
        public DataTable SearchUserIfId(Login_User user)
        {
            string sql = string.Format("select *  from DangNhap  where STT = '{0}' ", user.STT);

            return(DATA.Instance.ReadAllData(sql, null));
        }
コード例 #30
0
        // thêm mới giáo viên
        public int InsertUser(Login_User user)
        {
            string sql = string.Format("INSERT INTO	 dbo.DangNhap ( TaiKhoan, MatKhau, HoTen, SDT, LoaiDN )VALUES  ( '{0}', '{1}', N'{2}','{3}',  '{4}'  )", user.TaiKhoan, user.MatKhau, user.HoTen, user.SDT, user.LoaiDN);

            return(DATA.Instance.WriteData(sql, null));
        }