}//databind_Mst /// <summary> /// 繫結資料 Dtl /// </summary> private void databind_Dtl() { #region try { #region 檢視市調商品 try { BCO.MaintainMarketSurveyRecordsDtl bco = new BCO.MaintainMarketSurveyRecordsDtl(ConnectionDB); ParameterList.Clear(); ParameterList.Add(this.hiddenID.Value); DataTable dt = bco.QuerySurveyRecDetlByPID(ParameterList); this.gvDtl.DataSource = dt; this.gvDtl.DataBind(); Session["MKT132_DTL_" + PageTimeStamp.Value] = dt; } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion } catch (Exception ex) { this.ErrorMsgLabel.Text = ex.ToString(); } finally { } #endregion }//databind_Dtl
protected void Btn_Cancel_Click(object sender, EventArgs e) { try { switch (this.hid_PageStatus.Value) { case "EDIT": #region 設定頁面狀態 this.hid_PageStatus.Value = "VIEW"; this.txt_PageStatus.Text = "VIEW"; #endregion #region 檢視市調商品 try { BCO.MaintainMarketSurveyRecordsDtl bco = new BCO.MaintainMarketSurveyRecordsDtl(ConnectionDB); ParameterList.Clear(); ParameterList.Add(this.hiddenID.Value); DataTable dt = bco.QuerySurveyRecDetlByPID(ParameterList); this.gvDtl.DataSource = dt; this.gvDtl.DataBind(); Session["MKT132_DTL_" + PageTimeStamp.Value] = dt; } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion break; case "VIEW": Response.Redirect("MKT131.aspx?&Code=MKT13"); break; default: break; } } catch (Exception ex) { this.ErrorMsgLabel.Text = ex.ToString(); } finally { if (this.ErrorMsgLabel.Text == "") { SetPageStatus(); } } }
/// <summary> /// 繫結舊有營業所,市調日期資料 /// </summary> private void databind_Old() { #region try { DataTable Dt = new DataTable(); #region 取得查詢參數: 營業所,市調日期 ParameterList.Clear(); ParameterList.Add(GetValueSetParameter(this.SLP_CodeFile1.Text, "string")); //營業所 ParameterList.Add(GetValueSetParameter(this.dSurveyDate.Text, "date")); //市調日期 ParameterList.Add(GetValueSetParameter("", "string")); //市調人員 不納入查詢條件 #endregion #region 處理查詢 BCO.MaintainMarketSurveyRecords bcoMain = new MaintainMarketSurveyRecords(ConnectionDB); Dt = bcoMain.QuerySurveyRecMain(ParameterList); #endregion if (Dt == null || (Dt != null && Dt.Rows.Count <= 0)) { Session["MKT133_MAIN_OLD" + PageTimeStamp.Value] = null; return; } this.txtInvestigator.Text = Dt.Rows[0]["INVESTIGATOR"].ToString(); #region 設定查詢結果 this.GridView1.DataSource = Dt; this.GridView1.PageSize = 20;// (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); this.GridView1.PageIndex = 0; this.GridView1.DataBind(); Session["MKT133_MAIN_" + PageTimeStamp.Value] = Dt.Copy(); Session["MKT133_MAIN_OLD" + PageTimeStamp.Value] = Dt.Copy(); #endregion BCO.MaintainMarketSurveyRecordsDtl bco = new BCO.MaintainMarketSurveyRecordsDtl(ConnectionDB); ParameterList.Clear(); ParameterList.Add(Dt.Rows[0]["ID"].ToString()); DataTable dtDtl = bco.QuerySurveyRecDetlByPID(ParameterList); //設定市調商品 column DataTable dt = new DataTable(); DataColumn dcNew; dcNew = new DataColumn("ITEM", Type.GetType("System.String")); dt.Columns.Add(dcNew); dcNew = new DataColumn("PERIOD", Type.GetType("System.String")); dt.Columns.Add(dcNew); dcNew = new DataColumn("PUBLISH_DATE", Type.GetType("System.String")); dt.Columns.Add(dcNew); dcNew = new DataColumn("SURVEY_TIME", Type.GetType("System.Int32")); dt.Columns.Add(dcNew); //產生20筆資料供編輯 for (int i = 0; i < 20; i++) { DataRow drNew; drNew = dt.NewRow(); if (i < dtDtl.Rows.Count) { drNew["ITEM"] = dtDtl.Rows[i]["ITEM"].ToString(); drNew["PERIOD"] = dtDtl.Rows[i]["PERIOD"].ToString(); //drNew["PUBLISH_DATE"] = ((DateTime)dtDtl.Rows[i]["PUBLISH_DATE"]).ToString("yyyy/MM/dd"); drNew["SURVEY_TIME"] = GetValueSetParameter(dtDtl.Rows[i]["SURVEY_TIME"].ToString(), "int"); } else { drNew["ITEM"] = ""; drNew["PERIOD"] = ""; drNew["PUBLISH_DATE"] = DBNull.Value; drNew["SURVEY_TIME"] = DBNull.Value; } dt.Rows.Add(drNew); } dt.AcceptChanges(); this.gvDtl.DataSource = dt; this.gvDtl.DataBind(); } catch (Exception ex) { this.ErrorMsgLabel.Text = ex.ToString(); } finally { } #endregion }//databind_Old