Example #1
0
        public JsonResult UpdateInfo(string phone, string address, int marry, string ipphone, string noteContact)
        {
            try
            {
                NI10_Employee   employee     = (Session["EmployeeLogin"] != null) ? (NI10_Employee)Session["EmployeeLogin"] : new NI10_Employee();
                PutDataResponse dataResponse = DataFunction.PutDataToService(serviceUrl, "Request/GetData", "",
                                                                             new List <string>()
                {
                    "@EmployeeCode", employee.EmployeeCode,
                    "@PhoneNumber", phone,
                    "@Address", address,
                    "@Marry", marry.ToString(),
                    "@IPphone", ipphone,
                    "@NoteContact", noteContact
                },
                                                                             "[dbo].[NI10_Employee_UpdateInfo]");

                if (dataResponse.StatusCode == "DONE")
                {
                    return(Json("1", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json("0", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json("0", JsonRequestBehavior.AllowGet));
            }
        }
Example #2
0
        public ActionResult MenuInfo()
        {
            string           serviceUrl = ConfigurationManager.AppSettings["ServiceUrl"];
            NI10_Employee    employee   = (Session["EmployeeLogin"] != null) ? (NI10_Employee)Session["EmployeeLogin"] : new NI10_Employee();
            List <NI10_Menu> menus      = DataFunction.GetCustomObjectListFromService <NI10_Menu>(serviceUrl, "Request/GetData", "", new List <string>()
            {
                "@employeeCode", employee.EmployeeCode
            }, "[dbo].[NI10_Menu_GetByEmployeeCode]");

            return(View(menus));
        }
Example #3
0
        public ActionResult Profile()
        {
            if (Session["EmployeeLogin"] == null)
            {
                return(Redirect("/User/Login?returnUrl=/User/Profile"));
            }
            NI10_Employee employee = (Session["EmployeeLogin"] != null) ? (NI10_Employee)Session["EmployeeLogin"] : new NI10_Employee();

            employee         = new SqlNI10_EmployeeDao().GetSingleByCustomDataSource(new object[] { "@employeeCode", employee.EmployeeCode }, "[dbo].[NI10_Employee_GetEmployeeInfo]");
            ViewBag.UserInfo = employee;
            return(View());
        }
Example #4
0
 public ActionResult ChangePassword(ChangePasswordModel model)
 {
     try
     {
         NI10_Employee employee         = (Session["EmployeeLogin"] != null) ? (NI10_Employee)Session["EmployeeLogin"] : new NI10_Employee();
         bool          isADAuthenticate = bool.Parse(System.Web.Configuration.WebConfigurationManager.AppSettings["IsADAuthenticate"]);
         if (isADAuthenticate)
         {
             bool isValidateUser = LdapFunction.IsExists(employee.EmployeeCode);
             if (isValidateUser)
             {
                 if (!String.IsNullOrEmpty(model.NewPassword))
                 {
                     if (StaticFunc.EncryptIntranet(model.CurrentPassword) == employee.CurrentPassword)
                     {
                         LdapFunction.ResetPassword(employee.EmployeeCode, model.NewPassword);
                         employee.CurrentPassword = StaticFunc.EncryptIntranet(model.NewPassword);
                         Session["EmployeeLogin"] = employee;
                     }
                     else
                     {
                         TempData["error"] = "Mật khẩu cũ không trùng khớp";
                     }
                 }
             }
             else
             {
                 TempData["error"] = "Không tìm thấy tài khoản của bạn";
             }
         }
     }
     catch (Exception ex)
     {
         if (ex.ToString().Contains("The password does not meet the password policy requirements"))
         {
             TempData["error"] = "Mật khẩu không được chứa họ,tên,tên đệm";
         }
         else
         {
             TempData["error"] = ex.ToString();
         }
     }
     if (TempData["error"] != null)
     {
         return(Redirect("/User/Profile"));
     }
     else
     {
         TempData["success"] = "Cập nhập thành công!";
         return(Redirect("/User/Login/?returnUrl=/"));
     }
 }
Example #5
0
        public void FillLoginInfo(string jobTitleName, string userId, string displayName, string employeeCode, string warehouseCode, bool isAdmin, string roleId, string tabRole, string avatarLink, string isPopup, int changePass, string key, string email)
        {
            NI10_Employee currentLogin = new NI10_Employee
            {
                EmployeeCode    = (userId == "admininside" ? "4195" : userId),
                JobTitle        = jobTitleName,
                FullName        = displayName,
                Avatar          = avatarLink,
                CurrentPassword = key,
                EmailAddress    = email
            };

            Session["EmployeeLogin"] = currentLogin;
        }
Example #6
0
 public JsonResult UploadAvatar(HttpPostedFileBase fileImport = null)
 {
     try
     {
         NI10_Employee employee        = (Session["EmployeeLogin"] != null) ? (NI10_Employee)Session["EmployeeLogin"] : new NI10_Employee();
         string        l_imageFileName = "";
         if (Request.Files != null)
         {
             foreach (string file in Request.Files)
             {
                 var uploadedFile = Request.Files[file];
                 if (uploadedFile.ContentLength > 0)
                 {
                     List <string> array = new List <string> {
                         "jpg", "JPG", "jpeg", "JPEG", "icon", "BMP", "bmp", "png", "PNG"
                     };
                     if (array.Contains(uploadedFile.ContentType.Split('/')[1].ToString()) == true)
                     {
                         Bitmap photoFile = StaticFunc.ResizeImage(uploadedFile.InputStream, 200, 200);
                         string img_duoi  = "." + uploadedFile.ContentType.Split('/')[1].ToString();
                         l_imageFileName = employee.EmployeeCode + DateTime.Now.ToString("yyyyMMddHHmmss") + img_duoi;
                         var         appData = Server.MapPath("/Files/Avatar/");
                         ImageFormat format  = StaticFunc.ConvertImageToByteArray(img_duoi);
                         photoFile.Save(Server.MapPath("/Files/Avatar/" + l_imageFileName), format);
                         if (l_imageFileName != "")
                         {
                             PutDataResponse dataResponse = DataFunction.PutDataToService(serviceUrl, "Request/GetData", "",
                                                                                          new List <string>()
                             {
                                 "@EmployeeCode", employee.EmployeeCode,
                                 "@Avatar", l_imageFileName
                             },
                                                                                          "[dbo].[NI10_Employee_UpdateAvatar]");
                             return(Json("/Files/Avatar/" + l_imageFileName, JsonRequestBehavior.AllowGet));
                         }
                     }
                     else
                     {
                         return(Json("0", JsonRequestBehavior.AllowGet)); // File không đúng định dạng ảnh. Vui lòng đổi ảnh khác
                     }
                 }
             }
         }
         return(Json("-1", JsonRequestBehavior.AllowGet)); // Xảy ra lỗi trong quá trình xử lý dữ liệu
     }
     catch (Exception ex)
     {
         return(Json("-1", JsonRequestBehavior.AllowGet)); // Xảy ra lỗi trong quá trình xử lý dữ liệu
     }
 }
Example #7
0
        public ActionResult LoginInfo()
        {
            NI10_Employee employee = (Session["EmployeeLogin"] != null) ? (NI10_Employee)Session["EmployeeLogin"] : new NI10_Employee();

            return(View(employee));
        }