/// <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 }
/// <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; }