
function refresh() {
	$('#dg').datagrid('load', {});
	//$("#txtRoomNumber").textbox("reset");
}
//查询
function query() {
    var roomNumber = $("#txtRoomNumber").combobox("getText");
    var cardTypeID = $("#txtCardType").combobox("getValue");
    var cardNumber = $("#txtCardNumber").combobox("getValue");

    var params = {
        roomNumber: (roomNumber == lang.CheckAll ? undefined : roomNumber),
        cardTypeID: (cardTypeID == "" ? 0 : cardTypeID),
        cardNumber: (cardNumber == lang.CheckAll ? undefined : cardNumber),
        startDate: $('#txtStartTime').datetimespinner('getValue'),
        endDate: $('#txtEndTime').datetimespinner('getValue')
    };
    $('#dg').datagrid({ url: '/HostRoomCard/LoadAllByPage/', queryParams: params });
}
//删除刷卡记录
function dgDelete() {
	var rows = $('#dg').datagrid('getSelections');
	if (!rows || rows.length == 0) {
		$.tools.alert(lang.PleaseSelectTheData);
		return;
	}
	var param;
	$.each(rows, function (i, n) {
		if (i == 0) {
		    param = 'idList=' + n.ID;
		} else {
		    param += '&idList=' + n.ID;
		}
	});
	$.tools.delPost(param, '/HostRoomCard/Delete/', function () {
		$('#dg').datagrid('clearSelections');
		$('#dg').datagrid('reload');
	}, this);
}
//清空刷卡记录
function clearData() {
	$.tools.confrimPost(lang.CCrecords, null, "/HostRoomCard/DeleteAll/", function () {
		$('#dg').datagrid("clearSelections");
		$('#dg').datagrid("reload");
	}, this);
} 
//初始化加载数据
$(function () {
    var curTime = new Date();
    var startTime = new Date(curTime.getTime() - 1 * 24 * 60 * 60 * 1000);
    $("#txtStartTime").datebox("setValue", startTime.format('yyyy-MM-dd'));
    $("#txtEndTime").datebox("setValue", curTime.format('yyyy-MM-dd'));
});