/// <summary> /// 繫結資料到畫面控制項 /// </summary> private bool databind(string strID) { bool bResult = false; //false:無資料 true:有資料 CGDModel.CGD32_BCO BCO = new CGDModel.CGD32_BCO(ConnectionDB); ParameterList.Clear(); ParameterList.Add(strID); for (int i = 1; i <= 40; i++) ParameterList.Add(DBNull.Value); DataTable dtData = BCO.DoQueryMain(ParameterList); if (dtData.Rows.Count == 0) { hiddenID.Value = strID; txtVENDOR.Text = ""; hdfVENDOR.Value = ""; txtVENDOR_NAME.Text = ""; txtBOSS.Text = ""; SLP_VENDOR_OPEN_DATE.Text = ""; SLP_VENDOR_CLOSE_DATE.Text = ""; SLP_VENDOR_SERVICE_TEL.Text = ""; SLP_VENDOR_SERVICE_TEL.Text = ""; txtMAIL_ADDR.Text = ""; SLP_PARA1.Text = ""; SLP_PARA2.Text = ""; ddlSUBSIDY_FLAG.SelectedIndex = 0; ddlFINE_FLAG.SelectedIndex = 0; SLP_INV_TEL.Text = ""; SLP_INV_FAX.Text = ""; txtINV_PDZ_NO.Text = ""; txtINV_ADDR.Text = ""; SLP_BUSINESS_TEL.Text = ""; SLP_BUSINESS_FAX.Text = ""; txtBUSINESS_PDZ_NO.Text = ""; txtBUSINESS_ADDR.Text = ""; txtMNOTES.Text = ""; txtCreateDate.Text = ""; SLP_CREATEUID.Text = ""; txtUpdateDate.Text = ""; SLP_UPDATEUID.Text = ""; cblXYZ.Items[0].Selected = false; cblXYZ.Items[1].Selected = false; cblXYZ.Items[2].Selected = false; bindEMP("-1"); bResult = false; ErrorMsgLabel.Text = "此筆資料已被其他使用者刪除,請點選上一筆/下一筆鈕或回查詢頁重新查詢!"; } else { hiddenID.Value = strID; txtVENDOR.Text = dtData.Rows[0]["VENDOR"].ToString(); hdfVENDOR.Value = dtData.Rows[0]["VENDOR"].ToString(); txtVENDOR_NAME.Text = dtData.Rows[0]["VENDOR_NAME"].ToString(); txtBOSS.Text = dtData.Rows[0]["BOSS"].ToString(); SLP_VENDOR_OPEN_DATE.Text = dtData.Rows[0]["VENDOR_OPEN_DATE"].ToString(); SLP_VENDOR_CLOSE_DATE.Text = dtData.Rows[0]["VENDOR_CLOSE_DATE"].ToString(); SLP_VENDOR_SERVICE_TEL.TextBox_Fax.Text = dtData.Rows[0]["VENDOR_SERVICE_TEL_AREA"].ToString(); SLP_VENDOR_SERVICE_TEL.TextBox_Tel.Text = dtData.Rows[0]["VENDOR_SERVICE_TEL"].ToString(); txtMAIL_ADDR.Text = dtData.Rows[0]["MAIL_ADDR"].ToString(); SLP_PARA1.Text = dtData.Rows[0]["STORE_FEE_PARAM1"].ToString(); SLP_PARA2.Text = dtData.Rows[0]["STORE_FEE_PARAM2"].ToString(); ddlSUBSIDY_FLAG.Text = dtData.Rows[0]["SUBSIDY_FLAG"].ToString(); ddlFINE_FLAG.Text = dtData.Rows[0]["FINE_FLAG"].ToString(); SLP_INV_TEL.TextBox_Fax.Text = dtData.Rows[0]["INV_TEL_AREA"].ToString(); SLP_INV_TEL.TextBox_Tel.Text = dtData.Rows[0]["INV_TEL"].ToString(); SLP_INV_FAX.TextBox_Fax.Text = dtData.Rows[0]["INV_FAX_AREA"].ToString(); SLP_INV_FAX.TextBox_Tel.Text = dtData.Rows[0]["INV_FAX"].ToString(); txtINV_PDZ_NO.Text = dtData.Rows[0]["INV_PDZ_NO"].ToString(); txtINV_ADDR.Text = dtData.Rows[0]["INV_ADDR"].ToString(); SLP_BUSINESS_TEL.TextBox_Fax.Text = dtData.Rows[0]["BUSINESS_TEL_AREA"].ToString(); SLP_BUSINESS_TEL.TextBox_Tel.Text = dtData.Rows[0]["BUSINESS_TEL"].ToString(); SLP_BUSINESS_FAX.TextBox_Fax.Text = dtData.Rows[0]["BUSINESS_FAX_AREA"].ToString(); SLP_BUSINESS_FAX.TextBox_Tel.Text = dtData.Rows[0]["BUSINESS_FAX"].ToString(); txtBUSINESS_PDZ_NO.Text = dtData.Rows[0]["BUSINESS_PDZ_NO"].ToString(); txtBUSINESS_ADDR.Text = dtData.Rows[0]["BUSINESS_ADDR"].ToString(); txtMNOTES.Text = dtData.Rows[0]["NOTES"].ToString(); txtCreateDate.Text = dtData.Rows[0]["CREATEDATE"].ToString(); SLP_CREATEUID.Text = dtData.Rows[0]["CREATEUID"].ToString(); txtUpdateDate.Text = dtData.Rows[0]["UPDATEDATE"].ToString(); SLP_UPDATEUID.Text = dtData.Rows[0]["UPDATEUID"].ToString(); cblXYZ.Items[0].Selected = StrToBool(dtData.Rows[0]["X_LINE"].ToString()); cblXYZ.Items[1].Selected = StrToBool(dtData.Rows[0]["Y_LINE"].ToString()); cblXYZ.Items[2].Selected = StrToBool(dtData.Rows[0]["Z_LINE"].ToString()); ParameterList.Clear(); ParameterList.Add(strID); DataTable dtKind = BCO.DoQueryKind_PID(ParameterList); for (int x = 0; x < dtKind.Rows.Count; x++) { if (dtKind.Rows[x]["OUTSOURCE_ID"].ToString() == "1") { cblKIND1.Items[0].Selected = true; } else { for (int i = 0; i < cblKIND2.Items.Count; i++) { if (cblKIND2.Items[i].Value == dtKind.Rows[x]["OUTSOURCE_ID"].ToString()) cblKIND2.Items[i].Selected = true; } } } bindEMP(strID); bResult = true; } Session["CGD322_DT" + PageTimeStamp.Value] = dtData; return bResult; }//databind
/// <summary> /// 查詢資料庫取得資料 /// </summary> private void databind() { //抓取本頁初次登記的時間 string SessionIDName = "CGD321_" + PageTimeStamp.Value; CGDModel.CGD32_BCO BCO = new CGDModel.CGD32_BCO(ConntionDB); string N_ID = string.Empty; string V_VENDOR = SLP_CGDVENDOR1.Text.Trim(); string V_VENDOR_NAME = txtVENDOR_NAME.Text.Trim(); string V_BOSS = txtBOSS.Text.Trim(); string D_VENDOR_OPEN_DATE_S = SLP_VENDOR_OPEN_DATE.StartDate; string D_VENDOR_OPEN_DATE_E = SLP_VENDOR_OPEN_DATE.EndDate; string D_VENDOR_CLOSE_DATE_S = SLP_VENDOR_CLOSE_DATE.StartDate; string D_VENDOR_CLOSE_DATE_E = SLP_VENDOR_CLOSE_DATE.EndDate; string V_VENDOR_SERVICE_TEL_AREA = SLP_VENDOR_SERVICE_TEL.TextBox_Fax.Text.Trim(); string V_VENDOR_SERVICE_TEL = SLP_VENDOR_SERVICE_TEL.TextBox_Tel.Text.Trim(); string V_MAIL_ADDR = txtMAIL_ADDR.Text.Trim(); string V_STORE_FEE_PARAM1_OP = ConvertSign(SLP_PARA1.Operator); string N_STORE_FEE_PARAM1 = SLP_PARA1.Text.Trim(); string V_STORE_FEE_PARAM2_OP = ConvertSign(SLP_PARA2.Operator); string N_STORE_FEE_PARAM2 = SLP_PARA2.Text.Trim(); string N_SUBSIDY_FLAG = ddlSUBSIDY_FLAG.SelectedValue; string N_FINE_FLAG = ddlFINE_FLAG.SelectedValue; string V_INV_TEL_AREA = SLP_INV_TEL.TextBox_Fax.Text.Trim(); string V_INV_TEL = SLP_INV_TEL.TextBox_Tel.Text.Trim(); string V_INV_FAX_AREA = SLP_INV_FAX.TextBox_Fax.Text.Trim(); string V_INV_FAX = SLP_INV_FAX.TextBox_Tel.Text.Trim(); string V_INV_PDZ_NO = txtINV_PDZ_NO.Text.Trim(); string V_INV_ADDR = txtINV_ADDR.Text.Trim(); string V_BUSINESS_TEL_AREA = SLP_BUSINESS_TEL.TextBox_Fax.Text.Trim(); string V_BUSINESS_TEL = SLP_BUSINESS_TEL.TextBox_Tel.Text.Trim(); string V_BUSINESS_FAX_AREA = SLP_BUSINESS_FAX.TextBox_Fax.Text.Trim(); string V_BUSINESS_FAX = SLP_BUSINESS_FAX.TextBox_Tel.Text.Trim(); string V_BUSINESS_PDZ_NO = txtBUSINESS_PDZ_NO.Text.Trim(); string V_BUSINESS_ADDR = txtBUSINESS_ADDR.Text.Trim(); string V_MNOTES = txtMNOTES.Text.Trim(); string D_CREATEDATE_S = SLP_CREATEDATE.StartDate; string D_CREATEDATE_E = SLP_CREATEDATE.EndDate; string V_CREATEUID = SLP_CREATEUID.Text; string D_UPDATEDATE_S = SLP_UPDATEDATE.StartDate; string D_UPDATEDATE_E = SLP_UPDATEDATE.EndDate; string V_UPDATEUID = SLP_UPDATEUID.Text; string V_EMP_ID = txtEMP_ID.Text.Trim(); string V_EMP_NAME = txtEMP_NAME.Text.Trim(); string V_PNOTES = txtDNOTES.Text.Trim(); string V_KIND = string.Empty; string N_ROWNUM = TextBoxRowCountLimit.Text.Trim(); for (int i = 0; i < cblKIND.Items.Count; i++) { if (cblKIND.Items[i].Selected == true) { if (V_KIND != "") V_KIND += ","; V_KIND += cblKIND.Items[i].Value; } } ParaSQL PSQL = ParaSQL.Equal; if (CheckBoxLikeSearch.Checked == true) PSQL = ParaSQL.Like; ParameterList.Clear(); ParameterList.Add(DBPara(N_ID, ParaType.Varchar2, ParaSQL.Equal)); ParameterList.Add(DBPara(V_VENDOR, ParaType.Varchar2, ParaSQL.Equal)); ParameterList.Add(DBPara(V_VENDOR_NAME, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_BOSS, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(D_VENDOR_OPEN_DATE_S, ParaType.Varchar2, ParaSQL.Equal)); ParameterList.Add(DBPara(D_VENDOR_OPEN_DATE_E, ParaType.Varchar2, ParaSQL.Equal)); ParameterList.Add(DBPara(D_VENDOR_CLOSE_DATE_S, ParaType.Varchar2, ParaSQL.Equal)); ParameterList.Add(DBPara(D_VENDOR_CLOSE_DATE_E, ParaType.Varchar2, ParaSQL.Equal)); ParameterList.Add(DBPara(V_VENDOR_SERVICE_TEL_AREA, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_VENDOR_SERVICE_TEL, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_MAIL_ADDR, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_STORE_FEE_PARAM1_OP, ParaType.Varchar2, ParaSQL.Equal)); ParameterList.Add(DBPara(N_STORE_FEE_PARAM1, ParaType.Number, ParaSQL.Equal)); ParameterList.Add(DBPara(V_STORE_FEE_PARAM2_OP, ParaType.Varchar2, ParaSQL.Equal)); ParameterList.Add(DBPara(N_STORE_FEE_PARAM2, ParaType.Number, ParaSQL.Equal)); ParameterList.Add(DBPara(N_SUBSIDY_FLAG, ParaType.Number, ParaSQL.Equal)); ParameterList.Add(DBPara(N_FINE_FLAG, ParaType.Number, ParaSQL.Equal)); ParameterList.Add(DBPara(V_INV_TEL_AREA, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_INV_TEL, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_INV_FAX_AREA, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_INV_FAX, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_INV_PDZ_NO, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_INV_ADDR, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_BUSINESS_TEL_AREA, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_BUSINESS_TEL, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_BUSINESS_FAX_AREA, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_BUSINESS_FAX, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_BUSINESS_PDZ_NO, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_BUSINESS_ADDR, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_MNOTES, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(D_CREATEDATE_S, ParaType.Varchar2, ParaSQL.Equal)); ParameterList.Add(DBPara(D_CREATEDATE_E, ParaType.Varchar2, ParaSQL.Equal)); ParameterList.Add(DBPara(V_CREATEUID, ParaType.Varchar2, ParaSQL.Equal)); ParameterList.Add(DBPara(D_UPDATEDATE_S, ParaType.Varchar2, ParaSQL.Equal)); ParameterList.Add(DBPara(D_UPDATEDATE_E, ParaType.Varchar2, ParaSQL.Equal)); ParameterList.Add(DBPara(V_UPDATEUID, ParaType.Varchar2, ParaSQL.Equal)); ParameterList.Add(DBPara(V_EMP_ID, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_EMP_NAME, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_PNOTES, ParaType.Varchar2, PSQL)); ParameterList.Add(DBPara(V_KIND, ParaType.Varchar2, ParaSQL.Equal)); ParameterList.Add(DBPara(N_ROWNUM, ParaType.Number, ParaSQL.Equal)); DataTable Dt = BCO.DoQueryMain(ParameterList); Session[SessionIDName] = Dt; GridView1.DataSource = Dt; //設定分頁大小 if (TextBoxPagesize.Text == "0") { GridView1.PageSize = 1; } else { GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); } GridView1.PageIndex = 0; GridView1.DataBind(); #region 將Key值存到Session中 ArrayList arl_Key = new ArrayList(); foreach (DataRow drRow in Dt.Rows) { arl_Key.Add(drRow["ID"].ToString()); } Session["CGD32_SortKey" + this.PageTimeStamp.Value] = arl_Key; #endregion #region 檢查回傳資料 if (Dt.Rows.Count == 0) { this.ErrorMsgLabel.Text = "查無資料"; } #endregion }
private bool CheckPK(string strID, string strVENDOR) { CGDModel.CGD32_BCO BCO = new CGDModel.CGD32_BCO(ConnectionDB); ParameterList.Clear(); ParameterList.Add(DBNull.Value); ParameterList.Add(strVENDOR); for (int i = 1; i <= 39; i++) ParameterList.Add(DBNull.Value); DataTable dtData = BCO.DoQueryMain(ParameterList); bool bResult = false; //true:有重覆PK false:無重覆PK foreach (DataRow dr in dtData.Rows) { if (dr["ID"].ToString() != strID) { bResult = true; break; } } if (bResult == true) { ErrorMsgLabel.Text = "已有相同的委外商代號存在"; } return bResult; //無重覆PK }