public int UpdatePaperStrategyItemCategory(PaperStrategyItemCategory item)
        {
            Database     db         = DatabaseFactory.CreateDatabase();
            DbConnection connection = db.CreateConnection();

            connection.Open();
            DbTransaction transaction = connection.BeginTransaction();

            int nRecordAffected = 0;

            try
            {
                string    sqlCommand = "USP_strategy_category_U";
                DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);



                db.AddInParameter(dbCommand, "p_strategy_item_category_id", DbType.Int32, item.StrategyItemCategoryId);
                db.AddInParameter(dbCommand, "p_strategy_subject_id", DbType.Int32, item.StrategySubjectId);

                db.AddInParameter(dbCommand, "p_item_category_id", DbType.Int32, item.ItemCategoryId);
                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.String, item.ItemDifficulty2Count);
                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_categorys_id", DbType.String, item.ExcludeCategorysId);
                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_category_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);
        }
Exemple #2
0
        private void FillPage(int nID)
        {
            PaperStrategyItemCategoryBLL paperStrategyItemCategoryBLL = new PaperStrategyItemCategoryBLL();

            PaperStrategyItemCategory paperStrategyItemCategory = paperStrategyItemCategoryBLL.GetPaperStrategyItemCategory(nID);

            if (paperStrategyItemCategory != null)
            {
                if (paperStrategyItemCategory.ExcludeCategorysId != null)
                {
                    FillExcludeCategorysID(paperStrategyItemCategory.ExcludeCategorysId);
                }

                txtMemo.Text                   = paperStrategyItemCategory.Memo;
                txtItemCategoryName.Text       = paperStrategyItemCategory.CategoryName;
                txtSubjectName.Text            = paperStrategyItemCategory.SubjectName;
                hfExCludeItemCategoryIDS.Value = paperStrategyItemCategory.ExcludeCategorysId;
                txtNd1.Text       = paperStrategyItemCategory.ItemDifficulty1Count.ToString();
                txtNd2.Text       = paperStrategyItemCategory.ItemDifficulty2Count.ToString();
                txtNd3.Text       = paperStrategyItemCategory.ItemDifficulty3Count.ToString();
                txtNd4.Text       = paperStrategyItemCategory.ItemDifficulty4Count.ToString();
                txtNd5.Text       = paperStrategyItemCategory.ItemDifficulty5Count.ToString();
                txtNDR.Text       = paperStrategyItemCategory.ItemDifficultyRandomCount.ToString();
                txtScore.Text     = paperStrategyItemCategory.UnitScore.ToString();
                txtSeconds.Text   = paperStrategyItemCategory.UnitLimitTime.ToString();
                hfSubjectId.Value = paperStrategyItemCategory.StrategySubjectId.ToString();

                hfItemCategoryID.Value = paperStrategyItemCategory.ItemCategoryId.ToString();
                ddlType.SelectedValue  = paperStrategyItemCategory.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 PaperStrategyItemCategory GetPaperStrategyItemCategory(int paperItemId)
        {
            PaperStrategyItemCategory item = null;

            Database db = DatabaseFactory.CreateDatabase();

            string    sqlCommand = "USP_strategy_category_g";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "p_strategy_item_category_id", DbType.Int32, paperItemId);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    item = CreateModelObject(dataReader);
                    break;
                }
            }

            return(item);
        }
 public int UpdatePaperStrategyItemCategory(PaperStrategyItemCategory item)
 {
     return(dal.UpdatePaperStrategyItemCategory(item));
 }
 public int AddPaperStrategyItemCategory(PaperStrategyItemCategory item)
 {
     return(dal.AddPaperStrategyItemCategory(item));
 }
Exemple #6
0
        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";
            }

            PaperStrategyItemCategoryBLL paperStrategyItemCategoryBLL = new PaperStrategyItemCategoryBLL();
            PaperStrategyItemCategory    paperStrategyItemCategory    = new PaperStrategyItemCategory();

            paperStrategyItemCategory.ItemDifficultyRandomCount = int.Parse(txtNDR.Text);
            paperStrategyItemCategory.ItemDifficulty1Count      = int.Parse(txtNd1.Text);
            paperStrategyItemCategory.ItemDifficulty2Count      = int.Parse(txtNd2.Text);
            paperStrategyItemCategory.ItemDifficulty3Count      = int.Parse(txtNd3.Text);
            paperStrategyItemCategory.ItemDifficulty4Count      = int.Parse(txtNd4.Text);
            paperStrategyItemCategory.ItemDifficulty5Count      = int.Parse(txtNd5.Text);
            paperStrategyItemCategory.Memo = txtMemo.Text;

            paperStrategyItemCategory.ItemCategoryId     = int.Parse(hfItemCategoryID.Value);
            paperStrategyItemCategory.ExcludeCategorysId = hfExCludeItemCategoryIDS.Value;

            paperStrategyItemCategory.StrategySubjectId = int.Parse(hfSubjectId.Value);

            paperStrategyItemCategory.ItemTypeId    = int.Parse(ddlType.SelectedValue);
            paperStrategyItemCategory.UnitScore     = decimal.Parse(txtScore.Text);
            paperStrategyItemCategory.UnitLimitTime = int.Parse(txtSeconds.Text);

            if (ViewState["mode"].ToString() == "Insert")
            {
                paperStrategyItemCategoryBLL.AddPaperStrategyItemCategory(paperStrategyItemCategory);
            }
            else if (ViewState["mode"].ToString() == "Edit")
            {
                string strId = Request.QueryString.Get("id");
                paperStrategyItemCategory.StrategyItemCategoryId = int.Parse(strId);

                paperStrategyItemCategoryBLL.UpdatePaperStrategyItemCategory(paperStrategyItemCategory);
            }

            Response.Write("<script>  window.opener.form1.submit();window.close();</script>");
        }