コード例 #1
0
        protected void btnChangePass_Click(object sender, EventArgs e)
        {
            string macongty = DropCongTy.SelectedValue.ToString();

            if (txtPassNew.Text.Length < 6 && txtConfirmPass.Text.Length < 6)
            {
                string ngonngu = Session["languege"].ToString();
                if (ngonngu == "lbl_VN")
                {
                    lbThongBao.Text = "Độ dài của mật khẩu phải lớn hơn 6 ký tự";
                }
                else if (ngonngu == "lbl_TW")
                {
                    lbThongBao.Text = "密码的长度必须大于6个字符";
                }
                else if (ngonngu == "lbl_EN")
                {
                    lbThongBao.Text = " The password must be greater than six characters!";
                }

                return;
            }
            if (txtPassNew.Text != txtConfirmPass.Text)
            {
                string ngonngu = Session["languege"].ToString();
                if (ngonngu == "lbl_VN")
                {
                    lbThongBao.Text = "Mật khẩu và xác nhận mật khẩu không trùng nhau, vui lòng nhập lại";
                }
                else if (ngonngu == "lbl_TW")
                {
                    lbThongBao.Text = "密码和确认密码不匹配,请重新输入!";
                }
                else if (ngonngu == "lbl_EN")
                {
                    lbThongBao.Text = " Password and confirm password do not match, Please re-enter!";
                }

                return;
            }
            try
            {
                Busers2 nv = UserBUS.CheckPass2(txtUserID.Text, libraly.Encryption(txtPassOld.Text), macongty, true);
                if (nv != null)
                {
                    if (UserBUS.ThayDoiMatKhauCap2(txtUserID.Text, libraly.Encryption(txtPassOld.Text), libraly.Encryption(txtPassNew.Text), true))
                    {
                        //Program.client.WriteFileLog(Program.ipClient + "\t" + Util.uNhanVien.HoTen + "\tThay đổi mã bảo mật\t\tThành công.");
                        string ngonngu = Session["languege"].ToString();
                        if (ngonngu == "lbl_VN")
                        {
                            lblthongbaothanhcong.Text = "Thay đổi mật khẩu thành công";
                        }
                        else if (ngonngu == "lbl_TW")
                        {
                            lblthongbaothanhcong.Text = "成功修改密码!";
                        }
                        else if (ngonngu == "lbl_EN")
                        {
                            lblthongbaothanhcong.Text = " Change the password successfully";
                        }

                        //Until.uNhanVien = UserBUS.KiemTraDangNhap(Until.uNhanVien.USERID, Until.uNhanVien.PWD);
                    }
                    else
                    {
                        //Program.client.WriteFileLog(Program.ipClient + "\t" + Util.uNhanVien.HoTen + "\tThay đổi mã bảo mật\t\tThất bại.");
                        string ngonngu = Session["languege"].ToString();
                        if (ngonngu == "lbl_VN")
                        {
                            lbThongBao.Text = "Không thể thay đổi được mật khẩu";
                        }
                        else if (ngonngu == "lbl_TW")
                        {
                            lbThongBao.Text = "不能更改密码!";
                        }
                        else if (ngonngu == "lbl_EN")
                        {
                            lbThongBao.Text = " Cannot change is a password";
                        }
                        return;
                    }
                }
                else
                {
                    Busers2 timnv = UserDAO.TimNhanVienTheoMa(txtUserID.Text, macongty);
                    if (timnv == null)
                    {
                        string ngonngu = Session["languege"].ToString();
                        if (ngonngu == "lbl_VN")
                        {
                            lbThongBao.Text = "Sai Tên đăng nhập, mật khẩu hoặc công ty";
                        }
                        else if (ngonngu == "lbl_TW")
                        {
                            lbThongBao.Text = "公司名称,登入名称,密码有错误";
                        }
                        else if (ngonngu == "lbl_EN")
                        {
                            lbThongBao.Text = " Wrong login name, password, or company";
                        }
                    }
                    else
                    {
                        string ngonngu = Session["languege"].ToString();
                        if (ngonngu == "lbl_VN")
                        {
                            lbThongBao.Text = "Sai Tên đăng nhập, mật khẩu hoặc công ty";
                        }
                        else if (ngonngu == "lbl_TW")
                        {
                            lbThongBao.Text = "公司名称,登入名称,密码有错误";
                        }
                        else if (ngonngu == "lbl_EN")
                        {
                            lbThongBao.Text = " Wrong login name, password, or company";
                        }
                    }
                    return;
                }
            }

            catch (Exception)
            {
                // Khong biet lam gi
            }
        }