//保存 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}", "", "")); } }
private bool DoEdit(int _id) { bool result = false; BLL.teacher bll = new BLL.teacher(); Model.teacher model = bll.GetModel(_id); model.no = txtNo.Text.Trim(); model.name = txtName.Text.Trim(); model.email = txtEmail.Text.Trim(); model.direction = txtDirection.Text.Trim(); model.major = txtMajor.Text.Trim(); model.add_time = Utils.StrToDateTime(txtAddTime.Text.Trim()); model.is_aca = Utils.ObjectToStr(rblIsAca.SelectedValue); model.is_pro = Utils.ObjectToStr(rblIsPro.SelectedValue); var quota = txtQuota.Text.Trim(); //如果增加导师指标,则对应增加剩余指标 if (Utils.ObjToInt(quota) != Utils.ObjToInt(model.quota)) { if (model.is_aca == "0") { JscriptMsg("该导师不是学术型导师,无法修改学硕指标!", string.Empty); return(false); } if (Utils.ObjToInt(quota) > Utils.ObjToInt(model.quota)) { //增加指标数 var addQuota = Utils.ObjToInt(quota) - Utils.ObjToInt(model.quota); model.resquota = Utils.ObjectToStr(Utils.ObjToInt(model.resquota) + addQuota); model.quota = quota; } else { //减少指标数 var resQuota = Utils.ObjToInt(model.quota) - Utils.ObjToInt(quota); var resquota = Utils.ObjToInt(model.resquota) - resQuota; if (resquota < 0) { JscriptMsg("由于您是减少指标,请先取消相应研究生的选择以确保指标正常!", string.Empty); return(false); } model.resquota = Utils.ObjectToStr(resquota); model.quota = quota; } } var proQuota = txtProQuota.Text.Trim(); //如果增加导师指标,则对应增加剩余指标 if (Utils.ObjToInt(proQuota) != Utils.ObjToInt(model.pro_quota)) { if (model.is_pro == "0") { JscriptMsg("该导师不是专业型导师,无法修改专硕指标!", string.Empty); return(false); } if (Utils.ObjToInt(proQuota) > Utils.ObjToInt(model.pro_quota)) { //增加指标数 var addQuota = Utils.ObjToInt(proQuota) - Utils.ObjToInt(model.pro_quota); model.pro_resquota = Utils.ObjectToStr(Utils.ObjToInt(model.pro_resquota) + addQuota); model.pro_quota = proQuota; } else { //减少指标数 var resQuota = Utils.ObjToInt(model.pro_quota) - Utils.ObjToInt(proQuota); var resquota = Utils.ObjToInt(model.pro_resquota) - resQuota; if (resquota < 0) { JscriptMsg("由于您是减少指标,请先取消相应研究生的选择以确保指标正常!", string.Empty); return(false); } model.pro_resquota = Utils.ObjectToStr(resquota); model.pro_quota = proQuota; } } if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改导师" + model.name); //记录日志 result = true; } return(result); }
//保存 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)); } }