【分页2】

  	public dynamic PageQuery()        {
            int pageIndex = Request.Params["page"] == null ?  : int.Parse(Request.Params["page"]);//Request["page"] 需要显示第几页 EasyUI datagrid自传
            int pageSize = Request.Params["rows"] == null ?  : int.Parse(Request.Params["rows"]);//每页大小 EasyUI datagrid自传
            try {
                BackUserInfoPageCondition condition = new BackUserInfoPageCondition
                {
                    pageIndex=pageIndex,
                    pageSize=pageSize,
                    UserCode = Request.Params["search_UserCode"],
                    UserName = Request.Params["search_UserName"],
                    IDNO = Request.Params["search_IDNO"],
                    Phone = Request.Params["search_Phone"],
                    DepartId = Request.Params["search_Depart"].Trim().ConvertTo<int>(),//默认-1请选择
                    DutyId = Request.Params["search_Duty"].Trim().ConvertTo<int>() ,
                    StatusFlag = Request.Params["search_StatusFlag"].Trim().ConvertTo<short?>(),
                    DimissionFlag = Request.Params["search_DimissionFlag"].Trim().ConvertTo<short?>(),
                    DisableFlag = Request.Params["search_DisableFlag"].Trim().ConvertTo<short?>(),
                    LockFlag = Request.Params["search_LockFlag"].Trim().ConvertTo<short?>()
                };
                var data = _IBackUserInfoService.PageQuery(condition);//根据条件query查询
                var o = new { total = condition.total, rows = data };//EasyUI datagrid需要
                return Json(o);
            }
            catch (Exception e)
            {
                //写日志
                return Content("ERROR");
            }
        }  
using System;using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web; namespace Common
{
    public static class Utils
    {
        
        /// <summary>
        /// MD5加密
        /// https://social.msdn.microsoft.com/Forums/zh-CN/590bd6a8-57d7-4041-81da-80fe8b832b77/md5
        /// http://blog.163.com/m13864039250_1/blog/static/21386524820150231533602/
        /// </summary>
        public static string GetMD5Hash(string input){
            //MD5 md5Hash = MD5.Create();
            MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
            byte[] data=md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));
            StringBuilder sBuilder = new StringBuilder();
            for (int i = ; i < data.Length; i++)
            {
                sBuilder.Append(data[i].ToString("x2"));//字符串格式控制符 x 为十六进制 2每次两位数
            }//0xA、0x1A,这样看起来不整齐,为了好看,可以指定"X2",这样显示出来就是:0x0A、0x1A。 
            return sBuilder.ToString();
        }         /// <summary>
        /// 任意类型之间的转换
        /// 来源:http://www.cnblogs.com/artech/archive/2011/03/17/NullableType.html
        /// 用法:
        /// Utils.ConvertTo<short?>(Request.Params["LockFlag"])
        /// Request.Params["LockFlag"].ConvertTo<short?>()
        /// int intValue1               = "123".ConvertTo<int>();
        /// int? intValue2              = "123".ConvertTo<int?>();           
        /// DateTime dateTimeValue1     = "1981-08-24".ConvertTo<DateTime>();
        /// DateTime? dateTimeValue2    = "1981-08-24".ConvertTo<DateTime?>();
        /// </summary>
        public static T ConvertTo<T>(this IConvertible convertibleValue)
        {
            if (null == convertibleValue)
            {
                return default(T);
            }
            if (!typeof(T).IsGenericType)
            {
                return (T)Convert.ChangeType(convertibleValue, typeof(T));
            }
            else
            {
                Type genericTypeDefinition = typeof(T).GetGenericTypeDefinition();
                if (genericTypeDefinition == typeof(Nullable<>))
                {
                    return (T)Convert.ChangeType(convertibleValue, Nullable.GetUnderlyingType(typeof(T)));
                }
            }
            throw new InvalidCastException(string.Format("Invalid cast from type \"{0}\" to type \"{1}\".", convertibleValue.GetType().FullName, typeof(T).FullName));
        }
    }
}  

ASP.NET MVC 增强Convert用法+【分页2】的更多相关文章

  1. asp.net MVC过滤器的用法(转)

    转自:http://www.studyofnet.com/news/257.html APS.NET MVC中的每一个请求,都会分配给相应的控制器和对应的行为方法去处理,而在这些处理的前前后后如果想再 ...

  2. asp.net mvc 的几种分页Pager

    第一种 /// <summary> /// 分页Pager显示 /// </summary> /// <param name="html">&l ...

  3. Asp.Net MVC结合ExtJs gridPanel 分页和高度自适应

    Ext.onReady(function () { gridPanel(); var panel = Ext.getCmp('gridPanel'); window.onresize = functi ...

  4. Asp.Net MVC EasyUI DataGrid查询分页

    function doSearch() { //查询方法 var searchValue = $('#txtQueryTC001').textbox('getText'); $('#dgCMSTC') ...

  5. Asp.Net Mvc Areas 的用法与好处

    前言 在项目中为什么要使用Areas 进行分离 大家都知道,一般的Web应用都有前台(面向用户)和后台(面向管理员)两部分,我们希望以/localhost/Admin 开始的Url 是用户的后台管理地 ...

  6. ASP.NET MVC Html.BeginForm用法1

    Html.BeginForm():该方法用于构建一个From表单的开始, 他的构造方法为:Html.BeginForm("ActionName","ControllerN ...

  7. asp.net mvc 简易通用自定义Pager实现分页

    asp.net mvc 自定义Pager实现分页 Intro 一个WEB应用程序中经常会用到数据分页,本文将实现一个简单通用的分页组件,包含一个 PagerModel (用来保存页码信息),一个 Ht ...

  8. ASP.NET MVC分页实现

    ASP.NET MVC中不能使用分页控件,所以我就自己写了一个分页局部视图,配合PageInfo类,即可实现在任何页面任意位置呈现分页,由于采用的是基于POST分页方式,所以唯一的限制就是必须放在FO ...

  9. 在 ASP.NET MVC 中充分利用 WebGrid (microsoft 官方示例)

    在 ASP.NET MVC 中充分利用 WebGrid https://msdn.microsoft.com/zh-cn/magazine/hh288075.aspx Stuart Leeks 下载代 ...

随机推荐

  1. Linux基础1之磁盘与分区

    Linux上面设备皆文件,目前需要知道的,比如U盘和SARA硬盘的在Linux上面的文件名,/dev/sd[a-p].与IDE接口不同的是,SATA/USB接口的磁盘没有一定的顺序,这里就根据Linu ...

  2. apache2.2 + tomcat6 整合以及集群配置整理

    运行环境:apache2.2.X + tomcat6.0.X + window xp 1. 安装Apache,服务启动后在浏览器中输入http://localhost进行测试,如果能看到一个" ...

  3. C++ 变量转换

    atoi,atol,strtod,strtol,strtoul实现类型转换2006-02-13 版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明http://ivanvic.blogb ...

  4. swing容器继承重绘问题解决

    swing容器继承重绘问题解决   以JPanel为例,继承JPanel,想动态为器更换背景,这就涉及到重绘问题.一下是本人重写代码: package ui; import java.awt.Grap ...

  5. 暑假集训(2)第九弹 ----- Points on Cycle(hdu1700)

                                                Points on Cycle Time Limit:1000MS     Memory Limit:32768 ...

  6. 第3章文件I/O总结

    1. open和create函数在fcntl.h中,close.lseek.read.write函数在unistd.h中 open函数通过进程有效用户ID判断读文件的权限 可以调用access函数判断 ...

  7. 九度OJ 1527 首尾相连数组的最大子数组和 -- 动态规划

    题目地址:http://ac.jobdu.com/problem.php?pid=1527 题目描述: 给定一个由N个整数元素组成的数组arr,数组中有正数也有负数,这个数组不是一般的数组,其首尾是相 ...

  8. 降低IIScup使用率,提高性能

    智能提醒webservice在高峰期间CPU使用率达到50%,内存消耗2G优化方法:启用IIS的Web Garden. 步奏如下: 在IIS7中,选择对应的应用程序池 然后右键高级设置. 把其中的最大 ...

  9. 提高C#编程水平不可不读的50个要诀

    提高C#编程水平的50个要点 1.总是用属性 (Property) 来代替可访问的数据成员 2.在 readonly 和 const 之间,优先使用 readonly 3.在 as 和 强制类型转换之 ...

  10. input多选图片与显示

    input标签 在使用input选择文件时遇到了 在遍历input file.files 只显示最后一个,修改如下: CSS: <style type="text/css"& ...