gyhlw_dotnet/网站项目/VRS/Management/VSAT/ExamBatch_Add.aspx.cs

148 lines
5.0 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace VRS.Management.VSAT
{
public partial class ExamBatch_Add : BasePage
{
DataService.BLL.pro_exam_batch bll = new DataService.BLL.pro_exam_batch();
DataService.BLL.admin_log log = new DataService.BLL.admin_log();
DataService.BLL.admin_user bll_user = new DataService.BLL.admin_user();
protected override void Page_Load(object sender, EventArgs e)
{
base.Page_Load(sender, e);
if (!IsPostBack)
{
var user = DataService.BLL.admin_user.load_login();
var user_login = bll_user.GetModel(user.user_id);
if (bll_user.IsAdministrator(user_login))
{
tr_school.Visible = true;
BindSchool(dp_school, "");
}
else //老师或学校管理员
{
tr_school.Visible = false;
BindSchoolGrade(user_login.school_id, dp_schoolgrade, "");
}
BindExam(dp_exam, "","考试");
}
}
protected void dp_school_SelectedIndexChanged(object sender, Telerik.Web.UI.DropDownListEventArgs e)
{
//var value = dp_school.SelectedValue;
//BindSchoolGrade(value, dp_schoolgrade, "");
}
protected void btnSure_Click(object sender, EventArgs e)
{
DataService.Model.pro_exam_batch model = new DataService.Model.pro_exam_batch();
var user = DataService.BLL.admin_user.load_login();
var user_login = bll_user.GetModel(user.user_id);
if (bll_user.IsAdministrator(user_login))
{
if (!string.IsNullOrEmpty(dp_school.SelectedValue))
{
model.school_id = dp_school.SelectedValue;
}
else
{
RadAjaxManager1.Alert("学校不能为空!");
return;
}
}
else //老师或学校管理员
{
model.school_id = user_login.school_id;
}
/*
if (string.IsNullOrWhiteSpace(dp_schoolgrade.SelectedValue))
{
RadAjaxManager1.Alert("请选择班级!");
return;
}
model.grade = dp_schoolgrade.SelectedValue;
*/
if (string.IsNullOrEmpty(batch_name.Text.Trim()))
{
RadAjaxManager1.Alert("考场名称不能为空!");
return;
}
if (bll.GetRecordCount(string.Format(" batch_name = '{0}' and school_id='{1}' ", batch_name.Text.Trim(), model.school_id)) > 0)
{
RadAjaxManager1.Alert("考场名称禁止重复!");
return;
}
if (string.IsNullOrEmpty(ks_minute.Text.Trim()))
{
RadAjaxManager1.Alert("考试时长不能为空!");
return;
}
if (string.IsNullOrEmpty(dp_exam.SelectedValue))
{
RadAjaxManager1.Alert("试卷不能为空!");
return;
}
if (!string.IsNullOrWhiteSpace(start_time.Value))
{
model.start_time = DateTime.Parse(start_time.Value);
}
if (!string.IsNullOrWhiteSpace(end_time.Value))
{
model.end_time = DateTime.Parse(end_time.Value);
}
/*
int minute = -1;
int.TryParse(ks_minute.Text, out minute);
if (minute <= 0 || minute > 600)
{
RadAjaxManager1.Alert("考试时长应该在10小时之内");
return;
}
*/
var ts = model.end_time.Value.Subtract(model.start_time.Value).TotalSeconds;
int minute = (int)ts / 60;
if (minute <= 0 || minute > 600)
{
RadAjaxManager1.Alert("考试时长应该在10小时之内");
return;
}
model.ks_minute = minute;
model.batch_id = BasePage.GetId();
model.batch_name = batch_name.Text.Trim();
model.sjms = "";
model.create_time = DateTime.Now;
model.exam_id = dp_exam.SelectedValue;
model.state = int.Parse(ddp_state.SelectedValue);
//model.state = 0; //状态 0停用1启用
if (bll.Add(model))
{
log.write_log("添加考场成功。" + "名称:" + batch_name.Text.Trim() + "id" + model.batch_id);
RadAjaxManager1.ResponseScripts.Add("alert('添加成功!');CloseAndRebind();");
}
else
{
RadAjaxManager1.Alert("添加失败!");
}
}
}
}