【分页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. U3D 2D游戏之黑暗纪元 2D游戏基础入门开发全(1)

    第一个U3D 2D游戏的例子,全部自己编写,算是入门用,这里记录一下. 1.首先游戏把层次布置好,这里分为 背景层,游戏层,UI层 背景层 (Background-1):就是单纯的背景显示作用. 游戏 ...

  2. Velocity 模板引擎介绍

    一.变量 1. 变量定义 #set($name =“velocity”) 2. 变量的使用 在模板文件中使用$name 或者${name} 来使用定义的变量.推荐使用${name} 这种格式,因为在模 ...

  3. LSJ_NHibernate第三章 IDAL,DAL,BLL

    前言: 做项目(面向数据编程),首先必须了解业务,这是核心,不懂业务写出来的代码毫无意义.业务我这里分为两种,简单业务操作,复杂业务操作,我以他们操作表的界限进行区分,假设我更新一条数据,只操作了一张 ...

  4. c#中的重写方法与隐藏方

    1.父类中有方法a,添加virtua修饰符可声明为虚方法,在子类中可以用override声明后重写方法a. 2.父类中有方法a,在子类中可以有new修饰符声明后隐藏父类方法. 子类重写方法后,对于子类 ...

  5. Invalid SOAP message or SOAP version mismatch

    在把过车数据上传到海康平台的时候返回: Invalid SOAP message or SOAP version mismatch 网上找了说是协议问题,但是不知道如何解决: 我用客户端是c#2.0; ...

  6. 03_MySQL中文乱码处理_01_MySQl数据库字符集知识

    [MySql数据库常见字符集介绍] 在互联网环境中,使用MySql时常用的字符集有: [如何选择合适的字符集] 1.如果处理各种各样的文字,发布到不同语言的国家地区,应选Unicode字符集,对MyS ...

  7. Linux常用(持续更新)

    1. scp ./bcec_computernode_check.sh  root@10.254.3.1:/tmp 2. # uname -a # cat /proc/version # cat /e ...

  8. QListWidget 删除选中项目

    void MainWindow::on_action_Del_triggered() { QList<QListWidgetItem*> selectedItems = ui->li ...

  9. 理解Java中的协变返回类型

    在面向对象程序设计中,协变返回类型指的是子类中的成员函数的返回值类型不必严格等同于父类中被重写的成员函数的返回值类型,而可以是更 "狭窄" 的类型. Java 5.0添加了对协变返 ...

  10. 菜鸟的MySQL学习笔记(三)

    4-1插入记录INSERT INSERT [INTO] tbl_name [(col_name)] {VALUES|VALUE} ({expr|DEFAULT},...), (...), ...   ...