//dataget 查詢資料庫取得資料 private void dataget_Mst() { #region try { //抓取本頁初次登記的時間 string SessionIDName = "ALO02A_" + PageTimeStamp.Value; ALOModel.MaintainDisRank BCO = new ALOModel.MaintainDisRank(ConntionDB); DataTable Dt = null; //ParameterList.Clear(); //ParameterList.Add("1"); //ParameterList.Add(TextBoxParam.Text.Trim()); Dt = BCO.QuerySwitch(ALOModel.MaintainDisRank.QueryType.ALL, null); Session[SessionIDName] = Dt; GridView1.DataSource = Dt; GridView1.DataBind(); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }
//Tab2 新增存檔 protected void btnTab2SaveInsert_Click(object sender, EventArgs e) { #region try { ErrorMsgLabel.Text = ""; ResultMsgLabel.Text = ""; if (txtTab2Code.Text.Trim() == "" || txtTab2Name.Text.Trim() == "") { ErrorMsgLabel.Text = "[RANK類別代號] 及 [RANK類別名稱] 不得為空白"; return; } else if (GetStringLen(txtTab2Name.Text.Trim()) > 20) { ErrorMsgLabel.Text = "RANK類別名稱限制20個字元"; return; } else if (GetStringLen(txtTab2Memo.Text.Trim()) > 40) { ErrorMsgLabel.Text = "備註限制40個字元"; return; } //2010/02/22 modified string SessionIDName = "ALO02A2_" + PageTimeStamp.Value; DataTable dtTemp = (DataTable)Session[SessionIDName]; int tmpRateCount = 0; if (dtTemp != null && dtTemp.Rows.Count != 0) { for (int i = 0; i <= dtTemp.Rows.Count - 1; i++) { tmpRateCount += Convert.ToInt32(((dtTemp.Rows[i]["RANK_RATE"].ToString().Trim()))); } if (tmpRateCount != 100) { ErrorMsgLabel.Text = "[佔有率%] 的總合須為100"; return; } } //---檢查DB中是否已有重複資料 string v_CODE = txtTab2Code.Text.Trim(); string exist = ""; ALOModel.MaintainDisRank BCO = new ALOModel.MaintainDisRank(ConntionDB); DataTable Dt2 = new DataTable(); ArrayList ParameterList = new ArrayList(); ParameterList.Clear(); //ParameterList.Add("1"); //ParameterList.Add(TextBoxParam.Text.Trim()); Dt2 = BCO.QuerySwitch(ALOModel.MaintainDisRank.QueryType.ALL, null); if (Dt2 != null) { for (int i = 0; i <= Dt2.Rows.Count - 1; i++) { if (Dt2.Rows[i]["CODE"].ToString() == v_CODE) { if (Dt2.Rows[i]["ENABLE"].ToString() == "1") { ErrorMsgLabel.Text = "此RANK類別代號已存在"; return; } else if (Dt2.Rows[i]["ENABLE"].ToString() == "0") { exist = "Y"; //表示資料存於DB中但ENABLE = 0 } } } } if (exist == "Y") { if (DetailOLDData.InnerHtml != "") { Update_Mst("1"); Update_Dtl(); } } else { Insert_Mst(); Update_Dtl(); } dataget_Mst(); hidtxtTab2Memo.Text = txtTab2Memo.Text.Trim(); txtTab2Code.ReadOnly = true; txtTab2Name.ReadOnly = true; txtTab2Memo.ReadOnly = true; btnTab2SaveInsert.Visible = false; btnTab2Del.Visible = true; btnTab2Edit.Visible = true; btnTab3NewInsert.Visible = false; btnTab3New.Visible = true; txtTab3Lv.Text = ""; txtTab3Rate.Text = ""; Panel2.Visible = false; GridView2.Columns[2].Visible = false; GridView2.Columns[3].Visible = false; ResultMsgLabel.Text = "新增完成"; CurrentPageMode = PageCurrentMode.Query; DetailOLDData.InnerHtml = ""; DetailOLDData_Source.InnerHtml = ""; } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } #endregion }