//获取选中的数据
function validChoose() {
var d = [];
$.each($("#dgCourseScheduleSettingList").cmsXDataTable("getSelections"), function (index) {
d.push(this);
});
return d;
}
function idvalidChoose() {
var d = [];
$.each($("#dgCourseScheduleSettingList").cmsXDataTable("getSelections"), function (index) {
d.push(this.ExaminationSubjectID);
});
return d;
}
function validChooseUserGrade() {
var d = [];
$.each($("#dgUserGrade").cmsXDataTable("getSelections"), function (index) {
d.push(this);
});
return d;
}
//报名按钮
function ExamineApply_Update() {
var d = validChoose();
var id = idvalidChoose().join(',');
var myDateTime = getNowFormatDate();
var newData = new Date(myDateTime.replace("-", "/").replace("-", "/"));
if (d.length == 0) {
$.messager.alert("系统提示", "请选择您要报名的考试科目。");
return;
}
else if (d.length > 1) {
$.messager.alert("系统提示", "每次只能选择一个科目报考。");
return;
}
var isError = false;
$.each(d, function (index, value) {
if (value.EndDate != null) {
var dt1 = new Date();
var dtime = new Date(dt1.getFullYear(), dt1.getMonth(), dt1.getDate());
var dt2 = getDate(value.EndDate);
if (dtime > dt2) {
$.messager.alert("系统提示", "不在报名时间内,不能报名。");
isError = true;
return false;
}
}
});
if (isError) {
return;
}
$.postWithLoading(CMS_SystemConfig.VirtualDirectoryPath + '/ExamineApply/ApplySubmit', { ExaminationSubjectID: id, Version: 10 }, function (data) {
if (data == "报名成功") {
$.messager.alert("系统提示", "报名成功!");
$("#dgCourseScheduleSettingList").cmsXDataTable('load');
$("#dgUserGrade").cmsXDataTable('load');
} else {
$.messager.alert("系统提示", data);
}
});
}
function ExamineApply_Refresh() {
$("#dgCourseScheduleSettingList").cmsXDataTable('load');
$("#dgUserGrade").cmsXDataTable('load');
}
//撤销
function ExamineApply_Cancel() {
var d = validChooseUserGrade();
// var myDateTime = getNowFormatDate();
// var newData = new Date(myDateTime.replace("-", "/").replace("-", "/"));
if (d.length == 0) {
$.messager.alert("系统提示", "请选择您要撤销报名的考试科目。");
return;
}
var dt1 = new Date();
var dtime = new Date(dt1.getFullYear(), dt1.getMonth(), dt1.getDate());
var dt2 = getDate(d[0].EndDate);
var isError = false;
$.each(d, function (index, value) {
if (value.EndDate != null) {
var dt1 = new Date();
var dtime = new Date(dt1.getFullYear(), dt1.getMonth(), dt1.getDate());
var dt2 = getDate(value.EndDate);
if (dtime > dt2) {
$.messager.alert("系统提示", "对不起,已过报名截止时间,不能进行撤销操作!");
isError = true;
return false;
}
}
// if (value.IsRister) {
// $.messager.alert("系统提示", "你已报名,请勿重复报名。");
// isError = true;
// return false;
// }
// if (value.RegisterNum >= value.PeopleNumLimit) {
// $.messager.alert("系统提示", "科目" + value.Name + "已达报考人数上限,暂时无法报名。");
// isError = true;
// return false;
// }
});
if (isError) {
return;
}
$.post('/ExamineApply/ApplyCancel?ExaminationRegistrationIDs=' + $.map(d, function (x) { return x.ExaminationRegistrationID; }).join(','), function (data) {
if (data == "撤销成功") {
$.messager.alert("系统提示", "撤销成功!");
$("#dgCourseScheduleSettingList").cmsXDataTable('load');
$("#dgUserGrade").cmsXDataTable('load');
} else {
$.messager.alert("系统提示", data);
}
});
}
//获取系统时间 时分秒yyyy-MM-dd HH:MM:SS
function getNowFormatDate() {
var d = new Date(), str = '';
str += d.getFullYear() + '-'; //获取当前年份
str += d.getMonth() + 1 + '-'; //获取当前月份(0——11)
str += d.getDate() + '-';
str += d.getHours() + '-';
str += d.getMinutes() + '-';
str += d.getSeconds();
return str;
}
//字符串转时间格式
function getDate(strDate) {
var date = eval('new Date(' + strDate.replace(/\d+(?=-[^-]+$)/,
function (a) { return parseInt(a, 10) - 1; }).match(/\d+/g) + ')');
return date;
}
function CheckIsRister(index, row, value, bb) {
//alert(aa);
if (row.IsRister == true) {
return " ";
//return " " + value + "";
}
else {
return " ";
}
}
function CheckIsRister1(index, row, value, bb) {
//alert(aa);
if (row.IsRister == true) {
return "display :none";
}
else {
return "";
}
}