102 lines
3.4 KiB
C#
102 lines
3.4 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Web;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
|
||
namespace VRS.Management
|
||
{
|
||
public partial class School_Add : BasePage
|
||
{
|
||
DataService.BLL.admin_school bll = new DataService.BLL.admin_school();
|
||
DataService.BLL.admin_log log = new DataService.BLL.admin_log();
|
||
protected override void Page_Load(object sender, EventArgs e)
|
||
{
|
||
base.Page_Load(sender, e);
|
||
if (!IsPostBack)
|
||
{
|
||
|
||
}
|
||
}
|
||
protected void btnSure_Click(object sender, EventArgs e)
|
||
{
|
||
if (string.IsNullOrEmpty(name.Text.Trim()))
|
||
{
|
||
RadAjaxManager1.Alert("学校名称不能为空!");
|
||
return;
|
||
}
|
||
if (bll.GetRecordCount(string.Format(" school = '{0}' ", name.Text.Trim())) > 0)
|
||
{
|
||
RadAjaxManager1.Alert("学校名称禁止重复!");
|
||
return;
|
||
}
|
||
|
||
//设备名称唯一
|
||
DataService.Model.admin_school model = new DataService.Model.admin_school();
|
||
model.id = BasePage.GetNewId();
|
||
model.school = name.Text.Trim();
|
||
//老师
|
||
if (radio_no_limit_teacher.SelectedValue == "1") //无限制
|
||
{
|
||
model.r1 = "-1";
|
||
}
|
||
else if (radio_no_limit_teacher.SelectedValue == "0") //有限制
|
||
{
|
||
if (string.IsNullOrEmpty(num_teacher.Text))
|
||
{
|
||
RadAjaxManager1.Alert("请输入老师lisence数量!");
|
||
return;
|
||
}
|
||
model.r1 = num_teacher.Text;
|
||
}
|
||
//学生
|
||
if (radio_no_limit_student.SelectedValue == "1") //无限制
|
||
{
|
||
model.r2 = "-1";
|
||
}
|
||
else if (radio_no_limit_student.SelectedValue == "0") //有限制
|
||
{
|
||
if (string.IsNullOrEmpty(num_student.Text))
|
||
{
|
||
RadAjaxManager1.Alert("请输入学生lisence数量!");
|
||
return;
|
||
}
|
||
model.r2 = num_student.Text;
|
||
}
|
||
if (bll.Add(model))
|
||
{
|
||
log.write_log("添加学校成功。" + "名称:" + model.school + ",ID:" + model.id);
|
||
RadAjaxManager1.ResponseScripts.Add("alert('添加成功!');CloseAndRebind();");
|
||
}
|
||
else
|
||
{
|
||
RadAjaxManager1.Alert("添加失败!");
|
||
}
|
||
}
|
||
|
||
protected void radio_limit_teacher_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
if (radio_no_limit_teacher.SelectedValue == "1") //无限制
|
||
{
|
||
num_teacher.Enabled = false;
|
||
}
|
||
else if (radio_no_limit_teacher.SelectedValue == "0") //有限制
|
||
{
|
||
num_teacher.Enabled = true;
|
||
}
|
||
}
|
||
|
||
protected void radio_limit_student_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
if (radio_no_limit_student.SelectedValue == "1") //无限制
|
||
{
|
||
num_student.Enabled = false;
|
||
}
|
||
else if (radio_no_limit_student.SelectedValue == "0") //有限制
|
||
{
|
||
num_student.Enabled = true;
|
||
}
|
||
}
|
||
}
|
||
} |