protected void deleteUser_Click(object sender, EventArgs e) { { if (dt.Checked) { int uId = Int32.Parse(Request.QueryString["uid"].ToString()); var stud = new adminUser { userId = uId }; db.adminUsers.Attach(stud); db.adminUsers.Remove(stud); db.SaveChanges(); uname.Text = ""; rol.Text = ""; dt.Checked = false; msg.Text = "user deleted successfully"; // Response.Redirect("sviewUsers.aspx?msg="+msg); } else { msg.Text = "Please Check the delete box to confirm"; // Response.Redirect("sviewUsers.aspx?msg=" + msg); } } }
/// <summary> /// 获取员工列表 /// </summary> /// <param name="isService"></param> /// <param name="workNo"></param> /// <returns></returns> public List <adminUser> GetAdminUserList(string sql) { List <adminUser> le = null; using (DataTable dt = helper.GetDataTable(sql)) { if (dt != null && dt.Rows.Count > 0) { le = new List <adminUser>(); foreach (DataRow r in dt.Rows) { adminUser e = new adminUser { id = Convert.ToInt16(r["id"]), name = r["name"].ToString(), uName = r["uName"].ToString(), uPass = r["uPass"].ToString(), limits = r["limits"].ToString(), role = Convert.ToInt16(r["role"]), mobile = r["mobile"].ToString(), memo = r["memo"].ToString(), openid = r["openid"].ToString(), enable = Convert.ToInt16(r["enable"]), addOn = Convert.ToDateTime(r["addOn"]) }; le.Add(e); } } } return(le); }
public ActionResult DeleteConfirmed(int id) { adminUser adminUser = db.adminUsers.Find(id); db.adminUsers.Remove(adminUser); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult adminIndex([System.Web.Http.FromBody] adminAddModel model) { adminUser bo = new adminUser(); bo.userName = model.Account; bo.password = model.Password; conn.adminUser.Add(bo); conn.SaveChanges(); return(View()); }
public ActionResult Edit([Bind(Include = "UserId")] adminUser adminUser) { if (ModelState.IsValid) { db.Entry(adminUser).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.users, "Id", "Name", adminUser.UserId); return(View(adminUser)); }
public ActionResult Create([Bind(Include = "UserId")] adminUser adminUser) { if (ModelState.IsValid) { db.adminUsers.Add(adminUser); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.users.Where(usr => usr.adminUser == null), "Id", "Name", adminUser.UserId); return(View(adminUser)); }
protected void btnUser_Click(object sender, EventArgs e) { niapsEntities1 db = new niapsEntities1(); adminUser admu = new adminUser(); if (usname.Text == string.Empty) { unameMsg.Text = "*"; pswMsg.Text = ""; fnameMsg.Text = ""; } else if (psword.Text == string.Empty) { pswMsg.Text = "*"; fnameMsg.Text = ""; unameMsg.Text = ""; } else if (fname.Text == string.Empty) { fnameMsg.Text = "*"; unameMsg.Text = ""; pswMsg.Text = ""; } else { try { var test = db.adminUsers.Where(u => u.userName == usname.Text).First(); if (test.userName != string.Empty) { unameMsg.Text = "user name already taken"; } } catch (Exception) { admu.userName = usname.Text; admu.full_name = fname.Text; admu.password = CreateHash(psword.Text); admu.role = roles.SelectedValue; admu.status = "active"; db.adminUsers.Add(admu); db.SaveChanges(); unameMsg.Text = ""; usname.Text = ""; psword.Text = ""; pswMsg.Text = ""; fname.Text = ""; fnameMsg.Text = ""; roles.Text = "-select-"; msg.Text = "User Created Successfully"; } } }
// GET: UsersAdmin/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } adminUser adminUser = db.adminUsers.Find(id); if (adminUser == null) { return(HttpNotFound()); } return(View(adminUser)); }
// GET: UsersAdmin/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } adminUser adminUser = db.adminUsers.Find(id); if (adminUser == null) { return(HttpNotFound()); } ViewBag.UserId = new SelectList(db.users, "Id", "Name", adminUser.UserId); return(View(adminUser)); }
protected void Page_Load(object sender, EventArgs e) { int uId = Int32.Parse(Request.QueryString["uid"].ToString()); // var d = db.adminUsers.FirstOrDefault(cs => cs.userId == uId); //db.d //var stud = (from s1 in db.adminUsers where s1.userId == uId select s1).FirstOrDefault(); //db.rem var stud = new adminUser { userId = uId }; db.adminUsers.Attach(stud); db.adminUsers.Remove(stud); db.SaveChanges(); msg.Text = "user deleted successfully"; }
public ActionResult aManage(string name, string id) { var model = conn.adminUser.OrderByDescending(x => x.ID).ToList(); if (!string.IsNullOrEmpty(name)) { model = model.Where(w => w.userName.Contains(name)).ToList(); } if (!string.IsNullOrEmpty(id)) { int uid = System.Convert.ToInt32(id); adminUser post = conn.adminUser.Find(uid); conn.adminUser.Remove(post); conn.SaveChanges(); } return(PartialView("~/Areas/Admin/Views/AccountManage/aManage.cshtml", model)); }
/// <summary> /// 检查用户信息是否正确并返回 /// </summary> /// <param name="mobile"></param> /// <param name="pass"></param> /// <returns></returns> public adminUser checkUser(string LoginName, string LoginPass) { adminUser admin = null; string sql = "select * from tbl_admin_User where LoginName = '" + LoginName + "' and LoginPass = '******' and enable = 0"; try { using (DataTable dt = helper.GetDataTable(sql)) { if (dt != null && dt.Rows.Count > 0) { Dictionary <int, smsChannelSetting> Dic = new _SmsChannelSetting().GetSmsChannelSettingDic(); DataRow r = dt.Rows[0]; admin = new adminUser { ID = Convert.ToInt16(r["id"]), CorpName = r["CorpName"].ToString(), LoginName = r["LoginName"].ToString(), Limits = r["limits"].ToString(), RoleID = Convert.ToInt16(r["RoleID"]), Mobile = r["mobile"].ToString(), Memo = r["memo"].ToString(), Contact = r["Contact"].ToString(), Enable = Convert.ToInt16(r["enable"]), Account = Convert.ToInt32(r["Account"]), AddOn = Convert.ToDateTime(r["addOn"]) }; if (admin.RoleID > 0) { admin.Limits = new _AdminRole().GetLimits(admin.RoleID); } if (Dic.ContainsKey(admin.ID)) { admin.Account = Dic[admin.ID].MaxNum; } } } } catch { } return(admin); }
/// <summary> /// 检查用户信息是否正确并返回 /// </summary> /// <param name="mobile"></param> /// <param name="pass"></param> /// <returns></returns> public adminUser checkUser(string uName, string uPass) { adminUser admin = null; string sql = "select * from t_admin_User where uName = '" + uName + "' and uPass = '******' and enable = 0"; try { using (DataTable dt = helper.GetDataTable(sql)) { if (dt != null && dt.Rows.Count > 0) { DataRow r = dt.Rows[0]; admin = new adminUser { id = Convert.ToInt16(r["id"]), name = r["name"].ToString(), uName = r["uName"].ToString(), uPass = r["uPass"].ToString(), limits = r["limits"].ToString(), role = Convert.ToInt16(r["role"]), mobile = r["mobile"].ToString(), memo = r["memo"].ToString(), openid = r["openid"].ToString(), enable = Convert.ToInt16(r["enable"]), addOn = Convert.ToDateTime(r["addOn"]) }; if (admin.role > 0) { admin.limits = new _AdminRole().GetLimits(admin.role); } } } } catch { } return(admin); }