//保存 protected void btnSubmit_Click(object sender, EventArgs e) { ChkAdminLevel("_ybd_examination_question", EnumCollection.ActionEnum.Add.ToString()); //检查权限 #region string strError = string.Empty; if (txtexa_id.Text.Trim() == "" || txtexa_id.Text.Trim().Length > 4) { strError += "试卷ID为空或超出长度![br]"; } if (txtq_id.Text.Trim() == "" || txtq_id.Text.Trim().Length > 4) { strError += "题目ID为空或超出长度![br]"; } if (strError != string.Empty) { JscriptMsg(strError, "", "Error"); return; } #endregion Model.examination_question model = new Model.examination_question(); BLL.examination_question bll = new BLL.examination_question(); model.exa_id = Convert.ToInt32(txtexa_id.Text); model.q_id = Convert.ToInt32(txtq_id.Text); int id = bll.Add(model); if (id > 0) { AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加试卷题目关联信息,主键:" + id); //记录日志 JscriptMsg("添加试卷题目关联信息成功!", "Manage.aspx", ""); } else { JscriptMsg("保存过程中发生错误!", ""); } }
protected void btnAdd_Click(object sender, EventArgs e) { ChkAdminLevel("_common_questions", EnumCollection.ActionEnum.Add.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; string allid = hdfAllID.Value; string[] ids = allid.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); BLL.examination_question bll = new BLL.examination_question(); int id = 0; for (int i = 0; i < ids.Length; i++) { id = Convert.ToInt32(ids[i]); Model.examination_question model = bll.GetModel(" exa_id = " + this.exaid + " and q_id = " + id); if (model == null) { //添加 model = new Model.examination_question(); model.exa_id = this.exaid; model.q_id = id; if (bll.Add(model) > 0) { sucCount += 1; } else { errorCount += 1; } } else { errorCount += 1; } } hdfAllID.Value = ""; //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) // { // Model.examination_question model = bll.GetModel(" group_id = " + this.group + " and exa_id = " + this.exaid + " and q_id = " + id); // if (model == null) // { // //添加 // model = new Model.examination_question(); // model.exa_id = this.exaid; // model.q_id = id; // if (bll.Add(model) > 0) // { // sucCount += 1; // } // else // { // errorCount += 1; // } // } // else // { // errorCount += 1; // } // } //} AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加未选题目信息" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("添加成功" + sucCount + "条,失败" + errorCount + "条!", ""); BindData(); }