Exemplo n.º 1
0
        // GET: SYS_USER
        public ActionResult Index(string searchName, int?searchDep, int?searchUtype, int?pageNum)
        {
            var users = from s in db.SYS_USER
                        select s;

            List <SYS_DEPART> categories_Dep = SYS_DEPART.GETALL();

            ViewData["categories_Dep"] = new SelectList(categories_Dep, "id", "name");
            List <SYS_USERTYPE> categories_Utype = SYS_USERTYPE.GETALL();

            ViewData["categories_Utype"] = new SelectList(categories_Utype, "id", "typename");

            if (searchDep != null)
            {//部门筛选
                users = users.Where(s => s.departid_fx == searchDep);
            }
            if (searchUtype != null)
            {//用户组筛选
                users = users.Where(s => s.usertypeid_fx == searchUtype);
            }
            if (!String.IsNullOrEmpty(searchName))
            {//搜索名称
                users = users.Where(s => s.cname.Contains(searchName));
            }
            users = users.OrderBy(s => s.departid_fx);
            return(View(users.ToPagedList(pageNum ?? 1, 5)));
        }
Exemplo n.º 2
0
        // GET: SYS_USER/Create
        public ActionResult Create()
        {
            List <SYS_USERTYPE> categories_ug = SYS_USERTYPE.GETALL();

            ViewData["categories_ug"] = new SelectList(categories_ug, "id", "typename");
            List <SYS_DEPART> categories = SYS_DEPART.GETALL();

            ViewData["Categories"] = new SelectList(categories, "id", "name");
            return(View());
        }
Exemplo n.º 3
0
        public ActionResult Edit([Bind(Include = "id,code,cname,account_id,pwd,birthdate,tel,email,departid_fx,usertypeid_fx,desc_text,remark,whocreateid_fx,createdate")] SYS_USER sYS_USER)
        {
            if (ModelState.IsValid)
            {
                db.Entry(sYS_USER).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index", new { id = sYS_USER.id }));
            }
            List <SYS_DEPART> categories = SYS_DEPART.GETALL();

            ViewData["Categories"] = new SelectList(categories, "id", "name");
            return(View(sYS_USER));
        }
Exemplo n.º 4
0
        //Edit:GET
        public ActionResult Edit(int?id)
        {
            List <SYS_DEPART> categories = SYS_DEPART.GETALL();

            ViewData["Categories"] = new SelectList(categories, "id", "name");
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SYS_USER sYS_USER = db.SYS_USER.Find(id);

            if (sYS_USER == null)
            {
                return(HttpNotFound());
            }

            return(View(sYS_USER));
        }
Exemplo n.º 5
0
        public ActionResult Create([Bind(Include = "id,code,cname,account_id,birthdate,tel,email,departid_fx,usertypeid_fx,desc_text,remark,whocreateid_fx,createdate")] SYS_USER sYS_USER)
        {
            Model1 ef       = new Model1();
            String username = Request.Cookies["username"].Value.ToString();
            String cuuserid = ef.SYS_USER.Where(item => item.account_id == username).First <SYS_USER>().id.ToString();

            var obj = ef.SYS_USER.Where(item => item.id > 0);
            int nowcode = 0, maxid = 0;

            if (obj.Count <SYS_USER>() > 0)
            {
                maxid   = obj.Max(item => item.id);
                nowcode = maxid + 1;
            }
            else
            {
                nowcode = 1;
            }

            sYS_USER.pwd            = "123456";
            sYS_USER.whocreateid_fx = int.Parse(cuuserid);
            sYS_USER.createdate     = DateTime.Now;
            sYS_USER.code           = "USR" + nowcode.ToString().PadLeft(5, '0');
            if (ModelState.IsValid)
            {
                db.SYS_USER.Add(sYS_USER);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            List <SYS_DEPART> categories = SYS_DEPART.GETALL();

            ViewData["Categories"] = new SelectList(categories, "id", "name");
            List <SYS_USERTYPE> categories_ug = SYS_USERTYPE.GETALL();

            ViewData["categories_ug"] = new SelectList(categories_ug, "id", "typename");
            return(View(sYS_USER));
        }