MVC-CZBK.ItcastOA.WebApp.Controllers.UserInfoController

using CZBK.ItcastOA.Model;
using CZBK.ItcastOA.Model.EnumType;
using CZBK.ItcastOA.Model.Search;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CZBK.ItcastOA.WebApp.Controllers
{
    public class UserInfoController :BaseController //Controller
    {
        //
        // GET: /UserInfo/
        IBLL.IUserInfoService UserInfoService{get;set;}
        public ActionResult Index()
        {
            return View();
        }

        #region 获取用户列表数据
        public ActionResult GetUserInfoList()
        {
            int pageIndex = Request["page"] != null ? int.Parse(Request["page"]) : 1;
            int pageSize = Request["rows"] != null ? int.Parse(Request["rows"]) : 5;
            //接收搜索条件
            string userName = Request["name"];
            string userRemark = Request["remark"];
             int totalCount=0;
            //构建搜索条件.
            UserInfoSearch userInfoSearch = new UserInfoSearch() { 
              UserName=userName,
              UserRemark=userRemark,
              PageIndex=pageIndex,
              PageSize=pageSize,
              TotalCount=totalCount
            };
            short delFlag = (short)DeleteEnumType.Normarl;
            //根据构建好的搜索条件完成搜索
            var userInfoList = UserInfoService.LoadSearchEntities(userInfoSearch, delFlag);
           
           
            //获取分页数据。
            //var userInfoList= UserInfoService.LoadPageEntities<int>(pageIndex, pageSize, out totalCount, c => c.DelFlag == delFlag, c => c.ID,true);

            var temp = from u in userInfoList
                       select new {
                           ID=u.ID,
                       UName=u.UName,
                       UPwd=u.UPwd,
                       Remark=u.Remark,
                       SubTime=u.SubTime
                       };

            return Json(new { rows = temp, total = userInfoSearch.TotalCount }, JsonRequestBehavior.AllowGet);
        }
        #endregion

        #region 删除用户数据
        public ActionResult DeleteUserInfo()
        {
            string strId=Request["strId"];
            string[]strIds=strId.Split(',');
            List<int> list = new List<int>();
            foreach (string id in strIds)
            {
                list.Add(Convert.ToInt32(id));
            }
            //将list集合存储的的要删除的记录的编号传递到业务层.
            if (UserInfoService.DeleteEntities(list))
            {
                return Content("ok");
            }
            else
            {
                return Content("no");
            }
        }
        #endregion

        #region 添加用户数据
        public ActionResult AddUserInfo(UserInfo userInfo)
        {
            userInfo.DelFlag = 0;
            userInfo.ModifiedOn = DateTime.Now;
            userInfo.SubTime = DateTime.Now;
            UserInfoService.AddEntity(userInfo);
            return Content("ok");
        }
        #endregion
        #region 展示要修改的数据
        public ActionResult ShowEditInfo()
        {
            int id = int.Parse(Request["id"]);
           var userInfo= UserInfoService.LoadEntities(u=>u.ID==id).FirstOrDefault();
           return Json(userInfo, JsonRequestBehavior.AllowGet);
        }

        #endregion
        #region 完成用户数据的更新
         public ActionResult EditUserInfo(UserInfo userInfo)
        {
        
            userInfo.ModifiedOn = DateTime.Now;
            if (UserInfoService.EditEntity(userInfo))
            {
                return Content("ok");
            }
            else
            {
                return Content("no");
            }
        }
        #endregion
       

    }
}
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值