Пример #1
0
 public ActionResult Add(ADM_USER model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             model.PASSWORD = Com.Mxm.EncryptionHelper.EncodeMD5(model.PASSWORD);
             etMgr.AddToADM_USER(model);
             if (etMgr.SaveChanges() != 0)
             {
                 return(RedirectToAction("Index"));
             }
             else
             {
                 return(RedirectToAction("Add"));
             }
         }
         else
         {
             return(RedirectToAction("Add"));
         }
     }
     catch (Exception ex)
     {
         Com.Mxm.WriteTxt.WriteText(DateTime.Now.ToString() + "\t\n" + ex.Message + ex.StackTrace);
         return(View());
     }
 }
Пример #2
0
        public ActionResult ULogin(string username, string password)
        {
            string   sql = "select top 1 * from adm_user where username=@username";
            ADM_USER mo  = etMgr.ExecuteStoreQuery <ADM_USER>(sql,
                                                              new System.Data.SqlClient.SqlParameter("username", username)).FirstOrDefault <ADM_USER>();

            if (mo != null && mo.PASSWORD == Com.Mxm.EncryptionHelper.EncodeMD5(password))
            {
                FormsAuthentication.RedirectFromLoginPage(username, true);
                Response.Redirect("/");
            }
            else
            {
                var msg = "用户名或密码错误";
                ViewBag.msg = msg;
                //Response.Write("<script type='text/javascript'>alert('" + msg + "');</script>");
            }
            return(View());
        }
Пример #3
0
 public ActionResult Edit(int id, ADM_USER model)
 {
     try
     {
         var mo = etMgr.ADM_USER.FirstOrDefault(m => m.USER_ID == id);
         //TryUpdateModel(mo);
         //if (ModelState.IsValid)
         //{
         if (etMgr.SaveChanges() != 0)
         {
             return(RedirectToAction("Index"));
         }
         //}
     }
     catch (Exception ex)
     {
         Com.Mxm.WriteTxt.WriteText(DateTime.Now.ToString() + "\t\n" + ex.Message + ex.StackTrace);
     }
     return(View());
 }
Пример #4
0
        //
        // GET: /User/Edit/5

        public ActionResult Edit(int id)
        {
            ADM_USER user = etMgr.ADM_USER.Single(x => x.USER_ID == id);

            return(View(user));
        }