ASP.NET MVC 增强Convert用法+【分页2】
【分页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】的更多相关文章
- asp.net MVC过滤器的用法(转)
转自:http://www.studyofnet.com/news/257.html APS.NET MVC中的每一个请求,都会分配给相应的控制器和对应的行为方法去处理,而在这些处理的前前后后如果想再 ...
- asp.net mvc 的几种分页Pager
第一种 /// <summary> /// 分页Pager显示 /// </summary> /// <param name="html">&l ...
- Asp.Net MVC结合ExtJs gridPanel 分页和高度自适应
Ext.onReady(function () { gridPanel(); var panel = Ext.getCmp('gridPanel'); window.onresize = functi ...
- Asp.Net MVC EasyUI DataGrid查询分页
function doSearch() { //查询方法 var searchValue = $('#txtQueryTC001').textbox('getText'); $('#dgCMSTC') ...
- Asp.Net Mvc Areas 的用法与好处
前言 在项目中为什么要使用Areas 进行分离 大家都知道,一般的Web应用都有前台(面向用户)和后台(面向管理员)两部分,我们希望以/localhost/Admin 开始的Url 是用户的后台管理地 ...
- ASP.NET MVC Html.BeginForm用法1
Html.BeginForm():该方法用于构建一个From表单的开始, 他的构造方法为:Html.BeginForm("ActionName","ControllerN ...
- asp.net mvc 简易通用自定义Pager实现分页
asp.net mvc 自定义Pager实现分页 Intro 一个WEB应用程序中经常会用到数据分页,本文将实现一个简单通用的分页组件,包含一个 PagerModel (用来保存页码信息),一个 Ht ...
- ASP.NET MVC分页实现
ASP.NET MVC中不能使用分页控件,所以我就自己写了一个分页局部视图,配合PageInfo类,即可实现在任何页面任意位置呈现分页,由于采用的是基于POST分页方式,所以唯一的限制就是必须放在FO ...
- 在 ASP.NET MVC 中充分利用 WebGrid (microsoft 官方示例)
在 ASP.NET MVC 中充分利用 WebGrid https://msdn.microsoft.com/zh-cn/magazine/hh288075.aspx Stuart Leeks 下载代 ...
随机推荐
- eclipse 手动安装皮肤
关于自动使用eclipse 主题不成功的给出现在手动的安装方法和jar包 http://pan.baidu.com/s/1kVNEiYr http://pan.baidu.com/s/1cyTZrS ...
- Top 10 Uses of a Message Queue
Top 10 Uses of a Message QueueAsynchronicity, Work Dispatch, Load Buffering, Database Offloading, an ...
- EF中使用数据库的标量值函数
参考资料:https://msdn.microsoft.com/zh-cn/library/dd456847(v=vs.110).aspx http://stackoverflow.com/quest ...
- 20151210jquery进阶 代码备份
$(function () { /*$('form input[type=button]').click(function() { $.ajax({ type:'POST', //url:'http: ...
- Eclipse中绑定java源代码
如何在Eclipse sdk中查看jar源代码如:*.jar 1.点 “window”-> "Preferences" -> "Java" -&g ...
- ACM——A + B Problem (4)
A + B Problem (4) 时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte总提交:2496 测试通过:124 ...
- VS2010 测试 -普通单元测试
http://www.cnblogs.com/rhythmK/archive/2012/04/20/2458832.html
- memcache的分布式算法(转)
memcached的分布式 正如第1次中介绍的那样, memcached虽然称为“分布式”缓存服务器,但服务器端并没有“分布式”功能. 服务器端仅包括 第2次. 第3次 前坂介绍的内存存储功能,其实现 ...
- 关于使用用友华表Cell控件按需打印行的方法
分享下只需一个cll文件按需打印行的觉得最好的方式:1.cell文件要打印行的地方最好不要全删了,留一行,设置好单元格样式(字体.对齐方式.折行自适应等),后面会省一些代码: 2.使用CopyRang ...
- Objective-C MRC多个对象相互引用的内存管理
在MRC环境下,假定CTRoom对象是CTPerson的一个成员变量,那么修改CTRoom对象时应注意,代码如下: - (void) setRoom:(CTRoom *) room { //需判断新旧 ...