/// <summary> /// 添加学院管理员 /// </summary> public void insertAdmin() { string account = Context.Request["account"].ToString(); string name = Context.Request["name"].ToString(); string sex = Context.Request["sex"].ToString(); string college = Context.Request["college"].ToString(); string email = Context.Request["email"].ToString(); string phone = Context.Request["phone"].ToString(); try { if (teaBll.selectByColl(Convert.ToInt32(college))) { Response.Write("该学院已设置过分院管理员"); Response.End(); } else if (teaBll.selectByteaId(account)) { if (teaBll.GetModel(account).TeaType == 2) { Response.Write("该教师已为分院管理员"); Response.End(); } } else if (teaBll.selectByEmail(email)) {//根据输入的邮箱查找是否已存在 Response.Write("此邮箱已存在"); Response.End(); } else if (teaBll.selectByPhone(phone)) {//根据输入的联系电话查找是否已存在 Response.Write("此联系电话已存在"); Response.End(); } else { tea.TeaAccount = account; tea.TeaName = name; tea.Sex = sex; coll.ColID = int.Parse(college); tea.college = coll; tea.Email = email; tea.Phone = phone; RSACryptoService rsa = new RSACryptoService(); tea.TeaPwd = rsa.Encrypt("000000"); tea.TeaType = 2; result = teaBll.Insert(tea); if (result == Result.添加成功) { LogHelper.Info(this.GetType(), admin.TeaAccount + " - " + admin.TeaName + " - 添加分院管理员"); Response.Write("添加成功"); Response.End(); } else { Response.Write("添加失败"); Response.End(); } } } catch (Exception ex) { LogHelper.Error(this.GetType(), ex); } }
/// <summary> /// 添加教师 /// </summary> public void saveTeacher() { string teaAccount = Context.Request["TeaAccount"].ToString(); if (!teabll.selectByteaId(teaAccount)) { try { int collegeId = Convert.ToInt32(Context.Request["CollegeId"]); //int teaType = Convert.ToInt32(Context.Request["TeaType"]); //string pwd = Context.Request["Pwd"].ToString(); string teaName = Context.Request["TeaName"].ToString(); string sex = Context.Request["Sex"].ToString(); string email = Context.Request["Email"].ToString(); string tel = Context.Request["Tel"].ToString(); if (teabll.selectByEmail(email)) {//根据输入的邮箱查找是否已存在 Response.Write("此邮箱已存在"); Response.End(); } else if (teabll.selectByPhone(tel)) {//根据输入的联系电话查找是否已存在 Response.Write("此联系电话已存在"); Response.End(); } else { Teacher tea = new Teacher(); College college = new College(); Teacher teacher = teabll.GetModel(tealogin.TeaAccount); if (state == 0) { college.ColID = collegeId; } else { college.ColID = tealogin.college.ColID; } tea.college = college; tea.TeaType = 1; tea.TeaAccount = teaAccount; RSACryptoService rsa = new RSACryptoService(); tea.TeaPwd = rsa.Encrypt("000000"); tea.TeaName = teaName; tea.Sex = sex; tea.Email = email; tea.Phone = tel; OpResult result = teabll.Insert(tea); if (result == OpResult.添加成功) { LogHelper.Info(this.GetType(), tealogin.TeaAccount + " - " + tealogin.TeaName + " - 添加教师账号"); Response.Write("添加成功"); Response.End(); } else { Response.Write("添加失败"); Response.End(); } } } catch (Exception ex) { LogHelper.Error(this.GetType(), ex); } } else { Response.Write("此账号已存在"); Response.End(); } }