//取消选择 protected void btnCalcel_Click(object sender, EventArgs e) { BLL.teacher bll = new BLL.teacher(); Model.teacher model = bll.GetModel(this.id); var selectList = new List <int>(); var unSelectList = new List <int>(); StringBuilder tempStr = new StringBuilder(); for (int i = 0; i < rptList2.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList2.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList2.Items[i].FindControl("chkId"); if (cb.Checked) { selectList.Add(id); } else { unSelectList.Add(id); tempStr.Append(id + ","); } } if (selectList.Count == 0) { JscriptMsg("请选择研究生!", string.Empty); return; } model.students = Utils.DelLastComma(tempStr.ToString()); foreach (var item in selectList) { BLL.student studentBll = new BLL.student(); Model.student studentModel = studentBll.GetModel(Utils.ObjToInt(item)); //学术型研究生 if (studentModel.is_aca == "1") { model.resquota = (Utils.ObjToInt(model.resquota) + 1).ToString(); } else { model.pro_resquota = (Utils.ObjToInt(model.pro_resquota) + 1).ToString(); } studentModel.status = "导师未通过您的申请,请再次操作选择其他导师"; studentBll.Update(studentModel); } if (!bll.Update(model)) { JscriptMsg("保存过程中发生错误啦!", string.Empty); return; } JscriptMsg("取消选择研究生成功!", Utils.CombUrlTxt("teacher_list.aspx", "keywords={0}&property={1}", this.keywords, this.property)); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("teacher", DTEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; //成功数量 int errorCount = 0; //失败数量 BLL.teacher bll = new BLL.teacher(); Repeater rptList = new Repeater(); rptList = this.rptList1; for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { var model = bll.GetModel(id); if (!string.IsNullOrEmpty(model.students)) { JscriptMsg("导师【" + model.name + "】已经选择学生,无法删除!", "back"); return; } BLL.student studentBll = new BLL.student(); var studentList = studentBll.GetList(0, " teacher_id!='' and teacher_id is not null", "id asc"); var teacherIdList = new List <string>(); foreach (DataRow item in studentList.Rows) { teacherIdList.Add(Utils.ObjectToStr(item["teacher_id"])); } if (teacherIdList.Contains(id.ToString())) { JscriptMsg("导师【" + model.name + "】已经被学生选择,无法删除!", "back"); return; } if (bll.Delete(id)) { sucCount++; } else { errorCount++; } } } AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "删除导师资料成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("teacher_list.aspx", "keywords={0}&property={1}", this.keywords, this.property)); }
private void ShowInfo(int _id) { BLL.student bll = new BLL.student(); Model.student model = bll.GetModel(_id); txtNo.Text = model.no; txtName.Text = model.name; txtSchool.Text = model.school; txtScore.Text = model.score; txtReScore.Text = model.re_score; txtAttach.Text = model.attach; txtAddTime.Text = model.add_time.ToString("yyyy-MM-dd HH:mm:ss"); rblIsAca.SelectedValue = model.is_aca.ToString(); }
//批量撤回 protected void btnCancel_Click(object sender, EventArgs e) { Model.manager model = GetAdminInfo(); if (model.role_id == 3) { ChkAdminLevel("student", DTEnums.ActionEnum.Delete.ToString()); //检查权限 } int sucCount = 0; //成功数量 int errorCount = 0; //失败数量 BLL.student bll = new BLL.student(); Repeater rptList = new Repeater(); rptList = this.rptList1; for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { BLL.teacher teacherBll = new BLL.teacher(); var students = teacherBll.GetStudents().Tables[0]; var exsitIds = new List <string>(); foreach (DataRow item in students.Rows) { if (item["students"].ToString().Contains(id.ToString())) { exsitIds.Add(id.ToString()); } } if (exsitIds.Contains(id.ToString())) { continue; } if (bll.Cancel(id)) { sucCount++; } else { errorCount++; } } } AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "撤回导师选择成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("撤回导师选择成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("student_list.aspx", "keywords={0}&property={1}", this.keywords, this.property)); }
private bool DoAdd() { bool result = false; Model.student model = new Model.student(); BLL.student bll = new BLL.student(); model.no = txtNo.Text.Trim(); model.name = txtName.Text.Trim(); model.school = txtSchool.Text.Trim(); model.score = txtScore.Text.Trim(); model.re_score = txtReScore.Text.Trim(); model.attach = txtAttach.Text.Trim(); model.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim()); model.is_aca = Utils.ObjectToStr(rblIsAca.SelectedValue); //该研究生已经存在 if (bll.Exists(model.no)) { JscriptMsg("编号不能重复!", string.Empty); return(result); } if (bll.Add(model) > 0) { Model.manager manModel = new Model.manager(); BLL.manager manBll = new BLL.manager(); //不存在用户则进行提前加 if (!manBll.Exists(model.no)) { manModel.role_id = 2; manModel.role_type = new BLL.manager_role().GetModel(manModel.role_id).role_type; manModel.is_lock = 0; manModel.user_name = model.no; manModel.real_name = model.name; //获得6位的salt加密字符串 manModel.salt = Utils.GetCheckCode(6); //以随机生成的6位字符串做为密钥加密 manModel.password = DESEncrypt.Encrypt(model.no + "123", manModel.salt); manModel.real_name = model.name; manModel.add_time = DateTime.Now; manBll.Add(manModel); } AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加研究生" + model.name); //记录日志 result = true; } return(result); }
private void ShowInfo(int teacher_id) { BLL.teacher bll = new BLL.teacher(); model = bll.GetModel(teacher_id); adminModel = GetAdminInfo(); this.rptList.DataSource = bll.GetList(0, "id=" + teacher_id, " name "); this.rptList.DataBind(); BLL.student studentBll = new BLL.student(); var students = bll.GetStudentIds(teacher_id); var strWhere = ""; if (!string.IsNullOrEmpty(students)) { strWhere = " id in(select * from dbo.f_split((select students from dt_teacher where id=" + teacher_id + "),','))"; this.rptList1.DataSource = studentBll.GetList(0, strWhere, "name asc"); this.rptList1.DataBind(); } }
private void RptBind(string _strWhere, string _orderby) { BLL.teacher bll = new BLL.teacher(); if (this.action == DTEnums.ActionEnum.Edit.ToString()) { BLL.student studentBll = new BLL.student(); Model.student studentModel = studentBll.GetModel(this.id); txtIsAsa.Value = studentModel.is_aca; //如果是学术型研究生则只能看到学术型导师 if (studentModel.is_aca == "1") { _strWhere += " and is_aca='1' and resquota>0"; } else if (studentModel.is_aca == "0") { _strWhere += " and is_pro='1' and pro_resquota>0"; } //导师列表 this.rptList1.Visible = true; this.rptList1.DataSource = bll.GetList(0, _strWhere, _orderby); this.rptList1.DataBind(); } }
private bool DoEdit(int _id) { bool result = false; BLL.student bll = new BLL.student(); Model.student model = bll.GetModel(_id); model.no = txtNo.Text.Trim(); model.name = txtName.Text.Trim(); model.school = txtSchool.Text.Trim(); model.score = txtScore.Text.Trim(); model.re_score = txtReScore.Text.Trim(); model.attach = txtAttach.Text.Trim(); model.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim()); model.is_aca = Utils.ObjectToStr(rblIsAca.SelectedValue); if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改研究生" + model.name); //记录日志 result = true; } return(result); }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("student", DTEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; //成功数量 int errorCount = 0; //失败数量 BLL.student bll = new BLL.student(); Repeater rptList = new Repeater(); rptList = this.rptList1; for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { var model = bll.GetModel(id); if (model.status == "导师已通过您的申请") { JscriptMsg("学生【" + model.name + "】已经通过导师申请,无法删除!", "back"); return; } if (bll.Delete(id)) { sucCount++; } else { errorCount++; } } } AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "删除研究生资料成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("student_list.aspx", "keywords={0}&property={1}", this.keywords, this.property)); }
private void RptBind(string _strWhere, string _orderby) { Model.manager model = GetAdminInfo(); labRoleId.Value = model.role_id.ToString(); string strWhere = ""; if (model.role_id == 2) { strWhere = " and no='" + model.user_name + "'"; } this.page = DTRequest.GetQueryInt("page", 1); //图表或列表显示 BLL.student bll = new BLL.student(); this.rptList1.DataSource = bll.GetList(this.pageSize, this.page, _strWhere + strWhere, _orderby, out this.totalCount); this.rptList1.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("student_list.aspx", "property={0}&page={1}", this.property, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
//撤回选择导师 protected void Cancel(int id) { BLL.student bll = new BLL.student(); BLL.teacher teacherBll = new BLL.teacher(); var students = teacherBll.GetStudents().Tables[0]; var exsitIds = new List <string>(); foreach (DataRow item in students.Rows) { if (item["students"].ToString().Contains(id.ToString())) { JscriptMsg("您已被导师选择,无法撤回!", "back"); return; } } AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "撤回导师"); //记录日志 if (!bll.Cancel(id)) { JscriptMsg("撤回选择导师失败!", string.Empty); return; } JscriptMsg("撤回选择导师成功!", string.Empty); }
private void RptBind(string _strWhere, string _orderby) { BLL.student bll = new BLL.student(); if (this.action == DTEnums.ActionEnum.Edit.ToString()) { BLL.teacher teacherBll = new BLL.teacher(); var selectStudetns = teacherBll.GetStudentIds(this.id); //未选择学生 this.rptList1.Visible = true; this.rptList1.DataSource = bll.GetList(0, _strWhere + " and (status='' or status is null or status='待导师确认')", _orderby); this.rptList1.DataBind(); btnCancel.Visible = false; } else { //已选择学生 this.rptList2.Visible = true; this.rptList2.DataSource = bll.GetList(0, " id in(select * from dbo.f_split((select students from dt_teacher where id=" + this.id + "),','))", _orderby); this.rptList2.DataBind(); btnSubmit.Visible = false; //btnCancel.Visible = true; } }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { if (action == DTEnums.ActionEnum.Edit.ToString()) //修改 { BLL.student bll = new BLL.student(); Model.student model = bll.GetModel(this.id); if (model.status == "导师已通过您的申请") { JscriptMsg("导师已通过您的申请 !", string.Empty); return; } var selectList = new List <int>(); var unSelectList = new List <int>(); StringBuilder tempStr = new StringBuilder(); for (int i = 0; i < rptList1.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList1.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList1.Items[i].FindControl("chkId"); if (cb.Checked) { selectList.Add(id); tempStr.Append(id + ","); } else { unSelectList.Add(id); } } if (selectList.Count == 0) { JscriptMsg("请选择一名导师!", string.Empty); return; } if (selectList.Count > 1) { JscriptMsg("您只能选择一名导师!", string.Empty); return; } if (selectList.Count > 0) { BLL.teacher teacherBll = new BLL.teacher(); var requota = "0"; //学术型研究生 if (model.is_aca == "1") { requota = teacherBll.GetQuota(selectList[0]); } else { requota = teacherBll.GetProResQuota(selectList[0]); } if (Utils.ObjToInt(requota) == 0) { JscriptMsg("您选择的导师配额已满,请重新选择!", string.Empty); return; } model.teacher_id = selectList[0]; } else { JscriptMsg("请选择导师!", string.Empty); return; } model.status = "待导师确认"; if (!bll.Update(model)) { JscriptMsg("保存过程中发生错误啦!", string.Empty); return; } JscriptMsg("选择导师成功!", Utils.CombUrlTxt("student_list.aspx", "keywords={0}&property={1}", "", "")); } }
protected void btnImport_Click(object sender, EventArgs e) { StringBuilder errorMsg = new StringBuilder(); // 错误信息 try { #region 1.获取Excel文件并转换为一个List集合 // 1.1存放Excel文件到本地服务器 string filePath = Server.MapPath(txtImgUrl.Text.Trim()); // 保存文件并获取文件路径 // 单元格抬头 // key:实体对象属性名称,可通过反射获取值 // value:属性对应的中文注解 Dictionary <string, string> cellheader = new Dictionary <string, string> { { "No", "编号" }, { "Name", "姓名" }, { "School", "本科毕业院校" }, { "Score", "笔试成绩" }, { "ReScore", "复试成绩" }, { "IsAca", "是否为学术型研究生" }, }; // 1.2解析文件,存放到一个List集合里 List <StudentEntity> enlist = ExcelHelper.ExcelToEntityList <StudentEntity>(cellheader, filePath, out errorMsg); #endregion var sucCount = 0; for (int i = 0; i < enlist.Count; i++) { StudentEntity en = enlist[i]; string errorMsgStr = "第" + (i + 1) + "行数据检测异常:"; //未填写研究生编号 if (string.IsNullOrWhiteSpace(en.No)) { continue; } Model.student model = new Model.student(); BLL.student bll = new BLL.student(); //该研究生已经存在 if (bll.Exists(en.No)) { continue; } model.no = en.No; model.name = en.Name; model.school = en.School; model.score = en.Score; model.re_score = en.ReScore; model.is_aca = en.IsAca; model.add_time = DateTime.Now; bll.Add(model); sucCount++; Model.manager manModel = new Model.manager(); BLL.manager manBll = new BLL.manager(); //该用户已经存在 if (manBll.Exists(en.No)) { continue; } manModel.role_id = 2; manModel.role_type = new BLL.manager_role().GetModel(manModel.role_id).role_type; manModel.is_lock = 0; manModel.user_name = en.No; manModel.real_name = en.Name; //获得6位的salt加密字符串 manModel.salt = Utils.GetCheckCode(6); //以随机生成的6位字符串做为密钥加密 manModel.password = DESEncrypt.Encrypt(en.No + "123", manModel.salt); manModel.real_name = en.Name; manModel.add_time = DateTime.Now; manBll.Add(manModel); } //context.Response.Write("{\"status\": 1, \"msg\": \"导入成功!\"}"); JscriptMsg("导入成功" + sucCount + "条", Utils.CombUrlTxt("student_list.aspx", "keywords={0}&property={1}", this.keywords, this.property)); } catch (Exception ex) { throw ex; } }
//保存 protected void btnSubmit_Click(object sender, EventArgs e) { if (action == DTEnums.ActionEnum.Edit.ToString()) //修改 { int sucCount = 0; //成功数量 int errorCount = 0; //失败数量 BLL.teacher bll = new BLL.teacher(); Model.teacher model = bll.GetModel(this.id); if (Utils.ObjToInt(model.resquota) == 0 && Utils.ObjToInt(model.pro_resquota) == 0) { JscriptMsg("您的名额已满!", string.Empty); return; } var selectList = new List <int>(); var unSelectList = new List <int>(); StringBuilder tempStr = new StringBuilder(); for (int i = 0; i < rptList1.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList1.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList1.Items[i].FindControl("chkId"); if (cb.Checked) { selectList.Add(id); tempStr.Append(id + ","); } else { unSelectList.Add(id); } } if (selectList.Count == 0) { JscriptMsg("请选择研究生!", string.Empty); return; } if (selectList.Count > Utils.ObjToInt(model.resquota) + Utils.ObjToInt(model.pro_resquota)) { JscriptMsg("您选中学生过多,超出的您的配额!", string.Empty); btnCancel.Visible = false; return; } model.students = string.IsNullOrEmpty(model.students) ? Utils.DelLastComma(tempStr.ToString()) : model.students + "," + Utils.DelLastComma(tempStr.ToString()); var xsQuota = 0; var zsQuota = 0; foreach (var item in selectList) { BLL.student studentBll = new BLL.student(); Model.student studentModel = studentBll.GetModel(Utils.ObjToInt(item)); //学术型研究生 if (studentModel.is_aca == "1") { xsQuota++; } else { zsQuota++; } } if (xsQuota > Utils.StrToInt(model.resquota, 0)) { JscriptMsg("您选中学生过多,超出的您您的学硕配额!", string.Empty); btnCancel.Visible = false; return; } if (zsQuota > Utils.StrToInt(model.pro_resquota, 0)) { JscriptMsg("您选中学生过多,超出的您您的专硕配额!", string.Empty); btnCancel.Visible = false; return; } foreach (var item in selectList) { BLL.student studentBll = new BLL.student(); Model.student studentModel = studentBll.GetModel(Utils.ObjToInt(item)); //学术型研究生 if (studentModel.is_aca == "1") { model.resquota = (Utils.ObjToInt(model.resquota) - 1).ToString(); } else { model.pro_resquota = (Utils.ObjToInt(model.pro_resquota) - 1).ToString(); } studentModel.status = "导师已通过您的申请"; if (studentBll.Update(studentModel)) { sucCount++; } else { errorCount++; } } foreach (var item in unSelectList) { BLL.student studentBll = new BLL.student(); Model.student studentModel = studentBll.GetModel(Utils.ObjToInt(item)); studentModel.status = "导师未通过您的申请,请再次操作选择其他导师"; studentBll.Update(studentModel); } if (!bll.Update(model)) { JscriptMsg("保存过程中发生错误啦!", string.Empty); return; } JscriptMsg("选择研究生成功!", Utils.CombUrlTxt("teacher_list.aspx", "keywords={0}&property={1}", this.keywords, this.property)); } }