public ActionResult Login(String 帳號, String 密碼)
        {
            if (!String.IsNullOrEmpty(帳號) && !String.IsNullOrEmpty(密碼))
            {
                密碼 = CryptographyUtils.SHA256Cryp(密碼);
                客戶資料 tmp = _客戶資料Service.Reads().Where(a => a.帳號.Equals(帳號) && a.密碼.Equals(密碼)).FirstOrDefault();
                if (null != tmp)
                {
                    tmp.密碼 = "";

                    String  userData                 = "";//new JavaScriptSerializer().Serialize(tmp);
                    Boolean IsPersistent             = true;
                    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, tmp.帳號, DateTime.Now, DateTime.Now.AddHours(1), IsPersistent, userData, FormsAuthentication.FormsCookiePath);
                    var        encryptTicket         = FormsAuthentication.Encrypt(ticket);
                    HttpCookie cookie                = new HttpCookie(FormsAuthentication.FormsCookieName, encryptTicket);
                    cookie.HttpOnly = true;
                    this.Response.AppendCookie(cookie);

                    return(RedirectToAction("Index", "客戶明細", null));
                }
                else
                {
                    ModelState.AddModelError("", "帳密錯誤");
                }
            }

            ViewBag.帳號 = 帳號;

            return(View());
        }
        public ActionResult Create(客戶資料 客戶資料)
        {
            if (ModelState.IsValid)
            {
                客戶資料.密碼 = CryptographyUtils.SHA256Cryp(客戶資料.密碼);
                _客戶資料Service.Create(客戶資料);
                return(RedirectToAction("Index"));
            }

            return(View(客戶資料));
        }
 public ActionResult UpdatePwd(int Id, String pwd)
 {
     if (!String.IsNullOrEmpty(pwd))
     {
         客戶資料 entity = _客戶資料Service.Read(Id);
         entity.密碼 = CryptographyUtils.SHA256Cryp(pwd);
         _客戶資料Service.Update(Id, entity);
         return(RedirectToAction("Index"));
     }
     else
     {
     }
     return(View());
 }