private void FillPage(int nID) { PaperStrategyBookChapterBLL paperStrategyBookChapterBLL = new PaperStrategyBookChapterBLL(); PaperStrategyBookChapter paperStrategyBookChapter = paperStrategyBookChapterBLL.GetPaperStrategyBookChapter(nID); if (paperStrategyBookChapter != null) { txtMemo.Text = paperStrategyBookChapter.Memo; txtChapterName.Text = paperStrategyBookChapter.RangeName; HfRangeName.Value = paperStrategyBookChapter.RangeName; txtSubjectName.Text = paperStrategyBookChapter.SubjectName; txtExCludeChapters.Text = paperStrategyBookChapter.ExcludeChapterId; if (string.IsNullOrEmpty(paperStrategyBookChapter.ExcludeChapterId) == false) { FillExcludeCategorysID(paperStrategyBookChapter.ExcludeChapterId); } txtNd1.Text = paperStrategyBookChapter.ItemDifficulty1Count.ToString(); txtNd2.Text = paperStrategyBookChapter.ItemDifficulty2Count.ToString(); txtNd3.Text = paperStrategyBookChapter.ItemDifficulty3Count.ToString(); txtNd4.Text = paperStrategyBookChapter.ItemDifficulty4Count.ToString(); txtNd5.Text = paperStrategyBookChapter.ItemDifficulty5Count.ToString(); txtNDR.Text = paperStrategyBookChapter.ItemDifficultyRandomCount.ToString(); txtScore.Text = paperStrategyBookChapter.UnitScore.ToString(); txtSeconds.Text = paperStrategyBookChapter.UnitLimitTime.ToString(); hfSubjectId.Value = paperStrategyBookChapter.StrategySubjectId.ToString(); HfRangeType.Value = paperStrategyBookChapter.RangeType.ToString(); HfChapterId.Value = paperStrategyBookChapter.RangeId.ToString(); ddlType.SelectedValue = paperStrategyBookChapter.ItemTypeId.ToString(); PaperStrategySubjectBLL paperStrategySubjectBLL = new PaperStrategySubjectBLL(); PaperStrategySubject paperStrategySubject = paperStrategySubjectBLL.GetPaperStrategySubject(int.Parse(hfSubjectId.Value)); if (paperStrategySubject != null) { labelTotalCount.Text = paperStrategySubject.ItemCount.ToString(); } } if (ViewState["mode"].ToString() == "ReadOnly") { SaveButton.Visible = false; CancelButton.Visible = true; ddlType.Enabled = false; txtNDR.Enabled = false; txtNd1.Enabled = false; txtNd2.Enabled = false; txtNd3.Enabled = false; txtNd4.Enabled = false; txtNd5.Enabled = false; txtSeconds.Enabled = false; txtMemo.Enabled = false; } }
public int AddPaperStrategyBookChapter(PaperStrategyBookChapter item) { Database db = DatabaseFactory.CreateDatabase(); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); int nRecordAffected = 0; try { string sqlCommand = "USP_STRATEGY_BOOK_CHAPTER_I"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddOutParameter(dbCommand, "p_strategy_book_chapter_id", DbType.Int32, 4); db.AddInParameter(dbCommand, "p_strategy_subject_id", DbType.Int32, item.StrategySubjectId); db.AddInParameter(dbCommand, "p_Range_type", DbType.Int32, item.RangeType); db.AddInParameter(dbCommand, "p_Range_id", DbType.Int32, item.RangeId); db.AddInParameter(dbCommand, "p_item_type_id", DbType.Int32, item.ItemTypeId); db.AddInParameter(dbCommand, "p_item_difficulty_random_count", DbType.Int32, item.ItemDifficultyRandomCount); db.AddInParameter(dbCommand, "p_item_difficulty_1_count", DbType.Int32, item.ItemDifficulty1Count); db.AddInParameter(dbCommand, "p_item_difficulty_2_count", DbType.Int32, item.ItemDifficulty2Count); db.AddInParameter(dbCommand, "p_range_name", DbType.String, item.RangeName); db.AddInParameter(dbCommand, "p_item_difficulty_3_count", DbType.Int32, item.ItemDifficulty3Count); db.AddInParameter(dbCommand, "p_item_difficulty_4_count", DbType.Int32, item.ItemDifficulty4Count); db.AddInParameter(dbCommand, "p_item_difficulty_5_count", DbType.Int32, item.ItemDifficulty5Count); db.AddInParameter(dbCommand, "p_unit_score", DbType.Decimal, item.UnitScore); db.AddInParameter(dbCommand, "p_exclude_chapters_id", DbType.String, item.ExcludeChapterId); db.AddInParameter(dbCommand, "p_unit_limit_time", DbType.String, item.UnitLimitTime); db.AddInParameter(dbCommand, "p_memo", DbType.String, item.Memo); nRecordAffected = db.ExecuteNonQuery(dbCommand, transaction); string sqlCommand1 = "USP_strategy_Subject_U_score"; DbCommand dbCommand1 = db.GetStoredProcCommand(sqlCommand1); db.AddInParameter(dbCommand1, "p_STRATEGY_SUBJECT_ID", DbType.Int32, item.StrategySubjectId); db.ExecuteNonQuery(dbCommand1, transaction); transaction.Commit(); } catch (System.SystemException ex) { transaction.Rollback(); throw ex; } connection.Close(); return(nRecordAffected); }
public PaperStrategyBookChapter GetPaperStrategyBookChapter(int paperItemId) { PaperStrategyBookChapter item = null; Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_STRATEGY_BOOK_CHAPTER_g"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_strategy_book_chapter_id", DbType.Int32, paperItemId); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { item = CreateModelObject(dataReader); break; } } return(item); }
protected void SaveButton_Click(object sender, EventArgs e) { if (txtNd1.Text == "") { txtNd1.Text = "0"; } if (txtNd2.Text == "") { txtNd2.Text = "0"; } if (txtNd3.Text == "") { txtNd3.Text = "0"; } if (txtNd4.Text == "") { txtNd4.Text = "0"; } if (txtNd5.Text == "") { txtNd5.Text = "0"; } if (txtNDR.Text == "") { txtNDR.Text = "0"; } if (txtScore.Text == "") { txtScore.Text = "0"; } if (txtSeconds.Text == "") { txtSeconds.Text = "0"; } PaperStrategyBookChapterBLL paperStrategyBookChapterBLL = new PaperStrategyBookChapterBLL(); PaperStrategyBookChapter paperStrategyBookChapter = new PaperStrategyBookChapter(); paperStrategyBookChapter.StrategySubjectId = int.Parse(hfSubjectId.Value); paperStrategyBookChapter.RangeType = int.Parse(HfRangeType.Value); paperStrategyBookChapter.RangeId = int.Parse(HfChapterId.Value); paperStrategyBookChapter.ItemTypeId = int.Parse(ddlType.SelectedValue); paperStrategyBookChapter.ItemDifficultyRandomCount = int.Parse(txtNDR.Text); paperStrategyBookChapter.ItemDifficulty1Count = int.Parse(txtNd1.Text); paperStrategyBookChapter.ItemDifficulty2Count = int.Parse(txtNd2.Text); paperStrategyBookChapter.ItemDifficulty3Count = int.Parse(txtNd3.Text); paperStrategyBookChapter.ItemDifficulty4Count = int.Parse(txtNd4.Text); paperStrategyBookChapter.ItemDifficulty5Count = int.Parse(txtNd5.Text); paperStrategyBookChapter.UnitScore = decimal.Parse(txtScore.Text); paperStrategyBookChapter.ExcludeChapterId = HfExCludeChaptersId.Value; paperStrategyBookChapter.UnitLimitTime = int.Parse(txtSeconds.Text); paperStrategyBookChapter.Memo = txtMemo.Text; paperStrategyBookChapter.RangeName = HfRangeName.Value; if (ViewState["mode"].ToString() == "Insert") { paperStrategyBookChapterBLL.AddPaperStrategyBookChapter(paperStrategyBookChapter); } else if (ViewState["mode"].ToString() == "Edit") { string strId = Request.QueryString.Get("id"); paperStrategyBookChapter.PaperStrategyBookChapterId = int.Parse(strId); paperStrategyBookChapterBLL.UpdatePaperStrategyBookChapter(paperStrategyBookChapter); } Response.Write("<script>var p = window.opener; if(p) p.document.form1.submit();window.close();</script>"); }
public int UpdatePaperStrategyBookChapter(PaperStrategyBookChapter item) { return(dal.UpdatePaperStrategyBookChapter(item)); }
public int AddPaperStrategyBookChapter(PaperStrategyBookChapter item) { return(dal.AddPaperStrategyBookChapter(item)); }