public List <SelectListItem> GetListCongDoan(string sSystemId, string sLastCongDoan)
        {
            List <SelectListItem> listCongDoan = new List <SelectListItem>();

            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                try
                {
                    var  listRaw  = dc.GetCongDoanLiveboard(sSystemId).ToList <SelectListReturn>();
                    bool isSelect = false;

                    if (sLastCongDoan == null)
                    {
                        listCongDoan.Add(new SelectListItem()
                        {
                            Text = CommonHeader.CongDoanAllText, Value = CommonHeader.CongDoanAllValue, Selected = true
                        });
                    }
                    else
                    {
                        listCongDoan.Add(new SelectListItem()
                        {
                            Text = CommonHeader.CongDoanAllText, Value = CommonHeader.CongDoanAllValue, Selected = false
                        });
                    }

                    for (int i = 0; i < listRaw.Count; i++)
                    {
                        if (listRaw[i].value == sLastCongDoan)
                        {
                            isSelect = true;
                        }
                        else
                        {
                            isSelect = false;
                        }

                        listCongDoan.Add(new SelectListItem()
                        {
                            Text = listRaw[i].text, Value = listRaw[i].value, Selected = isSelect
                        });
                    }
                }
                catch (Exception ex)
                {
                    ZEMP_LOG zlog = new ZEMP_LOG()
                    {
                        Ngay           = DateTime.Now,
                        LogKey         = "GetCongDoanLiveboard",
                        LogDescription = string.Format("Exeption Msg: {0} ,SystemId: {1}", ex.Message, sSystemId)
                    };
                    dc.ZEMP_LOG.Add(zlog);
                    dc.SaveChanges();
                }
            }
            return(listCongDoan);
        }
Beispiel #2
0
        public List <SelectListItem> GetListCapDoByUsername(ZEMP_USER account)
        {
            bool isSelect = false;
            List <SelectListItem> selectList = new List <SelectListItem>();

            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                try
                {
                    var listRaw = dc.GetListCapDo(account.SystemId, account.Username).ToList <SelectListReturn>();

                    for (int i = 0; i < listRaw.Count; i++)
                    {
                        if (account.LastCapDo != "")
                        {
                            if (listRaw[i].value == account.LastCapDo)
                            {
                                isSelect = true;
                            }
                            else
                            {
                                isSelect = false;
                            }
                        }
                        else
                        {
                            if (i == 0)
                            {
                                isSelect = true;
                            }
                            else
                            {
                                isSelect = false;
                            }
                        }
                        selectList.Add(new SelectListItem()
                        {
                            Text = listRaw[i].text, Value = listRaw[i].value, Selected = isSelect
                        });
                    }
                }
                catch (Exception ex)
                {
                    ZEMP_LOG zlog = new ZEMP_LOG()
                    {
                        Ngay           = DateTime.Now,
                        LogKey         = "GetListCapDoByUsername",
                        LogDescription = string.Format("Exeption Msg: {0} , Username: {1} , LastCapDo: {2}",
                                                       ex.Message, account.Username, account.LastCapDo)
                    };
                    dc.ZEMP_LOG.Add(zlog);
                    dc.SaveChanges();
                }
            }
            return(selectList);
        }
        public List <SelectListItem> GetModeView(ZEMP_USER account)
        {
            List <SelectListItem> listMode = new List <SelectListItem>();

            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                try
                {
                    var  listRaw  = dc.GetModeView(account.SystemId).ToList <SelectListReturn>();
                    bool isSelect = false;
                    for (int i = 0; i < listRaw.Count; i++)
                    {
                        isSelect = false;
                        if (account.LastMode == null)
                        {
                            if (i == 0)
                            {
                                isSelect = true;
                            }
                            else
                            {
                                isSelect = false;
                            }
                        }
                        else
                        {
                            if (account.LastMode == listRaw[i].value)
                            {
                                isSelect = true;
                            }
                            else
                            {
                                isSelect = false;
                            }
                        }

                        listMode.Add(new SelectListItem()
                        {
                            Value = listRaw[i].value, Text = listRaw[i].text, Selected = isSelect
                        });
                    }
                }
                catch (Exception ex)
                {
                    ZEMP_LOG zlog = new ZEMP_LOG()
                    {
                        Ngay           = DateTime.Now,
                        LogKey         = "GetModeView",
                        LogDescription = string.Format("Exeption Msg: {0} ,SystemId: {1}", ex.Message, account.SystemId)
                    };
                    dc.ZEMP_LOG.Add(zlog);
                    dc.SaveChanges();
                }
            }
            return(listMode);
        }
Beispiel #4
0
        public ActionResult ChangePassword(UserManager user)
        {
            var loggedUser = Session["Username"] as BI_USER;

            user.Username = loggedUser.Username;
            if (user.JobPosition == null)
            {
                user.JobPosition = loggedUser.GhiChu;
            }

            if (loggedUser == null)
            {
                RedirectToAction("Index", "Login");
            }

            if ((user.CurrentPassword == null) && (user.Password == null) &&
                (user.PasswordCofirm == null))
            {
                return(View("ChangePassword", user));
            }


            if (!ModelState.IsValid)
            {
                return(View("ChangePassword", user));
            }
            using (TKTDSXEntities dc = new TKTDSXEntities())
            {
                string strPwd     = user.CurrentPassword.Trim();
                string strEncrypt = CryptorEngine.Encrypt(strPwd, true);
                //Check exist user
                BI_USER existUser = dc.BI_USER.Where(x => x.MANDT == "900" && x.SYSID == "P01" &&
                                                     x.Username == user.Username).FirstOrDefault();
                if ((user.CurrentPassword != null) && (strEncrypt != existUser.Password))
                {
                    ModelState.AddModelError("CurrentPassword", "Current Password Incorrect");
                    return(View("ChangePassword", user));
                }
                else
                {
                    user.CurrentPassword = existUser.Password;
                }

                if ((user.Password != user.PasswordCofirm) && ((user.Password != null) || (user.PasswordCofirm != null)))
                {
                    ModelState.AddModelError("Password", "New Password do not match with confirm password");
                    return(View("ChangePassword", user));
                }

                if (user.Password == existUser.Password)
                {
                    ModelState.AddModelError("Password", "New Password must different exist password");
                    return(View("ChangePassword", user));
                }
                else
                {
                    existUser.Password = user.Password;
                    existUser.GhiChu   = user.JobPosition;

                    string newPwd = existUser.Password.Trim();

                    string strEncryptPwd = CryptorEngine.Encrypt(newPwd, true);

                    existUser.Password = strEncryptPwd;

                    dc.BI_USER.Attach(existUser);
                    var entry = dc.Entry(existUser);
                    entry.Property(e => e.Password).IsModified = true;
                    entry.Property(e => e.GhiChu).IsModified   = true;
                    dc.SaveChanges();

                    Session["Username"]           = existUser;
                    ViewBag.SuccessChangePassword = "******";
                    return(View("ChangePassword", user));
                }
            }
        }