protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["id"] != null) { int id = Convert.ToInt32(Request.QueryString["id"]); subject = subjectBLL.GetModel(id); txtSubjectName.Text = subject.subjectname; } } }
/// <summary> /// 获得数据列表 /// </summary> public List <Model.tbSubject> DataTableToList(DataTable dt) { List <Model.tbSubject> modelList = new List <Model.tbSubject>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Model.tbSubject model; for (int n = 0; n < rowsCount; n++) { model = new Model.tbSubject(); if (dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } model.subjectname = dt.Rows[n]["subjectname"].ToString(); modelList.Add(model); } } return(modelList); }
/// <summary> /// 获得数据列表 /// </summary> public List<Model.tbSubject> DataTableToList(DataTable dt) { List<Model.tbSubject> modelList = new List<Model.tbSubject>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Model.tbSubject model; for (int n = 0; n < rowsCount; n++) { model = new Model.tbSubject(); if(dt.Rows[n]["id"].ToString()!="") { model.id=int.Parse(dt.Rows[n]["id"].ToString()); } model.subjectname= dt.Rows[n]["subjectname"].ToString(); modelList.Add(model); } } return modelList; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.tbSubject model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.tbSubject model) { return(dal.Add(model)); }
protected void Page_Load(object sender, EventArgs e) { arrangeid = Convert.ToInt32(Request.QueryString["id"]); arrange = arrangeBLL.GetModel(arrangeid); paper = paperBLL.GetModel(arrange.paperid); subject = subjectBLL.GetModel(arrange.subjectid); if (!IsPostBack) { //取得数据库连接 SqlConnection conn = SQLHelper.GetConnection(); //打开数据库连接 conn.Open(); //创建事务 SqlTransaction SqlTransaction = conn.BeginTransaction(); try { PaperGenerateDAL pgd = new PaperGenerateDAL(paper, SqlTransaction); pc = pgd.GetPaperContent(); SqlTransaction.Commit(); } catch (Exception) { try { SqlTransaction.Rollback(); } catch (Exception) { //事务回滚出错 } } finally { //关闭各种资源 SqlTransaction.Dispose(); conn.Close(); } if (arrange.arrangetype == 2) { //考试,记录考试时间,成绩状态 tbUser user = (tbUser)Session[Constant.User]; tbScore score = this.GetScore(arrangeid, user.id); score.starttime = DateTime.Now; score.scorestatus = 2;//正在考试 scoreBLL.Update(score); //把scoreid存放在ViewState ViewState[Constant.ScoreID] = score.id; } if (pc.SRContent.Count != 0) { rptSR.DataSource = pc.SRContent; rptSR.DataBind(); } if (pc.CBContent.Count != 0) { rptCB.DataSource = pc.CBContent; rptCB.DataBind(); } if (pc.JDContent.Count != 0) { rptJD.DataSource = pc.JDContent; rptJD.DataBind(); } if (pc.BFContent.Count != 0) { rptBF.DataSource = pc.BFContent; rptBF.DataBind(); } if (pc.SAContent.Count != 0) { rptSA.DataSource = pc.SAContent; rptSA.DataBind(); } } }