//修改 protected void btnAdd_Click(object sender, EventArgs e) { if (txtGradeCheckItemName.Text.Trim().Length == 0) { Javascript.GoHistory(-1, "请输入成绩审核单项名称!", Page); } else { DalOperationAboutGradeCheck dalOperationAboutGradeCheck = new DalOperationAboutGradeCheck(); StudentsGradeCheck model = new StudentsGradeCheck(); model.gradeCheckItemName = txtGradeCheckItemName.Text.Trim(); model.gradeCheckItemDefaultValue = txtGradeCheckItemDefaultValue.Text.Trim(); model.displayOrder = int.Parse(txtDisplayOrder.Text.Trim()); List<string> items = new List<string>(); for (int i = 0; i < ddlTermYears.Items.Count; i++) { ListItem _item = ddlTermYears.Items[i]; if (_item.Selected) { items.Add(_item.Value); } } model.termYears = string.Join(",", items).Trim(); try { dalOperationAboutGradeCheck.AddGradeCheckItems(model);//修改 Javascript.RefreshParentWindow("添加成绩审核单项成功!", "/Administrator/StudentManager.aspx?fragment=5", Page); } catch (Exception ex) { MongoDBLog.LogRecord(ex); Javascript.GoHistory(-1, "添加成绩审核单项失败,请检查格式是否有误!", Page); } } }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddGradeCheckItems(StudentsGradeCheck model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into usta_StudentsGradeCheck("); strSql.Append("gradeCheckItemName,gradeCheckItemDefaultValue,displayOrder,termYears)"); strSql.Append(" values ("); strSql.Append("@gradeCheckItemName,@gradeCheckItemDefaultValue,@displayOrder,@termYears);"); SqlParameter[] parameters = { new SqlParameter("@gradeCheckItemName", SqlDbType.NChar,50), new SqlParameter("@gradeCheckItemDefaultValue", SqlDbType.NChar,50), new SqlParameter("@displayOrder", SqlDbType.Int,4), new SqlParameter("@termYears", SqlDbType.NVarChar,200)}; parameters[0].Value = model.gradeCheckItemName; parameters[1].Value = model.gradeCheckItemDefaultValue; parameters[2].Value = model.displayOrder; parameters[3].Value = model.termYears; return SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters); }
//修改 protected void btnUpdate_Click(object sender, EventArgs e) { DalOperationAboutGradeCheck dalOperationAboutGradeCheck = new DalOperationAboutGradeCheck(); string _name = txtGradeCheckItemName.Text.Trim(); if (dalOperationAboutGradeCheck.CheckIsExistGradeCheckItemName(_name, gradeCheckId).Tables[0].Rows.Count > 0) { Javascript.GoHistory(-1, "已经存在此名称的规则,请更换规则名或者在已有规则上修改所应用的学年即可!", Page); return; } if (txtGradeCheckItemName.Text.Trim().Length == 0) { Javascript.GoHistory(-1, "请输入成绩审核单项名称!", Page); } else { StudentsGradeCheck model = new StudentsGradeCheck(); model.gradeCheckItemName = txtGradeCheckItemName.Text.Trim(); model.gradeCheckItemDefaultValue = txtGradeCheckItemDefaultValue.Text.Trim(); model.gradeCheckId = gradeCheckId; model.displayOrder = int.Parse(txtDisplayOrder.Text.Trim()); List<string> items = new List<string>(); for (int i = 0; i < ddlTermYears.Items.Count; i++) { ListItem _item = ddlTermYears.Items[i]; if (_item.Selected) { items.Add(_item.Value); } } model.termYears = string.Join(",", items).Trim(); try { dalOperationAboutGradeCheck.UpdateGradeCheckItemById(model);//修改 Javascript.RefreshParentWindow("修改成绩审核单项成功!", "/Administrator/StudentManager.aspx?fragment=5", Page); } catch (Exception ex) { MongoDBLog.LogRecord(ex); Javascript.GoHistory(-1, "修改失败,请检查格式是否有误!", Page); } } }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public int UpdateGradeCheckItemById(StudentsGradeCheck model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update usta_StudentsGradeCheck set "); strSql.Append("gradeCheckItemName=@gradeCheckItemName,"); strSql.Append("gradeCheckItemDefaultValue=@gradeCheckItemDefaultValue,"); strSql.Append("displayOrder=@displayOrder,"); strSql.Append("termYears=@termYears"); strSql.Append(" where gradeCheckId=@gradeCheckId"); SqlParameter[] parameters = { new SqlParameter("@gradeCheckItemName", SqlDbType.NChar,50), new SqlParameter("@gradeCheckItemDefaultValue", SqlDbType.NChar,50), new SqlParameter("@gradeCheckId", SqlDbType.Int,4), new SqlParameter("@displayOrder", SqlDbType.Int,4), new SqlParameter("@termYears", SqlDbType.NVarChar,200)}; parameters[0].Value = model.gradeCheckItemName; parameters[1].Value = model.gradeCheckItemDefaultValue; parameters[2].Value = model.gradeCheckId; parameters[3].Value = model.displayOrder; parameters[4].Value = model.termYears; return SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString(), parameters); }