Example #1
0
    /// <summary>削除ボタン</summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    protected string UOC_btnDelete_Click(FxEventArgs fxEventArgs)
    {
        // 引数クラスを生成
        _3TierParameterValue parameterValue = new _3TierParameterValue(
            this.ContentPageFileNoEx, fxEventArgs.ButtonID, "DeleteRecord",
            (string)Session["DAP"], (MyUserInfo)this.UserInfo);

        // テーブル
        parameterValue.TableName = "_TableName_";

        // 主キーとタイムスタンプ列
        parameterValue.AndEqualSearchConditions = (Dictionary <string, object>)Session["PrimaryKeyAndTimeStamp"];

        // B層を生成
        _3TierEngine b = new _3TierEngine();

        // データ取得処理を実行
        _3TierReturnValue returnValue =
            (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

        // 結果表示
        this.lblResult.Text = returnValue.Obj.ToString() + "件削除しました。";

        // 画面遷移しない。
        return(string.Empty);
    }
Example #2
0
    /// <summary>更新ボタン</summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    protected string UOC_btnUpdate_Click(FxEventArgs fxEventArgs)
    {
        // 引数クラスを生成
        _3TierParameterValue parameterValue = new _3TierParameterValue(
            this.ContentPageFileNoEx, fxEventArgs.ButtonID, "UpdateRecord",
            (string)Session["DAP"], (MyUserInfo)this.UserInfo);

        // テーブル
        parameterValue.TableName = "_TableName_";

        // 主キーとタイムスタンプ列
        parameterValue.AndEqualSearchConditions = (Dictionary <string, object>)Session["PrimaryKeyAndTimeStamp"];

        // 更新値(TimeStamp列は外す。主キーは採番方法次第。
        parameterValue.InsertUpdateValues = new Dictionary <string, object>();
        // ControlComment:LoopStart-ElseColumn
        parameterValue.InsertUpdateValues.Add("_ColumnName_", this.txt_ColumnName_.Text);
        // ControlComment:LoopEnd-ElseColumn

        // B層を生成
        _3TierEngine b = new _3TierEngine();

        // データ取得処理を実行
        _3TierReturnValue returnValue =
            (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

        // 結果表示
        this.lblResult.Text = returnValue.Obj.ToString() + "件更新しました。";

        // 画面遷移しない。
        return(string.Empty);
    }
Example #3
0
    /// <summary>追加ボタン</summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    protected string UOC_btnInsert_Click(FxEventArgs fxEventArgs)
    {
        // 引数クラスを生成
        _3TierParameterValue parameterValue = new _3TierParameterValue(
            this.ContentPageFileNoEx, fxEventArgs.ButtonID, "InsertRecord",
            (string)Session["DAP"], (MyUserInfo)this.UserInfo);

        // テーブル
        parameterValue.TableName = "my_table";

        // 追加値(TimeStamp列は外す。主キーは採番方法次第。
        parameterValue.InsertUpdateValues = new Dictionary <string, object>();
        parameterValue.InsertUpdateValues.Add("columnc", this.txtcolumnc.Text);
        parameterValue.InsertUpdateValues.Add("columnd", this.txtcolumnd.Text);

        // B層を生成
        _3TierEngine b = new _3TierEngine();

        // データ取得処理を実行
        _3TierReturnValue returnValue =
            (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

        // 結果表示
        this.lblResult.Text = returnValue.Obj.ToString() + "件追加しました。";

        // 画面遷移しない。
        return(string.Empty);
    }
Example #4
0
    /// <summary>データ件数取得処理を実装</summary>
    /// <returns>データ件数</returns>
    public int SelectCountMethod()
    {
        _3TierReturnValue returnValue = null;

        try
        {
            // ここのデータアクセス処理は棟梁のB層を呼び出して実装する。

            // ユーザ情報を取得
            MyUserInfo myUserInfo = MyBaseController.GetUserInfo2();

            // 引数クラスを生成
            _3TierParameterValue parameterValue
                = this.CreateParameter("_TableName_", "SelectCountMethod", myUserInfo);

            // B層を生成
            _3TierEngine b = new _3TierEngine();

            // データ件数取得処理を実行
            returnValue = (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);
        }
        catch (Exception ex)
        {
            MyBaseController.TransferErrorScreen2(ex);
            return(0);
        }

        // データ件数を返却
        //(OracleでdecimalになるケースがあるのでParseしている。)
        return(int.Parse(returnValue.Obj.ToString()));
    }
Example #5
0
    /// <summary>バッチ更新ボタン</summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    protected string UOC_btnBatUpd_Click(FxEventArgs fxEventArgs)
    {
        // 引数クラスを生成
        _3TierParameterValue parameterValue = new _3TierParameterValue(
            this.ContentPageFileNoEx, fxEventArgs.ButtonID, "BatchUpdate",
            (string)Session["DAP"], (MyUserInfo)UserInfoHandle.GetUserInformation());

        // テーブル
        parameterValue.TableName = "Products";

        // 主キーとタイムスタンプ列
        parameterValue.AndEqualSearchConditions = new Dictionary <string, object>();
        parameterValue.AndEqualSearchConditions.Add("ProductID", "");

        // DataTableを設定
        parameterValue.Obj = (DataTable)Session["SearchResult"];

        // B層を生成
        _3TierEngine b = new _3TierEngine();

        // データ取得処理を実行
        _3TierReturnValue returnValue =
            (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

        // 結果表示
        //this.lblResult.Text = returnValue.Obj.ToString() + "件更新しました。";

        // 画面遷移しない。
        return(string.Empty);
    }
    /// <summary>検索ボタン</summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    protected string UOC_btnSearch_Click(FxEventArgs fxEventArgs)
    {
        // GridViewをリセット
        this.gvwGridView1.PageIndex = 0;
        this.gvwGridView1.Sort("", SortDirection.Ascending);

        // 検索条件の収集
        // AndEqualSearchConditions
        Dictionary <string, object> andEqualSearchConditions = new Dictionary <string, object>();

        // ControlComment:LoopStart-PKColumn
        andEqualSearchConditions.Add("_JoinTextboxColumnName_", this.txt_JoinTextboxColumnName__And.Text);
        // ControlComment:LoopEnd-PKColumn
        // ControlComment:LoopStart-ElseColumn
        andEqualSearchConditions.Add("_JoinTextboxColumnName_", this.txt_JoinTextboxColumnName__And.Text);
        // ControlComment:LoopEnd-ElseColumn
        Session["AndEqualSearchConditions"] = andEqualSearchConditions;

        // 引数クラスを生成
        _3TierParameterValue parameterValue = new _3TierParameterValue(
            this.ContentPageFileNoEx, fxEventArgs.ButtonID, "SelectRecord",
            (string)Session["DAP"], (MyUserInfo)this.UserInfo);

        // テーブル
        parameterValue.TableName = "_JoinTableName_";

        // 主キーとタイムスタンプ列
        parameterValue.AndEqualSearchConditions = (Dictionary <string, object>)Session["AndEqualSearchConditions"];

        // B層を生成
        _3TierEngine b = new _3TierEngine();

        // データ取得処理を実行
        _3TierReturnValue returnValue =
            (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);
        //Declare Table to bind data to gridview
        DataTable dt = new DataTable();

        dt = returnValue.Dt;
        HttpContext.Current.Session["SearchResult"] = dt;

        // ヘッダーを設定する。
        this.gvwGridView1.Columns[_ColumnNmbr_].HeaderText = "Select";
        // ControlComment:LoopStart-PKColumn
        this.gvwGridView1.Columns[_ColumnNmbr_].HeaderText = "_JoinTextboxColumnName_";
        // ControlComment:LoopEnd-PKColumn
        // ControlComment:LoopStart-ElseColumn
        this.gvwGridView1.Columns[_ColumnNmbr_].HeaderText = "_JoinTextboxColumnName_";
        // ControlComment:LoopEnd-ElseColumn

        //Bind gridview
        this.gvwGridView1.DataSource = dt;
        this.gvwGridView1.DataBind();

        //Return empty string since there is no need to redirect to any other page.
        return(string.Empty);
    }
Example #7
0
        /// <summary>データ取得処理を実装</summary>
        /// <param name="startRowIndex">開始位置</param>
        /// <param name="maximumRows">取得行数</param>
        /// <returns>DataTable</returns>
        public DataTable SelectMethod(int startRowIndex, int maximumRows)
        {
            _3TierReturnValue returnValue = null;

            try
            {
                // ここのデータアクセス処理は棟梁のB層を呼び出して実装する。

                // ユーザ情報を取得
                MyUserInfo myUserInfo = MyBaseController.GetUserInfo2();

                // 引数クラスを生成
                _3TierParameterValue parameterValue
                    = this.CreateParameter("Products", "SelectMethod", myUserInfo);

                // カラムリスト(射影
                parameterValue.ColumnList =
                    "_s_ProductID_e_, "
                    + "_s_ProductName_e_, "
                    + "_s_SupplierID_e_, "
                    + "_s_CategoryID_e_, "
                    + "_s_QuantityPerUnit_e_, "
                    + "_s_UnitPrice_e_, "
                    + "_s_UnitsInStock_e_, "
                    + "_s_UnitsOnOrder_e_, "
                    + "_s_ReorderLevel_e_, "
                    + "_s_Discontinued_e_";

                // ソート条件
                parameterValue.SortExpression =
                    (string)HttpContext.Current.Session["SortExpression"];
                parameterValue.SortDirection =
                    (string)HttpContext.Current.Session["SortDirection"];

                // ページング条件
                parameterValue.MaximumRows   = maximumRows;
                parameterValue.StartRowIndex = startRowIndex;

                // B層を生成
                _3TierEngine b = new _3TierEngine();

                // データ取得処理を実行
                returnValue = (_3TierReturnValue)b.DoBusinessLogic(
                    (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

                // GridView1.DataSourceから取得できなかったのでSessionに格納。
                HttpContext.Current.Session["SearchResult"] = returnValue.Dt;
            }
            catch (Exception ex)
            {
                MyBaseController.TransferErrorScreen2(ex);
                return(null);
            }

            // 取得データを返却
            return(returnValue.Dt);
        }
Example #8
0
    /// <summary>
    /// ページロードのUOCメソッド(個別:初回ロード)
    /// </summary>
    /// <remarks>
    /// 実装必須
    /// </remarks>
    protected override void UOC_FormInit()
    {
        // フォーム初期化(初回ロード)時に実行する処理を実装する

        // TODO:
        _3TierParameterValue parameterValue = null;
        _3TierReturnValue    returnValue    = null;

        if (Session["PrimaryKeyAndTimeStamp"] == null)
        {
            // 追加処理のみ。
            this.btnEdit.Enabled   = false;
            this.btnUpdate.Enabled = false;
            this.btnDelete.Enabled = false;

            // 編集
            this.SetControlReadOnly(false);
        }
        else
        {
            // 詳細表示処理

            // 引数クラスを生成
            parameterValue = new _3TierParameterValue(
                this.ContentPageFileNoEx, "FormInit", "SelectRecord",
                (string)Session["DAP"], (MyUserInfo)this.UserInfo);

            // テーブル
            parameterValue.TableName = "Products";

            // 主キーとタイムスタンプ列
            parameterValue.AndEqualSearchConditions = (Dictionary <string, object>)Session["PrimaryKeyAndTimeStamp"];

            // B層を生成
            _3TierEngine b = new _3TierEngine();

            // データ取得処理を実行
            returnValue = (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

            // 編集状態の初期化

            // 値
            this.txtProductID.Text       = returnValue.Dt.Rows[0]["ProductID"].ToString();
            this.txtProductName.Text     = returnValue.Dt.Rows[0]["ProductName"].ToString();
            this.txtSupplierID.Text      = returnValue.Dt.Rows[0]["SupplierID"].ToString();
            this.txtCategoryID.Text      = returnValue.Dt.Rows[0]["CategoryID"].ToString();
            this.txtQuantityPerUnit.Text = returnValue.Dt.Rows[0]["QuantityPerUnit"].ToString();
            this.txtUnitPrice.Text       = returnValue.Dt.Rows[0]["UnitPrice"].ToString();
            this.txtUnitsInStock.Text    = returnValue.Dt.Rows[0]["UnitsInStock"].ToString();
            this.txtUnitsOnOrder.Text    = returnValue.Dt.Rows[0]["UnitsOnOrder"].ToString();
            this.txtReorderLevel.Text    = returnValue.Dt.Rows[0]["ReorderLevel"].ToString();
            this.txtDiscontinued.Text    = returnValue.Dt.Rows[0]["Discontinued"].ToString();
            // 編集
            this.SetControlReadOnly(true);
        }
    }
Example #9
0
    /// <summary>
    /// ページロードのUOCメソッド(個別:初回ロード)
    /// </summary>
    /// <remarks>
    /// 実装必須
    /// </remarks>
    protected override void UOC_FormInit()
    {
        // フォーム初期化(初回ロード)時に実行する処理を実装する

        // TODO:
        _3TierParameterValue parameterValue = null;
        _3TierReturnValue    returnValue    = null;

        if (Session["PrimaryKeyAndTimeStamp"] == null)
        {
            // 追加処理のみ。
            this.btnEdit.Enabled   = false;
            this.btnUpdate.Enabled = false;
            this.btnDelete.Enabled = false;

            // 編集
            this.SetControlReadOnly(false);
        }
        else
        {
            // 詳細表示処理

            // 引数クラスを生成
            parameterValue = new _3TierParameterValue(
                this.ContentPageFileNoEx, "FormInit", "SelectRecord",
                (string)Session["DAP"], (MyUserInfo)this.UserInfo);

            // テーブル
            parameterValue.TableName = "_TableName_";

            // 主キーとタイムスタンプ列
            parameterValue.AndEqualSearchConditions = (Dictionary <string, object>)Session["PrimaryKeyAndTimeStamp"];

            // B層を生成
            _3TierEngine b = new _3TierEngine();

            // データ取得処理を実行
            returnValue = (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

            // 編集状態の初期化

            // 値
            // ControlComment:LoopStart-PKColumn
            this.txt_ColumnName_.Text = returnValue.Dt.Rows[0]["_ColumnName_"].ToString();
            // ControlComment:LoopEnd-PKColumn
            // ControlComment:LoopStart-ElseColumn
            this.txt_ColumnName_.Text = returnValue.Dt.Rows[0]["_ColumnName_"].ToString();
            // ControlComment:LoopEnd-ElseColumn
            // 編集
            this.SetControlReadOnly(true);
            Session["PrimaryKeyAndTimeStamp"] = null;
        }
    }
Example #10
0
    /// <summary>更新ボタン</summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    protected string UOC_btnUpdate_Click(FxEventArgs fxEventArgs)
    {
        #region  Create the instance of classes here

        // 引数クラスを生成
        _3TierParameterValue parameterValue = new _3TierParameterValue(
            this.ContentPageFileNoEx, fxEventArgs.ButtonID, "UpdateRecord",
            (string)Session["DAP"], (MyUserInfo)this.UserInfo);

        //Initialize the data access procedure
        _3TierReturnValue returnValue = null;
        // B layer Initialize
        _3TierEngine b = new _3TierEngine();
        Dictionary <string, object> UpdateWhereConditions = (Dictionary <string, object>)Session["PrimaryKeyAndTimeStamp"];
        #endregion

        // ControlComment:LoopStart-JoinTables
        #region  Set the values to be updated to the _TableName_. Then Update to database
        // Remove '_TableName__' from the PrimaryKeyandTimeStamp dictionary Key values so developer need not to change the values manually in Dao_TableName__S3_UPDATE.xml
        parameterValue.AndEqualSearchConditions = new Dictionary <string, object>();
        foreach (string k in UpdateWhereConditions.Keys)
        {
            if (k.Split('_')[0] == "_TableName_")
            {
                parameterValue.AndEqualSearchConditions.Add(k.Split('_')[1], UpdateWhereConditions[k]);
            }
        }
        //Declare InsertUpdateValue dictionary and add the values to it
        parameterValue.InsertUpdateValues = new Dictionary <string, object>();
        // ControlComment:LoopStart-PKColumn
        parameterValue.InsertUpdateValues.Add("_ColumnName_", this.txt_JoinTextboxColumnName_.Text);
        // ControlComment:LoopEnd-PKColumn
        // ControlComment:LoopStart-ElseColumn
        parameterValue.InsertUpdateValues.Add("_ColumnName_", this.txt_JoinTextboxColumnName_.Text);
        // ControlComment:LoopEnd-ElseColumn

        //Reset returnvalue with null;
        returnValue = null;
        //Name of the table  _TableName_
        parameterValue.TableName = "_TableName_";

        // Run the Database access process
        returnValue =
            (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

        this.lblResult_TableName_.Text = returnValue.Obj.ToString() + " Data is Updated to the table: _TableName_";
        #endregion

        // ControlComment:LoopEnd-JoinTables
        //Return empty string since there is no need to redirect to any other page.
        return(string.Empty);
    }
    /// <summary>削除ボタン</summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    /// <remarks>In case of deleting from multiple tables and when the tables have dependent relation, the sequence of execution of delete statements for these tables become necessary.
    /// Developer should decide the sequence of table for the delete operation.
    /// This can be managed by altering the position of code block present in the region 'Delete the data from the [TableName] table' as required</remarks>
    protected string UOC_btnDelete_Click(FxEventArgs fxEventArgs)
    {
        #region  Create the instance of classes here
        // 引数クラスを生成
        _3TierParameterValue parameterValue = new _3TierParameterValue(
            this.ContentPageFileNoEx, fxEventArgs.ButtonID, "DeleteRecordDM",
            (string)Session["DAP"], (MyUserInfo)this.UserInfo);

        //Initialize the data access procedure
        _3TierReturnValue returnValue = null;
        // B layer Initialize
        _3TierEngine b = new _3TierEngine();
        Dictionary <string, object> DeleteWhereConditions = (Dictionary <string, object>)Session["PrimaryKeyAndTimeStamp"];
        // Modifications for DM
        parameterValue.AndEqualSearchConditions = new Dictionary <string, object>();
        parameterValue.TargetTableNames         = new Dictionary <int, string>();
        //Declaring the table counter to add it to TargetTableNames Dictionary
        int TableCounter = 0;
        #endregion

        // ControlComment:LoopStart-JoinTables
        #region  Delete the data from the _TableName_  table
        // Remove '_TableName__' from the PrimaryKeyandTimeStamp dictionary Key values so developer need not to change the values manually in Dao_TableName__S4_Delete.xml
        TableCounter = TableCounter + 1;
        foreach (string k in DeleteWhereConditions.Keys)
        {
            if (k.Split('_')[0] == "_TableName_")
            {
                //Check to avoid duplicate key addition
                if (!parameterValue.AndEqualSearchConditions.ContainsKey(k))
                {
                    parameterValue.AndEqualSearchConditions.Add(k, DeleteWhereConditions[k]);
                }
            }
        }
        //Reset returnvalue with null;
        returnValue = null;
        //Name of the table  _TableName_
        parameterValue.TargetTableNames.Add(TableCounter, "_TableName_");
        #endregion
        // ControlComment:LoopEnd-JoinTables
        // Run the Database access process
        returnValue =
            (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

        this.lblResult_TableName_.Text = returnValue.Obj.ToString() + " Data is Deleted from the table Successfully";

        //Return empty string since there is no need to redirect to any other page.
        return(string.Empty);
    }
        /// <summary>更新Button</summary>
        /// <param name="fxEventArgs">Event Handlerの共通引数</param>
        /// <returns>URL</returns>
        protected string UOC_btnUpdate_Click(FxEventArgs fxEventArgs)
        {
            // 引数クラスを生成
            _3TierParameterValue parameterValue = new _3TierParameterValue(
                this.ContentPageFileNoEx, fxEventArgs.ButtonID, "UpdateRecord",
                (string)Session["DAP"], (MyUserInfo)this.UserInfo);

            // テーブル
            parameterValue.TableName = "Products";

            // 主キーとタイムスタンプ列
            parameterValue.AndEqualSearchConditions = (Dictionary <string, object>)Session["PrimaryKeyAndTimeStamp"];

            // 更新値(TimeStamp列は外す。主キーは採番方法次第。
            parameterValue.InsertUpdateValues = new Dictionary <string, object>();
            //parameterValue.InsertUpdateValues.Add("ProductID", this.txtProductID.Text);
            parameterValue.InsertUpdateValues.Add("ProductName", this.txtProductName.Text);

            //parameterValue.InsertUpdateValues.Add("SupplierID", this.txtSupplierID.Text);
            parameterValue.InsertUpdateValues.Add("SupplierID", this.ddlSupplierID.SelectedValue);
            //parameterValue.InsertUpdateValues.Add("CategoryID", this.txtCategoryID.Text);
            parameterValue.InsertUpdateValues.Add("CategoryID", this.ddlCategoryID.SelectedValue);

            parameterValue.InsertUpdateValues.Add("QuantityPerUnit", this.txtQuantityPerUnit.Text);
            parameterValue.InsertUpdateValues.Add("UnitPrice", this.txtUnitPrice.Text);
            parameterValue.InsertUpdateValues.Add("UnitsInStock", this.txtUnitsInStock.Text);
            parameterValue.InsertUpdateValues.Add("UnitsOnOrder", this.txtUnitsOnOrder.Text);
            parameterValue.InsertUpdateValues.Add("ReorderLevel", this.txtReorderLevel.Text);
            parameterValue.InsertUpdateValues.Add("Discontinued", this.txtDiscontinued.Text);

            // B層を生成
            _3TierEngine b = new _3TierEngine();

            // データ取得処理を実行
            _3TierReturnValue returnValue =
                (_3TierReturnValue)b.DoBusinessLogic(
                    (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

            // 結果表示
            this.lblResult.Text = returnValue.Obj.ToString() + "件更新しました。";

            // 画面遷移しない。
            return(string.Empty);
        }
    /// <summary>バッチ更新ボタン</summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    protected string UOC_btnBatUpd_Click(FxEventArgs fxEventArgs)
    {
        // 引数クラスを生成
        _3TierParameterValue parameterValue = new _3TierParameterValue(
            this.ContentPageFileNoEx, fxEventArgs.ButtonID, "BatchUpdate",
            (string)Session["DAP"], (MyUserInfo)this.UserInfo);

        // テーブル
        parameterValue.TableName = "_TableName_";

        // 主キーとタイムスタンプ列
        parameterValue.AndEqualSearchConditions = new Dictionary <string, object>();

        // 主キー列
        // ControlComment:LoopStart-PKColumn
        parameterValue.AndEqualSearchConditions.Add("_ColumnName_", "");
        // ControlComment:LoopEnd-PKColumn

        // タイムスタンプ列
        // ControlComment:ControlComment:IsRequired-TimeStamp
        // ...
        parameterValue.AndEqualSearchConditions.Add("_TimeStampColName_", "");

        // DataTableを設定
        parameterValue.Obj = (DataTable)Session["SearchResult"];

        // B層を生成
        _3TierEngine b = new _3TierEngine();

        // データ取得処理を実行
        _3TierReturnValue returnValue =
            (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

        // 結果表示
        //this.lblResult.Text = returnValue.Obj.ToString() + "件更新しました。";

        // 更新ボタンの非活性化
        this.btnBatUpd.Enabled = false;

        // 画面遷移しない。
        return(string.Empty);
    }
Example #14
0
    /// <summary>追加ボタン</summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    protected string UOC_btnInsert_Click(FxEventArgs fxEventArgs)
    {
        #region  Create the instance of classes here
        // 引数クラスを生成
        _3TierParameterValue parameterValue = new _3TierParameterValue(
            this.ContentPageFileNoEx, fxEventArgs.ButtonID, "InsertRecord",
            (string)Session["DAP"], (MyUserInfo)this.UserInfo);

        //Initialize the data access procedure
        _3TierReturnValue returnValue = null;
        // B layer Initialize
        _3TierEngine b = new _3TierEngine();
        #endregion

        // ControlComment:LoopStart-JoinTables
        #region  Set the values to be inserted into to the _TableName_ . Then insert into database
        //Declare InsertUpdateValue dictionary and add the values to it
        parameterValue.InsertUpdateValues = new Dictionary <string, object>();
        // ControlComment:LoopStart-PKColumn
        parameterValue.InsertUpdateValues.Add("_ColumnName_", this.txt_JoinTextboxColumnName_.Text);
        // ControlComment:LoopEnd-PKColumn
        // ControlComment:LoopStart-ElseColumn
        parameterValue.InsertUpdateValues.Add("_ColumnName_", this.txt_JoinTextboxColumnName_.Text);
        // ControlComment:LoopEnd-ElseColumn

        //Reset returnvalue with null;
        returnValue = null;
        //Name of the table  _TableName_
        parameterValue.TableName = "_TableName_";

        // Run the Database access process
        returnValue =
            (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

        this.lblResult_TableName_.Text = returnValue.Obj.ToString() + " Data is Inserted into table: _TableName_";
        #endregion

        // ControlComment:LoopEnd-JoinTables
        //Return empty string since there is no need to redirect to any other page.
        return(string.Empty);
    }
Example #15
0
    /// <summary>追加ボタン</summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    protected string UOC_btnInsert_Click(FxEventArgs fxEventArgs)
    {
        // 引数クラスを生成
        _3TierParameterValue parameterValue = new _3TierParameterValue(
            this.ContentPageFileNoEx, fxEventArgs.ButtonID, "InsertRecord",
            (string)Session["DAP"], (MyUserInfo)UserInfoHandle.GetUserInformation());

        // テーブル
        parameterValue.TableName = "Products";

        // 追加値(TimeStamp列は外す。
        parameterValue.InsertUpdateValues = new Dictionary <string, object>();
        //parameterValue.InsertUpdateValues.Add("ProductID", this.txtProductID.Text);
        parameterValue.InsertUpdateValues.Add("ProductName", this.txtProductName.Text);
        parameterValue.InsertUpdateValues.Add("SupplierID", this.txtSupplierID.Text);
        parameterValue.InsertUpdateValues.Add("CategoryID", this.txtCategoryID.Text);
        parameterValue.InsertUpdateValues.Add("QuantityPerUnit", this.txtQuantityPerUnit.Text);
        parameterValue.InsertUpdateValues.Add("UnitPrice", this.txtUnitPrice.Text);
        parameterValue.InsertUpdateValues.Add("UnitsInStock", this.txtUnitsInStock.Text);
        parameterValue.InsertUpdateValues.Add("UnitsOnOrder", this.txtUnitsOnOrder.Text);
        parameterValue.InsertUpdateValues.Add("ReorderLevel", this.txtReorderLevel.Text);
        parameterValue.InsertUpdateValues.Add("Discontinued", this.txtDiscontinued.Text);

        // B層を生成
        _3TierEngine b = new _3TierEngine();

        // データ取得処理を実行
        _3TierReturnValue returnValue =
            (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

        // 結果表示
        this.lblResult.Text = returnValue.Obj.ToString() + "件追加しました。";

        // 画面遷移しない。
        return(string.Empty);
    }
        /// <summary>
        /// Page LoadのUOCメソッド(個別:初回Load)
        /// </summary>
        /// <remarks>
        /// 実装必須
        /// </remarks>
        protected override void UOC_FormInit()
        {
            // Form初期化(初回Load)時に実行する処理を実装する

            // TODO:
            _3TierParameterValue parameterValue = null;
            _3TierReturnValue    returnValue    = null;

            if (Session["PrimaryKeyAndTimeStamp"] == null)
            {
                // 追加処理のみ。
                this.btnEdit.Enabled   = false;
                this.btnUpdate.Enabled = false;
                this.btnDelete.Enabled = false;

                // 編集
                this.SetControlReadOnly(false);
            }
            else
            {
                // 詳細表示処理

                // 引数クラスを生成
                parameterValue = new _3TierParameterValue(
                    this.ContentPageFileNoEx, "FormInit", "SelectRecord",
                    (string)Session["DAP"], (MyUserInfo)this.UserInfo);

                // テーブル
                parameterValue.TableName = "Products";

                // 主キーとタイムスタンプ列
                parameterValue.AndEqualSearchConditions = (Dictionary <string, object>)Session["PrimaryKeyAndTimeStamp"];

                // B層を生成
                _3TierEngine b = new _3TierEngine();

                // データ取得処理を実行
                returnValue = (_3TierReturnValue)b.DoBusinessLogic(
                    (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

                // 編集状態の初期化

                // 値
                this.txtProductID.Text   = returnValue.Dt.Rows[0]["ProductID"].ToString();
                this.txtProductName.Text = returnValue.Dt.Rows[0]["ProductName"].ToString();

                //this.txtSupplierID.Text = returnValue.Dt.Rows[0]["SupplierID"].ToString();
                this.ddlSupplierID.SelectedValue = returnValue.Dt.Rows[0]["SupplierID"].ToString();
                //this.txtCategoryID.Text = returnValue.Dt.Rows[0]["CategoryID"].ToString();
                this.ddlCategoryID.SelectedValue = returnValue.Dt.Rows[0]["CategoryID"].ToString();

                this.txtQuantityPerUnit.Text = returnValue.Dt.Rows[0]["QuantityPerUnit"].ToString();
                this.txtUnitPrice.Text       = returnValue.Dt.Rows[0]["UnitPrice"].ToString();
                this.txtUnitsInStock.Text    = returnValue.Dt.Rows[0]["UnitsInStock"].ToString();
                this.txtUnitsOnOrder.Text    = returnValue.Dt.Rows[0]["UnitsOnOrder"].ToString();
                this.txtReorderLevel.Text    = returnValue.Dt.Rows[0]["ReorderLevel"].ToString();
                this.txtDiscontinued.Text    = returnValue.Dt.Rows[0]["Discontinued"].ToString();

                // 編集
                this.SetControlReadOnly(true);
            }

            #region マスタ・データのロードと設定

            // 引数クラスを生成
            // 下位(B・D層)は、テスト クラスを流用する
            parameterValue
                = new _3TierParameterValue(
                      this.ContentPageFileNoEx,
                      "FormInit_PostBack", "Invoke",
                      this.ddlDap.SelectedValue,
                      this.UserInfo);

            // B層を生成
            GetMasterData getMasterData = new GetMasterData();

            // 業務処理を実行
            returnValue = (_3TierReturnValue)getMasterData.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

            DataTable[] dts = (DataTable[])returnValue.Obj;
            DataTable   dt  = null;
            DataRow     dr  = null;

            // daoSuppliers
            _3TierEngine.CreateDropDownListDataSourceDataTable(
                dts[0], "SupplierID", "CompanyName", out dt, "value", "text");

            dr          = dt.NewRow();
            dr["value"] = "";
            dr["text"]  = "empty";
            dt.Rows.Add(dr);
            dt.AcceptChanges();

            this.ddlSupplierID.DataValueField = "value";
            this.ddlSupplierID.DataTextField  = "text";

            this.ddlSupplierID.DataSource = dt;
            this.ddlSupplierID.DataBind();

            // daoCategories
            _3TierEngine.CreateDropDownListDataSourceDataTable(
                dts[1], "CategoryID", "CategoryName", out dt, "value", "text");

            dr          = dt.NewRow();
            dr["value"] = "";
            dr["text"]  = "empty";
            dt.Rows.Add(dr);
            dt.AcceptChanges();

            this.ddlCategoryID.DataValueField = "value";
            this.ddlCategoryID.DataTextField  = "text";

            this.ddlCategoryID.DataSource = dt;
            this.ddlCategoryID.DataBind();

            // 追加時はSelectedValueに空の値を設定
            if (Session["PrimaryKeyAndTimeStamp"] == null)
            {
                this.ddlSupplierID.SelectedValue = "";
                this.ddlCategoryID.SelectedValue = "";
            }

            #endregion
        }
Example #17
0
    /// <summary>バッチ更新ボタン</summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    /// <remarks>In case of deleting from multiple tables and when the tables have dependent relation, the sequence of execution of delete statements for these tables become necessary.
    /// Developer should decide the sequence of table for the delete operation.
    /// This can be managed by altering the position of code block present in the region 'Batch Update for [TableName]  table' as required</remarks>
    protected string UOC_btnBatUpd_Click(FxEventArgs fxEventArgs)
    {
        #region  Create the instance of classes here

        // 引数クラスを生成
        _3TierParameterValue parameterValue = new _3TierParameterValue(
            this.ContentPageFileNoEx, fxEventArgs.ButtonID, "BatchUpdateDM",
            (string)Session["DAP"], (MyUserInfo)this.UserInfo);

        //Initialize the data access procedure
        _3TierReturnValue returnValue = null;
        // B layer Initialize
        _3TierEngine b = new _3TierEngine();
        parameterValue.AndEqualSearchConditions = new Dictionary <string, object>();
        parameterValue.TargetTableNames         = new Dictionary <int, string>();
        //Declaring the table counter to add it to TargetTableNames Dictionary
        int TableCounter = 0;
        //Keep the copy of the table in session because change in the column name causes the problem in the temperory update after batch update. So keep the copy of the table.
        DataTable dtSession = ((DataTable)Session["SearchResult"]).Copy();
        #endregion

        // ControlComment:LoopStart-JoinTables

        #region  Batch Update for _TableName_  table


        #region This is much needed to handle the duplicate column issue while udpating  _TableName_ using batch update
        TableCounter = TableCounter + 1;
        foreach (DataColumn dc in dtSession.Columns)
        {
            //Replace "." in column names of other tables with "_". This is needed becuase if columns are having "." then we get sql error, so we need to replace "." with "_"
            dc.ColumnName = dc.ColumnName.Replace('.', '_');
        }

        #endregion

        //Reset returnvalue with null;
        returnValue = null;


        //Primary Key Columns
        // ControlComment:LoopStart-PKColumn
        if (!parameterValue.AndEqualSearchConditions.ContainsKey("_JoinTextboxColumnName_"))
        {
            parameterValue.AndEqualSearchConditions.Add("_JoinTextboxColumnName_", "");
        }
        // ControlComment:LoopEnd-PKColumn
        //Timestamp column
        TS_CommentOut_ parameterValue.AndEqualSearchConditions.Add("_TimeStampColName_", "");

        // Table Name
        parameterValue.TargetTableNames.Add(TableCounter, "_TableName_");
        #endregion
        // ControlComment:LoopEnd-JoinTables

        // DataTableを設定
        parameterValue.Obj = dtSession;

        // Run the Database access process
        returnValue =
            (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

        // Disable the button
        this.btnBatUpd.Enabled = false;
        //No Screen transition
        return(string.Empty);
    }
Example #18
0
    /// <summary>バッチ更新ボタン</summary>
    /// <param name="fxEventArgs">イベントハンドラの共通引数</param>
    /// <returns>URL</returns>
    protected string UOC_btnBatUpd_Click(FxEventArgs fxEventArgs)
    {
        #region  Create the instance of classes here

        // 引数クラスを生成
        _3TierParameterValue parameterValue = new _3TierParameterValue(
            this.ContentPageFileNoEx, fxEventArgs.ButtonID, "BatchUpdate",
            (string)Session["DAP"], (MyUserInfo)this.UserInfo);

        //Initialize the data access procedure
        _3TierReturnValue returnValue = null;
        // B layer Initialize
        _3TierEngine b = new _3TierEngine();

        //Keep the copy of the table in session because change in the column name causes the problem in the temperory update after batch update. So keep the copy of the table.
        DataTable dtSession = ((DataTable)Session["SearchResult"]).Copy();
        #endregion
        // ControlComment:LoopStart-JoinTables

        #region  Batch Update for _TableName_  table

        #region This is much needed to handle the duplicate column issue while udpating  _TableName_ using batch update
        // to change the column names of table as per Table we should have copy of dtSession table.
        DataTable dt_TableName_ = dtSession.Copy();

        foreach (DataColumn dc in dt_TableName_.Columns)
        {
            //Remove the '_TableName_.' from column names of _TableName_ only so that update will not have any problem.
            //Otherwise When two tables are having same column names then we get an  error "A column named 'Columname' already belongs to this DataTable."
            if (dc.ColumnName.Split('.')[0].Trim() == "_TableName_")
            {
                dc.ColumnName = dc.ColumnName.Split('.')[1].Trim();
            }
            //Replace "." in column names of other tables with "_". This is needed becuase if columns are having "." then we get sql error, so we need to replace "." with "_"
            else
            {
                dc.ColumnName = dc.ColumnName.Replace('.', '_');
            }
        }

        #endregion

        // DataTableを設定
        parameterValue.Obj = dt_TableName_;

        //Reset returnvalue with null;
        returnValue = null;

        parameterValue.AndEqualSearchConditions = new Dictionary <string, object>();
        //Primary Key Columns
        // ControlComment:LoopStart-PKColumn
        parameterValue.AndEqualSearchConditions.Add("_ColumnName_", "");
        // ControlComment:LoopEnd-PKColumn
        //Timestamp column
        TS_CommentOut_ parameterValue.AndEqualSearchConditions.Add("_TimeStampColName_", "");

        // Table Name
        parameterValue.TableName = "_TableName_";

        // Run the Database access process
        returnValue =
            (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

        #endregion
        // ControlComment:LoopEnd-JoinTables

        // Disable the button
        this.btnBatUpd.Enabled = false;
        // Keep the original session table with actual column names.
        Session["SearchResult"] = dtSession;
        //No Screen transition
        return(string.Empty);
    }
Example #19
0
    /// <summary>
    /// ページロードのUOCメソッド(個別:初回ロード)
    /// </summary>
    /// <remarks>
    /// 実装必須
    /// </remarks>
    protected override void UOC_FormInit()
    {
        // フォーム初期化(初回ロード)時に実行する処理を実装する

        // TODO:

        // 詳細表示処理

        // 引数クラスを生成
        _3TierParameterValue parameterValue = new _3TierParameterValue(
            this.ContentPageFileNoEx, "FormInit", "SelectRecord",
            (string)Session["DAP"], (MyUserInfo)UserInfoHandle.GetUserInformation());

        // テーブル
        parameterValue.TableName = "Products";

        // 主キーとタイムスタンプ列
        // 主キー列
        parameterValue.AndEqualSearchConditions = (Dictionary <string, object>)Session["PrimaryKeyAndTimeStamp"];
        // タイムスタンプ列

        // B層を生成
        _3TierEngine b = new _3TierEngine();

        // データ取得処理を実行
        _3TierReturnValue returnValue =
            (_3TierReturnValue)b.DoBusinessLogic(
                (BaseParameterValue)parameterValue, DbEnum.IsolationLevelEnum.ReadCommitted);

        // 編集状態の初期化

        // 値
        this.txtProductID.Text       = returnValue.Dt.Rows[0]["ProductID"].ToString();
        this.txtProductName.Text     = returnValue.Dt.Rows[0]["ProductName"].ToString();
        this.txtSupplierID.Text      = returnValue.Dt.Rows[0]["SupplierID"].ToString();
        this.txtCategoryID.Text      = returnValue.Dt.Rows[0]["CategoryID"].ToString();
        this.txtQuantityPerUnit.Text = returnValue.Dt.Rows[0]["QuantityPerUnit"].ToString();
        this.txtUnitPrice.Text       = returnValue.Dt.Rows[0]["UnitPrice"].ToString();
        this.txtUnitsInStock.Text    = returnValue.Dt.Rows[0]["UnitsInStock"].ToString();
        this.txtUnitsOnOrder.Text    = returnValue.Dt.Rows[0]["UnitsOnOrder"].ToString();
        this.txtReorderLevel.Text    = returnValue.Dt.Rows[0]["ReorderLevel"].ToString();
        this.txtDiscontinued.Text    = returnValue.Dt.Rows[0]["Discontinued"].ToString();

        // 編集
        this.txtProductID.ReadOnly       = true;
        this.txtProductName.ReadOnly     = true;
        this.txtSupplierID.ReadOnly      = true;
        this.txtCategoryID.ReadOnly      = true;
        this.txtQuantityPerUnit.ReadOnly = true;
        this.txtUnitPrice.ReadOnly       = true;
        this.txtUnitsInStock.ReadOnly    = true;
        this.txtUnitsOnOrder.ReadOnly    = true;
        this.txtReorderLevel.ReadOnly    = true;
        this.txtDiscontinued.ReadOnly    = true;

        // 背景色
        this.txtProductID.BackColor       = System.Drawing.Color.LightGray;
        this.txtProductName.BackColor     = System.Drawing.Color.LightGray;
        this.txtSupplierID.BackColor      = System.Drawing.Color.LightGray;
        this.txtCategoryID.BackColor      = System.Drawing.Color.LightGray;
        this.txtQuantityPerUnit.BackColor = System.Drawing.Color.LightGray;
        this.txtUnitPrice.BackColor       = System.Drawing.Color.LightGray;
        this.txtUnitsInStock.BackColor    = System.Drawing.Color.LightGray;
        this.txtUnitsOnOrder.BackColor    = System.Drawing.Color.LightGray;
        this.txtReorderLevel.BackColor    = System.Drawing.Color.LightGray;
        this.txtDiscontinued.BackColor    = System.Drawing.Color.LightGray;
    }