예제 #1
0
 public ActionResult AllotAdmit(int id)
 {
     UsersBLL usreBll = new UsersBLL();
     string loginName = Request.Form["U_LoginName"];
     int S_ID = Convert.ToInt32(Request.Form["S_ID"]);
     ShopsBLL shopBll = new ShopsBLL();
     Shops s = shopBll.SelectWhere(m => m.S_ID == S_ID).FirstOrDefault();
     Users u = new Users();
     try
     {
         using (TransactionScope ts = new TransactionScope())
         {
             u.U_LoginName = loginName;
             u.U_Password = "******";
             u.S_ID = S_ID;
             u.U_Role = 2;
             s.S_IsHasSetAdmin = true;
             shopBll.SaveChanges();
             usreBll.Add(u);
             usreBll.SaveChanges();
             ts.Complete();
         }
         return Json(new { result = "ok" });
     }
     catch
     {
         return Json(new { result = "error" });
     }
 }
예제 #2
0
 public ActionResult Create(Users u)
 {
     try
     {
         UsersBLL bll = new UsersBLL();
         Users user = Session["user"] as Users;
         u.S_ID = user.S_ID;
         u.U_Password = u.U_Password ?? "1";
         u.U_CanDelete = Request["U_CanDelete"] == "on" ? true : false;
         bll.Add(u);
         bll.SaveChanges();
         return Json(new { result = "ok" });
     }
     catch
     {
         return Json(new { result = "error" });
     }
 }
예제 #3
0
 /// <summary>
 /// 创建新的 Users 对象。
 /// </summary>
 /// <param name="u_ID">U_ID 属性的初始值。</param>
 public static Users CreateUsers(global::System.Int32 u_ID)
 {
     Users users = new Users();
     users.U_ID = u_ID;
     return users;
 }
예제 #4
0
 public ActionResult Edit(Users u)
 {
     try
     {
         UsersBLL bll = new UsersBLL();
         u.U_Password = u.U_Password ?? "1";
         u.U_CanDelete = Request["U_CanDelete"] == "on" ? true : false;
         bll.Edit(u, "U_Password", "U_RealName", "U_Sex", "U_Telephone", "U_Role", "U_CanDelete");
         bll.SaveChanges();
         return Json(new { result = "ok" });
     }
     catch
     {
         return Json(new { result = "error" });
     }
 }