Exemplo n.º 1
0
        public ActionResult Import(string id)
        {
            try
            {
                HttpFileCollectionBase files = Request.Files;
                DataTable dt  = CommClass.CreateTB("UserName:System.String,UserID:System.String,UserPwd:System.String,UserPermission:System.String,UserState:System.Int32,Remark:System.String");
                string    str = NPOIExcel.ImportExcelFile(files, dt, 1, 0);

                List <M_User> lstUser = new JavaScriptSerializer().Deserialize <List <M_User> >(str);
                bool          iSucc   = SQLDBHelperClient.CreateUser().Add(lstUser);
                if (iSucc)
                {
                    ViewBag.Succ = "1";
                    ViewBag.Msg  = "数据添加成功!";
                    return(View());
                }
                else
                {
                    ViewBag.Succ = "0";
                    ViewBag.Msg  = "数据添加失败!";
                    return(View());
                }
            }
            catch (Exception ex)
            {
                ViewBag.Succ = "0";
                ViewBag.Msg  = "数据添加失败!";
                return(View());
            }
        }
Exemplo n.º 2
0
        public ActionResult Edit(string userid)
        {
            ViewBag.AState = "EDIT";
            M_User User = SQLDBHelperClient.CreateUser().Query(userid);

            return(View("Edit", User));
        }
Exemplo n.º 3
0
 public ActionResult Edit(M_User muser)
 {
     if (ModelState.IsValid)
     {
         SQLDBHelperClient.CreateUser().Update(muser);
         ViewBag.Succ = "1";
         ViewBag.Msg  = "数据编辑成功!";
         //return View("Query");
         return(View("Edit"));
     }
     else
     {
         //ViewData["succ"] = "0";
         ViewBag.Succ = "0";
         ViewBag.Msg  = "数据编辑失败!";
         return(View(muser));
     }
 }
Exemplo n.º 4
0
        public ActionResult Add(M_User muser)
        {
            muser.AddOrUpdateUserID = "";
            bool iTrue = SQLDBHelperClient.CreateUser().Add(muser);

            if (iTrue)
            {
                ViewBag.Succ = "1";
                ViewBag.Msg  = "数据添加成功!";
                return(View(new M_User()));
            }
            else
            {
                ViewBag.Succ = "0";
                ViewBag.Msg  = "数据添加失败!";
                return(View(muser));
            }
        }
Exemplo n.º 5
0
        public ActionResult Delete(string userid)
        {
            bool iSucc = false;

            //if (string.IsNullOrEmpty(userid))
            //{
            if (Request.Params["userids"] != null)
            {
                string[] strUserid = Request.Params["userids"].Split(',');
                iSucc = SQLDBHelperClient.CreateUser().Remove(Request.Params["userids"].Split(',').ToList());
            }
            //}
            if (iSucc)
            {
                ViewBag.Succ = "1";
                ViewBag.Msg  = "数据删除成功!";
            }
            else
            {
                ViewBag.Succ = "0";
                ViewBag.Msg  = "数据删除失败!";
            }
            return(View("Query"));
        }
Exemplo n.º 6
0
 public ActionResult Export(string id)
 {
     try
     {
         string sWhere = "";
         //条件
         WhereFilter QF = null;
         if (!string.IsNullOrEmpty(Request.Params["where"]))
         {
             QF = new JavaScriptSerializer().Deserialize <WhereFilter>(Request.Params["where"]);
             //sWhere = QF.GetWhere();
         }
         //DataTable dt = SQLDBHelper.MUser.QueryDT(sWhere, 1, int.MaxValue);
         M_Data_Paging <M_User> lstMUserPage = SQLDBHelperClient.CreateUser().Query(QF, 1, int.MaxValue);
         Stream stream = NPOIExcel.RenderDataTableToExcelHSS(lstMUserPage.lstTObj);
         ViewBag.Succ = "1";
         ViewBag.Msg  = "数据下载成功!";
         return(File(stream, "application/vnd.ms-excel", DateTime.Now.Ticks + ".xls"));
     }
     catch (Exception ex)
     {
         return(View("Query"));
     }
 }