Esempio n. 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" });
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 删除
 /// </summary>
 public ActionResult Delete(int id)
 {
     try
     {
         UsersBLL bll = new UsersBLL();
         Users u = bll.Find(id);
         u.U_Role = 4;
         bll.SaveChanges();
         return Json(new { result = "ok" }, JsonRequestBehavior.AllowGet);
     }
     catch
     {
         return Json(new { result = "error" }, JsonRequestBehavior.AllowGet);
     }
 }
Esempio n. 3
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" });
     }
 }
Esempio n. 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" });
     }
 }
Esempio n. 5
0
        public ActionResult Delete(int id)
        {
            try
            {
                ShopsBLL spBll = new ShopsBLL(); UsersBLL uBll = new UsersBLL();

                Shops shop = spBll.Find(id);
                Users user = uBll.SelectWhere(m => m.S_ID == shop.S_ID && m.U_Role == 2).FirstOrDefault();
                using (TransactionScope ts = new TransactionScope())
                {
                    // 软删除当前店铺的管理员
                    if (user != null)
                    {
                        user.U_Role = 4;
                        uBll.SaveChanges();
                    }
                    shop.S_Category = 4;
                    spBll.SaveChanges();
                    ts.Complete();
                }
                return Json(new { result = "ok" });
            }
            catch
            {
                return Json(new { result = "error" });
            }
        }