protected void bt_Yes_Click(object sender, EventArgs e) { try { BLL.TitleList bll = new BLL.TitleList(); Model.TitleList model = new Model.TitleList(); model.CourseID = int.Parse(Request.QueryString["CourseID"]); model.Type = Request.QueryString["TitleType"]; model.Title = Common.Function.StringEncode(tb_Title.Text.Trim()); model.Analysis = Common.Function.StringEncode(tb_Analysis.Text.Trim()); model.Extent = rbl_Extent.SelectedValue.ToString(); int TitleListID = bll.Add(model); if (TitleListID > 0) { int k = 0; int l = 0; string del_Work = ""; del_Work = Request.Form["del_Work"].ToString(); int num = int.Parse(Request.Form["WorkExpNum"].ToString()); for (int i = 1; i <= num; i++) { if (del_Work.IndexOf(i.ToString()) <= 0) { //Response.Write(i + ":" + Request.Form["Name" + i] + Request.Form["radio" + i] + "<br/>"); string radio = Request.Form["radio" + i]; string Name = Request.Form["Name" + i]; if (Name == "") { } else { BLL.OptionsList bll1 = new BLL.OptionsList(); Model.OptionsList model1 = new Model.OptionsList(); model1.TitleListID = TitleListID; model1.Name = Common.Function.StringEncode(Name); model1.T_F = radio; if (bll1.Add(model1) > 0) { k = k + 1; } else { l = l + 1; } } } } lb_msg.Text = "题目添加成功,选择成功添加[" + k + "]条,失败[" + l + "]条!"; } else { lb_msg.Text = "题目添加失败!"; //Common.Function.AlertRedirect("系统繁忙请稍后再试!", "/I-B/List" + Request.QueryString["TitleType"] + "-" + Request.QueryString["CourseID"] + ".html", "Iframe_Div_Mid_Mid"); } } catch { lb_msg.Text = "系统繁忙请稍后再试!"; } }
/// <summary> /// 添加到数据库 /// </summary> /// <param name="Type">类型</param> /// <param name="Count">条数</param> /// <param name="Score">每条分值</param> private void InsertDB(string Type, int Count, int Score) { string Extent = rbl_Extent.SelectedValue.ToString(); BLL.TitleList bll = new BLL.TitleList(); List <Model.TitleList> list = new List <Model.TitleList>(); list = bll.GetList(Type, int.Parse(lb_CourseID.Text), Count, Extent); if (PapersID > 0) { //Common.Function.Alert("啥也不做"); } else { //Common.Function.Alert("添加"); Papers(); } for (int i = 0; i < list.Count; i++) { Model.TitleList model = new Model.TitleList(); model.Title = list[i].Title; model.T_F = list[i].T_F; model.Analysis = list[i].Analysis; model.ID = list[i].ID; model.CourseID = list[i].CourseID; AddPapersTitleList(Type, PapersID, Score, model); } }
/// <summary> /// 显示所有 /// </summary> /// <param name="Type">类型(单选/多选/不定项选/判断)</param> /// <param name="CourseID">课程ID</param> /// <param name="Extent">程度</param> /// <returns></returns> public List <Model.TitleList> GetList(string Type, int CourseID, string Extent) { string strSql = ""; strSql = "Select * FROM [TitleList] Where [Type]='" + Type + "' AND [CourseID]='" + CourseID + "' AND [Extent]='" + Extent + "'"; List <Model.TitleList> List = new List <Model.TitleList>(); SqlParameter[] parameters = { }; SqlDataReader DR; DR = ExamSys.ExecuteReader(strSql.ToString(), parameters); using (DR) { while (DR.Read()) { Model.TitleList model = new Model.TitleList(); model.Title = DR["Title"].ToString(); model.T_F = DR["T_F"].ToString(); model.Analysis = DR["Analysis"].ToString(); model.ID = int.Parse(DR["ID"].ToString()); model.Extent = DR["Extent"].ToString(); List.Add(model); } DR.Close(); DR.Dispose(); } return(List); }
/// <summary> /// /// </summary> /// <param name="PageCount"></param> /// <param name="PageSize"></param> /// <param name="Type"></param> /// <param name="Extent"></param> /// <returns></returns> public List <Model.TitleList> GetList(int PageCount, int PageSize, string Type, string Extent) { string strSql = ""; string RedCountsql = ""; int RowTotal = (PageCount - 1) * PageSize;// RedCountsql = "(select count(ID) from [TitleList] Where [Type]='" + Type + "' and [Extent]='" + Extent + "' ) as RowTotal"; strSql = "Select Top " + PageSize + " *," + RedCountsql + " FROM [TitleList] where [ID] not in (Select Top " + RowTotal + " [ID] from [TitleList] Where [Type]='" + Type + "' and [Extent]='" + Extent + "' ORDER BY ID DESC) and [Type]='" + Type + "' and [Extent]='" + Extent + "' ORDER BY ID DESC"; List <Model.TitleList> List = new List <Model.TitleList>(); SqlParameter[] parameters = { }; using (SqlDataReader DR = ExamSys.ExecuteReader(strSql.ToString(), parameters)) { while (DR.Read()) { Model.TitleList model = new Model.TitleList(); model.RowTotal = int.Parse(DR["RowTotal"].ToString()); model.ID = int.Parse(DR["ID"].ToString()); model.Type = DR["Type"].ToString(); model.Title = DR["Title"].ToString(); model.T_F = DR["T_F"].ToString(); model.CourseID = int.Parse(DR["CourseID"].ToString()); model.Extent = DR["Extent"].ToString(); List.Add(model); } DR.Close(); DR.Dispose(); } return(List); }
/// <summary> /// 添加 /// </summary> /// <param name="model"></param> /// <returns></returns> public int Add(Model.TitleList model) { int rowsAffected; SqlParameter[] parameters = { new SqlParameter("@ReturnValue", SqlDbType.Int), new SqlParameter("@CourseID", SqlDbType.Int), new SqlParameter("@Type", SqlDbType.NVarChar, 50), new SqlParameter("@Title", SqlDbType.NVarChar, 500), new SqlParameter("@T_F", SqlDbType.NVarChar, 50), new SqlParameter("@Analysis", SqlDbType.Text), new SqlParameter("@Extent", SqlDbType.NVarChar, 50), new SqlParameter("@Status_id", SqlDbType.Int) }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.CourseID; parameters[2].Value = model.Type; parameters[3].Value = model.Title; parameters[4].Value = model.T_F; parameters[5].Value = model.Analysis; parameters[6].Value = model.Extent; parameters[7].Value = model.Status_id; ExamSys.RunProcedure("TitleList_Add", parameters, out rowsAffected); return((int)parameters[0].Value); }
/// <summary> /// 详细信息 /// </summary> /// <param name="ID">ID</param> /// <returns></returns> public List <Model.TitleList> Details(int ID) { string strSql = ""; strSql = "Select * FROM [TitleList] Where [ID]='" + ID + "'"; List <Model.TitleList> List = new List <Model.TitleList>(); SqlParameter[] parameters = { }; SqlDataReader DR; DR = ExamSys.ExecuteReader(strSql.ToString(), parameters); using (DR) { while (DR.Read()) { Model.TitleList model = new Model.TitleList(); model.Title = DR["Title"].ToString(); model.T_F = DR["T_F"].ToString(); model.Analysis = DR["Analysis"].ToString(); model.ID = int.Parse(DR["ID"].ToString()); model.CourseID = int.Parse(DR["CourseID"].ToString()); model.Status_id = int.Parse(DR["Status_id"].ToString()); List.Add(model); } DR.Close(); DR.Dispose(); } return(List); }
/// <summary> /// 更新 /// </summary> /// <param name="model"></param> public void Updata(Model.TitleList model) { if (dal.Updata(model) > 0) { Common.Function.AlertRedirect("成功!", "/Aspx/Success.htm"); } else { Common.Function.AlertRedirect("失败!", "/Aspx/Failure.htm"); } }
protected void bt_Yes_Click(object sender, EventArgs e) { try { int k = 0; int l = 0; string del_Work = ""; del_Work = Request.Form["del_Work"].ToString(); int num = int.Parse(Request.Form["WorkExpNum"].ToString()); for (int i = 1; i <= num; i++) { if (del_Work.IndexOf(i.ToString()) <= 0) { //Response.Write(i + ":" + Request.Form["Name" + i] + Request.Form["radio" + i] + "<br/>"); string Name = Request.Form["Name" + i]; string Analysis = Request.Form["textfield" + i]; if (Name == "") { } else { BLL.TitleList bll = new BLL.TitleList(); Model.TitleList model = new Model.TitleList(); model.CourseID = int.Parse(Request.QueryString["CourseID"]); model.Type = Request.QueryString["TitleType"]; model.Title = Common.Function.StringEncode(Name); model.T_F = Request.Form["radio" + i]; model.Analysis = Common.Function.StringEncode(Analysis); model.Extent = rbl_Extent.SelectedValue.ToString(); if (bll.Add(model) > 0) { k = k + 1; } else { l = l + 1; } } } } lb_msg.Text = "题目添加成功,选择成功添加[" + k + "]条,失败[" + l + "]条!"; } catch { lb_msg.Text = "题目添加失败!"; } }
/// <summary> /// 添加试卷题目 /// </summary> /// <param name="Type">类型</param> /// <param name="PapersID">PapersID</param> /// <param name="Score">分数</param> /// <param name="md">TitleList</param> private void AddPapersTitleList(string Type, int PapersID, int Score, Model.TitleList md) { BLL.PapersTitleList bll = new BLL.PapersTitleList(); Model.PapersTitleList model = new Model.PapersTitleList(); model.Title = md.Title; model.T_F = md.T_F; model.Analysis = md.Analysis; model.ID = md.ID; model.CourseID = md.CourseID; model.Score = Score; model.Type = Type; model.PapersID = PapersID; if (bll.Add(model) > 0) { AddPapersOptionsList(PapersID, model.ID, model.Score, model.Type); } else { //如果题目添加不成功 } }
/// <summary> /// 添加 /// </summary> public int Add(Model.TitleList model) { return(dal.Add(model)); }