/// <summary> /// 儲存鈕 /// </summary> protected void btnSave_Click(object sender, EventArgs e) { string SessionIDName = "CGD041_" + PageTimeStamp.Value; DataTable Dt = null; DataTable DT_Add = null; DataTable DT_Mod = null; DataTable DT_Del = null; if (Session[SessionIDName] != null) { Dt = (DataTable)Session[SessionIDName]; DT_Add = Dt.GetChanges(DataRowState.Added); DT_Mod = Dt.GetChanges(DataRowState.Modified); DT_Del = Dt.GetChanges(DataRowState.Deleted); } else { ErrorMsgLabel.Text = "目前無資料異動"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' 目前無資料異動 ');", true); return; } if (DT_Add == null && DT_Mod == null && DT_Del == null) { ErrorMsgLabel.Text = "目前無資料異動"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' 目前無資料異動 ');", true); return; } CGDModel.CGDCommon BCOCommon = new CGDModel.CGDCommon(); System.Data.Common.DbTransaction DBT = BCOCommon.OpenAndGetConnection(ConnectionDB).BeginTransaction(); CGDModel.MaintainCheckQualityStore BCO = new CGDModel.MaintainCheckQualityStore(ConntionDB); try { //新增---------------------------------------------------------------------------------------------------------- if (DT_Add != null) { foreach (DataRow dRow in DT_Add.Rows) { ParameterList.Clear(); ParameterList.Add(dRow["CREATEDATE"]); ParameterList.Add(dRow["CREATEUID"]); ParameterList.Add(dRow["UPDATEDATE"]); ParameterList.Add(dRow["UPDATEUID"]); ParameterList.Add(dRow["ENABLE"]); ParameterList.Add(dRow["PICK_BATCH"]); ParameterList.Add(dRow["CHAN_NO"]); ParameterList.Add(dRow["STORE"]); ParameterList.Add(dRow["START_DATE"]); ParameterList.Add(dRow["END_DATE"]); BCO.CreatePICK_CK_STORE(ParameterList, DBT); } } //修改---------------------------------------------------------------------------------------------------------- if (DT_Mod != null) { foreach (DataRow dRow in DT_Mod.Rows) { ParameterList.Clear(); ParameterList.Add(dRow["UPDATEUID", DataRowVersion.Current].ToString()); ParameterList.Add(dRow["PICK_BATCH", DataRowVersion.Current].ToString()); ParameterList.Add(dRow["CHAN_NO", DataRowVersion.Current].ToString()); ParameterList.Add(dRow["STORE", DataRowVersion.Current].ToString()); ParameterList.Add(Convert.ToDateTime(dRow["START_DATE", DataRowVersion.Current].ToString())); ParameterList.Add(Convert.ToDateTime(dRow["END_DATE", DataRowVersion.Current].ToString())); ParameterList.Add(Convert.ToDateTime(dRow["CREATEDATE", DataRowVersion.Original].ToString())); ParameterList.Add(dRow["CREATEUID", DataRowVersion.Original].ToString()); ParameterList.Add(Convert.ToDateTime(dRow["UPDATEDATE", DataRowVersion.Original].ToString())); ParameterList.Add(dRow["UPDATEUID", DataRowVersion.Original].ToString()); ParameterList.Add(dRow["ENABLE", DataRowVersion.Original].ToString()); ParameterList.Add(dRow["PICK_BATCH", DataRowVersion.Original].ToString()); ParameterList.Add(dRow["CHAN_NO", DataRowVersion.Original].ToString()); ParameterList.Add(dRow["STORE", DataRowVersion.Original].ToString()); ParameterList.Add(Convert.ToDateTime(dRow["START_DATE", DataRowVersion.Original].ToString())); ParameterList.Add(Convert.ToDateTime(dRow["END_DATE", DataRowVersion.Original].ToString())); string MSG = BCO.UpdatePICK_CK_STORE(ParameterList, DBT); if (MSG == "NODATA") { throw new Exception("DB_NODATA"); } } } DBT.Commit();//交易成功 btnQuery_Click(null, null); ErrorMsgLabel.Text = "儲存完畢"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' 儲存完畢 ');", true); } catch (Exception ex) { DBT.Rollback();//交易失敗 if (ex.Message.IndexOf("新增之資料已重複") > 0) { ErrorMsgLabel.Text = "查無資料"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD281.aspx", "alert(' 新增之資料已重複 ');", true); return; } if (ex.Message.IndexOf("NODATA") > 0) { ErrorMsgLabel.Text = "原資料已異動過,請重新查詢資料後再作處理"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD281.aspx", "alert(' 原資料已異動過,請重新查詢資料後再作處理 ');", true); return; } ErrorMsgLabel.Text = ex.Message; } txtChanNo.Text = ""; txtChanNo_Add.Text = ""; txtStore.Text = ""; txtStore_Add.Text = ""; SLP_StartDate_Add.Text = ""; SLP_EndDate_Add.Text = ""; Panel1.Visible = false; }
/// <summary> /// 插入鈕 /// </summary> protected void btnInsert_Click(object sender, EventArgs e) { #region 檢查輸入值 if (txtChanNo_Add.Text.Trim() == "") { ErrorMsgLabel.Text = "[通路]不得為空白"; return; } if (txtStore_Add.Text.Trim() == "") { ErrorMsgLabel.Text = "[店號]不得為空白"; return; } if (SLP_StartDate_Add.Text.Trim() == "") { ErrorMsgLabel.Text = "[適用開始日]不得為空白"; return; } if (SLP_EndDate_Add.Text.Trim() == "") { ErrorMsgLabel.Text = "[適用結束日]不得為空白"; return; } if ((SLP_StartDate_Add.Text != "") && (SLP_EndDate_Add.Text != "")) { if (Convert.ToDateTime(SLP_StartDate_Add.Text).CompareTo(Convert.ToDateTime(SLP_EndDate_Add.Text)) > 0) { ErrorMsgLabel.Text = "[適用開始日]不可大於[適用結束日]"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' [適用開始日]不可大於[適用結束日] ');", true); return; } } if (userState == "ADD") { //檢查日期生效區間 string checkResult = CheckEffDate(); if (checkResult == "1") { ErrorMsgLabel.Text = "日期生效區間重複"; return; } } #endregion string SessionIDName = "CGD041_" + PageTimeStamp.Value; hidtxtPickBatch.Text = txtPickBatch.Text; DataTable Dt = null; DataSet Ds = new DataSet(); DataView DV1 = null; try { if (Session[SessionIDName] != null) { Dt = (DataTable)Session[SessionIDName]; } else { CGDModel.MaintainCheckQualityStore BCO = new CGDModel.MaintainCheckQualityStore(ConntionDB); ParameterList.Clear(); Dt = BCO.QuerySwitch(CGDModel.MaintainCheckQualityStore.QueryType.Empty, ParameterList); } #region 檢查資料的[適用開始日]是否大於舊資料的[[適用結束日] , 以及編輯時檢查[適用結束日]是否小於等於系統日 , 因為需要用到 Dt 所以放在這 if (userState == "EDIT") { for (int i = Dt.Rows.Count - 1; i >= 0; i--) { if (Dt.Rows[i].RowState != DataRowState.Deleted) { if ((Convert.ToDateTime(SLP_StartDate_Add.Text).ToShortDateString() != hidSLP_StartDate_Add.Text) && (Convert.ToDateTime(DateTime.Now.ToShortDateString()).CompareTo(Convert.ToDateTime(SLP_StartDate_Add.Text)) > 0)) { ErrorMsgLabel.Text = "無法將[適用開始日]修改為小於系統日"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' 無法將[適用開始日]修改為小於系統日 ');", true); return; } if ((Convert.ToDateTime(SLP_EndDate_Add.Text).ToShortDateString() != hidSLP_EndDate_Add.Text) && (Convert.ToDateTime(DateTime.Now.ToShortDateString()).CompareTo(Convert.ToDateTime(SLP_EndDate_Add.Text)) > 0)) { ErrorMsgLabel.Text = "無法將[適用結束日]修改為小於系統日"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' 無法將[適用結束日]修改為小於系統日 ');", true); return; } if ((Dt.Rows[i]["CHAN_NO"].ToString() == txtChanNo_Add.Text) && (Dt.Rows[i]["STORE"].ToString() == txtStore_Add.Text) && (Convert.ToDateTime(Dt.Rows[i]["START_DATE"].ToString()).ToShortDateString() == Convert.ToDateTime(hidSLP_StartDate_Add.Text).ToShortDateString()) && (Convert.ToDateTime(Dt.Rows[i]["END_DATE"].ToString()).ToShortDateString() == Convert.ToDateTime(hidSLP_EndDate_Add.Text).ToShortDateString())) { if ((Convert.ToDateTime(SLP_StartDate_Add.Text).ToShortDateString() != hidSLP_StartDate_Add.Text) && (Convert.ToDateTime(DateTime.Now.ToShortDateString()).CompareTo(Convert.ToDateTime(Dt.Rows[i]["START_DATE"].ToString())) >= 0)) { ErrorMsgLabel.Text = "無法修改[適用開始日]小於等於系統日之資料"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' 無法修改[適用開始日]小於等於系統日之資料 ');", true); return; } if ((Convert.ToDateTime(SLP_EndDate_Add.Text).ToShortDateString() != hidSLP_EndDate_Add.Text) && (Convert.ToDateTime(DateTime.Now.ToShortDateString()).CompareTo(Convert.ToDateTime(Dt.Rows[i]["END_DATE"].ToString())) >= 0)) { ErrorMsgLabel.Text = "無法修改[適用結束日]小於等於系統日之資料"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' 無法修改[適用結束日]小於等於系統日之資料 ');", true); return; } } #region 目前沒用到 //if ((Convert.ToDateTime(SLP_StartDate_Add.Text).ToShortDateString() != hidSLP_StartDate_Add.Text) && (Convert.ToDateTime(Dt.Rows[i]["START_DATE"].ToString()).ToShortDateString() == Convert.ToDateTime(SLP_StartDate_Add.Text).ToShortDateString())) //{ // ErrorMsgLabel.Text = "查無資料";//ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' [適用開始日]已重複 ');", true); // return; //} //if ((Convert.ToDateTime(SLP_EndDate_Add.Text).ToShortDateString() != hidSLP_EndDate_Add.Text) && (Convert.ToDateTime(Dt.Rows[i]["END_DATE"].ToString()).ToShortDateString() == Convert.ToDateTime(SLP_EndDate_Add.Text).ToShortDateString())) //{ // ErrorMsgLabel.Text = "查無資料";//ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' [適用結束日]已重複 ');", true); // return; //} //if (!((Dt.Rows[i]["CHAN_NO"].ToString() == txtChanNo_Add.Text) && (Dt.Rows[i]["STORE"].ToString() == txtStore_Add.Text) && (Convert.ToDateTime(Dt.Rows[i]["START_DATE"].ToString()).ToShortDateString() == Convert.ToDateTime(hidSLP_StartDate_Add.Text).ToShortDateString()) && (Convert.ToDateTime(Dt.Rows[i]["END_DATE"].ToString()).ToShortDateString() == Convert.ToDateTime(hidSLP_EndDate_Add.Text).ToShortDateString())) && ((Dt.Rows[i]["CHAN_NO"].ToString() == txtChanNo_Add.Text) && (Dt.Rows[i]["STORE"].ToString() == txtStore_Add.Text))) //{ // if ((Convert.ToDateTime(SLP_StartDate_Add.Text).ToShortDateString() != hidSLP_StartDate_Add.Text) && ((Convert.ToDateTime(SLP_StartDate_Add.Text) >= Convert.ToDateTime(Dt.Rows[i]["START_DATE"].ToString())) && (Convert.ToDateTime(SLP_StartDate_Add.Text) <= Convert.ToDateTime(Dt.Rows[i]["END_DATE"].ToString())))) // { // ErrorMsgLabel.Text = "查無資料";//ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' 錯誤的日期區間 ');", true); // return; // } // if ((Convert.ToDateTime(SLP_EndDate_Add.Text).ToShortDateString() != hidSLP_EndDate_Add.Text) && ((Convert.ToDateTime(SLP_EndDate_Add.Text) >= Convert.ToDateTime(Dt.Rows[i]["START_DATE"].ToString())) && (Convert.ToDateTime(SLP_EndDate_Add.Text) <= Convert.ToDateTime(Dt.Rows[i]["END_DATE"].ToString())))) // { // ErrorMsgLabel.Text = "查無資料";//ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' 錯誤的日期區間 ');", true); // return; // } //} #endregion } } } if (userState == "ADD") { for (int i = Dt.Rows.Count - 1; i >= 0; i--) { if (Dt.Rows[i].RowState != DataRowState.Deleted) { if ((Dt.Rows[i]["CHAN_NO"].ToString() == txtChanNo_Add.Text) && (Dt.Rows[i]["STORE"].ToString() == txtStore_Add.Text)) { if (Convert.ToDateTime(Dt.Rows[i]["END_DATE"].ToString()).CompareTo(Convert.ToDateTime(SLP_StartDate_Add.Text.Trim())) >= 0) { ErrorMsgLabel.Text = "[適用開始日]不能小於等於最新一筆履歷資料之[適用結束日]"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' [適用開始日]不能小於等於最新一筆履歷資料之[適用結束日] ');", true); return; } } } } } DataView DVCheck = null; string strWhere2 = ""; if (Dt != null) { DataTable Dt2 = Dt.Copy(); DVCheck = Dt2.DefaultView; strWhere2 = ""; TextBox _ChanNo = (TextBox)this.txtChanNo_Add.FindControl("TextBoxCode"); string tmpChanNo = Request[_ChanNo.UniqueID].ToString(); strWhere2 += "CHAN_NO = '" + tmpChanNo + "' "; TextBox _Store = (TextBox)this.txtStore_Add.FindControl("TextBoxCode"); string tmpStore = Request[_Store.UniqueID].ToString(); strWhere2 += " and STORE = '" + tmpStore + "' "; strWhere2 += " and START_DATE <= CONVERT('" + this.SLP_EndDate_Add.Text.Trim() + "','System.DateTime')"; strWhere2 += " and END_DATE >= CONVERT('" + this.SLP_StartDate_Add.Text.Trim() + "','System.DateTime')"; } DVCheck.RowFilter = strWhere2; DataTable temp = DVCheck.ToTable(); if (temp.Rows.Count != 0) { if (Convert.ToDateTime(temp.Rows[temp.Rows.Count-1]["END_DATE"].ToString()) <= System.DateTime.Now) { ErrorMsgLabel.Text = "日期生效區間重複"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' 日期生效區間重複 ');", true); return; } } #endregion //將資料寫入暫存檔 if (userState == "EDIT") { for (int i = Dt.Rows.Count - 1; i >= 0; i--) { if (Dt.Rows[i].RowState != DataRowState.Deleted) { if ((Dt.Rows[i]["CHAN_NO"].ToString() == hidtxtChanNo_Add.Text) && (Dt.Rows[i]["STORE"].ToString() == hidtxtStore_Add.Text) && (Convert.ToDateTime(Dt.Rows[i]["START_DATE"].ToString()).ToShortDateString() == Convert.ToDateTime(hidSLP_StartDate_Add.Text).ToShortDateString()) && (Convert.ToDateTime(Dt.Rows[i]["END_DATE"].ToString()).ToShortDateString() == Convert.ToDateTime(hidSLP_EndDate_Add.Text).ToShortDateString()) ) { Dt.Rows[i]["CHAN_NO"] = txtChanNo_Add.Text.ToUpper(); Dt.Rows[i]["STORE"] = txtStore_Add.Text; Dt.Rows[i]["START_DATE"] = SLP_StartDate_Add.Text; Dt.Rows[i]["END_DATE"] = SLP_EndDate_Add.Text; Dt.Rows[i]["UPDATEDATE"] = DateTime.Now; Dt.Rows[i]["UPDATEUID"] = Session["UID"].ToString(); } } } } else { TextBox _ChanNo = (TextBox)this.txtChanNo_Add.FindControl("TextBoxName"); string ChanNoName = Request[_ChanNo.UniqueID].ToString(); TextBox _Store = (TextBox)this.txtStore_Add.FindControl("TextBoxName"); string StoreName = Request[_Store.UniqueID].ToString(); if (ChanNoName == "查無資料") { ErrorMsgLabel.Text = "[通路]輸入錯誤"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' [通路]輸入錯誤 ');", true); return; } #region 取temp ID tempID = 0; DataView tempDT = new DataView(); tempDT.Table = Dt.Copy(); tempDT.Sort = "ID ASC"; if (Dt.Rows.Count != 0) { tempID = Convert.ToInt32(tempDT[tempDT.Count - 1]["ID"].ToString()); } #endregion #region 取序號 DV1 = null; int rowNum = 1; if (Dt != null) { //DV1 = Dt.DefaultView; //DV1.RowFilter = "rownum <= " + TextBoxRowCountLimit.Text.Trim(); //DataTable tmpDT = DV1.ToTable(); //rowNum = tmpDT.Rows.Count; rowNum = Dt.Rows.Count; } #endregion DataRow dRow = Dt.NewRow(); //ID和CODE暫自訂, 真正寫入CO時會重取 int v_ID = tempID + 1; int v_CODE = tempID + 1; dRow["ID"] = v_ID; dRow["CODE"] = v_CODE; dRow["ROWNUM"] = rowNum + 1; dRow["CREATEDATE"] = DateTime.Now; dRow["UPDATEDATE"] = DateTime.Now; dRow["CREATEUID"] = Session["UID"].ToString(); dRow["UPDATEUID"] = Session["UID"].ToString(); dRow["ENABLE"] = "1"; dRow["PICK_BATCH"] = hidtxtPickBatch.Text; dRow["CHAN_NO"] = txtChanNo_Add.Text; dRow["NAME"] = ChanNoName; dRow["STORE"] = txtStore_Add.Text; dRow["STORE_NAME"] = StoreName; dRow["START_DATE"] = SLP_StartDate_Add.Text; dRow["END_DATE"] = SLP_EndDate_Add.Text; Dt.Rows.Add(dRow); } Session[SessionIDName] = Dt; DV1 = null; string strWhere = ""; if (Dt != null) { DV1 = Dt.DefaultView; strWhere = ""; TextBox _ChanNo = (TextBox)this.txtChanNo.FindControl("TextBoxCode"); string tmpChanNo = Request[_ChanNo.UniqueID].ToString(); if (tmpChanNo != "") { strWhere += "CHAN_NO = '" + tmpChanNo + "' "; } TextBox _Store = (TextBox)this.txtStore.FindControl("TextBoxCode"); string tmpStore = Request[_Store.UniqueID].ToString(); if (tmpStore != "") { if (strWhere == "") { strWhere += "STORE = '" + tmpStore + "' "; } else { strWhere += " and STORE = '" + tmpStore + "' "; } } if (this.SLP_StartDate.Text.Trim() != "") { if (strWhere == "") { strWhere += "START_DATE = CONVERT('" + this.SLP_StartDate.Text.Trim() + "','System.DateTime')"; } else { strWhere += " and START_DATE = CONVERT('" + this.SLP_StartDate.Text.Trim() + "','System.DateTime')"; } } if (this.SLP_EndDate.Text.Trim() != "") { if (strWhere == "") { strWhere += "END_DATE = CONVERT('" + this.SLP_EndDate.Text.Trim() + "','System.DateTime')"; } else { strWhere += " and END_DATE = CONVERT('" + this.SLP_EndDate.Text.Trim() + "','System.DateTime')"; } } if (strWhere == "") { strWhere += "rownum <= " + TextBoxRowCountLimit.Text.Trim(); } else { strWhere += " and rownum <= " + TextBoxRowCountLimit.Text.Trim(); } } if (userState == "EDIT") Panel1.Visible = false; txtChanNo.Text = ""; txtChanNo_Add.Text = ""; txtStore.Text = ""; txtStore_Add.Text = ""; SLP_StartDate_Add.Text = ""; SLP_EndDate_Add.Text = ""; DV1.RowFilter = strWhere; GridView1.DataSource = DV1; //設定分頁大小 GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); GridView1.PageIndex = 0; GridView1.DataBind(); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { } userState = ""; }
/// <summary> /// 把值傳到Client端 /// </summary> /// <returns></returns> public string GetCallbackResult() { //判斷值是否有重覆 string rtn = "", strResult = ""; CGDModel.MaintainCheckQualityStore BCO = new CGDModel.MaintainCheckQualityStore(ConntionDB); DataTable dt = null; DataTable dt2 = null; ParameterList.Clear(); if (ObjectFrom == "ChanNo") { ParameterList.Add(CallServerValue); dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.ChanNoName , ParameterList); } else if (ObjectFrom == "Store") { //----找StoreName ParameterList.Add(CallServerValue); dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.StoreName , ParameterList); ParameterList.Clear(); //----找StoreDate ParameterList.Add(ChanNoAdd); ParameterList.Add(CallServerValue); dt2 = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.StoreDate, ParameterList); } if (dt != null) { if (dt.Rows.Count > 0) { if (ObjectFrom == "ChanNo") { rtn = string.Format("{0}", dt.Rows[0][0].ToString()); } else if (ObjectFrom == "Store") { rtn = string.Format("{0}", dt.Rows[0][0].ToString()); } } } if (dt2 != null) { if (dt2.Rows.Count > 0) { if (ObjectFrom == "Store") { rtn = string.Format("{0},{1},{2}", dt.Rows[0][0].ToString(), dt2.Rows[0][0].ToString(), dt2.Rows[0][1].ToString()); } } } //附加相關控制項 if (ObjectFrom == "ChanNo") { //strResult = string.Format("{0},{1}", txtChanNoName_Add.UniqueID, rtn); } else if (ObjectFrom == "Store") { //strResult = string.Format("{0},{1},{2},{3}", txtStoreName_Add.UniqueID, rtn, "ctl00_CPH_SLP_StartDate_Add_TextBoxCode", "ctl00_CPH_SLP_EndDate_Add_TextBoxCode"); //strResult = string.Format("{0},{1}", txtStoreName_Add.UniqueID, rtn); } return strResult; }
/// <summary> /// 列印鈕 /// </summary> protected void btnPrintReport_Click(object sender, EventArgs e) { if (VerifyFormData() == true) { try { ErrorMsgLabel.Text = ""; this.hid_PageStatus.Value = "PRINT"; //抓取本頁初次登記的時間 string SessionIDName = "CGD041_" + PageTimeStamp.Value; CGDModel.MaintainCheckQualityStore BCO = new CGDModel.MaintainCheckQualityStore(ConntionDB); DataTable Dt; ParameterList.Clear(); //組sql where字串 string strWhere = ""; if (this.txtPickBatch.Text.Trim() != "") { strWhere += " and MA.PICK_BATCH = '" + this.txtPickBatch.Text.Trim() + "' "; } if (this.txtChanNo.Text.Trim() != "") { strWhere += " and MA.CHAN_NO = '" + this.txtChanNo.Text.Trim() + "' "; } if (this.txtStore.Text.Trim() != "") { strWhere += " and MA.STORE = '" + this.txtStore.Text.Trim() + "' "; } if (this.SLP_StartDate.Text.Trim() != "") { strWhere += " and MA.START_DATE = to_date('" + this.SLP_StartDate.Text.Trim() + "','yyyy/mm/dd')"; } if (this.SLP_EndDate.Text.Trim() != "") { strWhere += " and MA.END_DATE = to_date('" + this.SLP_EndDate.Text.Trim() + "','yyyy/mm/dd')"; } if (strWhere == "") { Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.ALL, ParameterList); } else { ParameterList.Add(strWhere); Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryStoreData, ParameterList); } if (Dt.Rows.Count == 0) { this.hid_PageStatus.Value = "QUERY"; ErrorMsgLabel.Text = "查無資料"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' 查無資料 ');", true); CrystalReportViewer1.Visible = false; return; } else { #region 顯示報表 string s_FileName = ""; //設定輸出檔名 string s_rptFilePath = ""; //設定報表路徑 s_rptFilePath = Server.MapPath("./REPORT/CGD041.rpt"); s_FileName = HttpUtility.UrlEncode("指定品檢門市.PDF", System.Text.Encoding.UTF8); LoadCrystalReport(s_FileName, s_rptFilePath, Dt, "PDF"); #endregion } //預覽報表 //ShowReport(Dt); } catch (Exception ex) { ErrorMsgLabel.Text = ex.Message; } finally { } } }
/// <summary> /// 檢查路線履歷是否已重複 /// </summary> private string CheckEffDate() { CGDModel.MaintainCheckQualityStore BCO = new CGDModel.MaintainCheckQualityStore(ConntionDB); ParameterList.Clear(); ParameterList.Add(hidtxtPickBatch.Text.Trim()); ParameterList.Add(txtChanNo_Add.Text.Trim()); ParameterList.Add(txtStore_Add.Text.Trim()); ParameterList.Add(SLP_StartDate_Add.Text.Trim()); ParameterList.Add(SLP_EndDate_Add.Text.Trim()); return BCO.CheckEffDate(ParameterList); }
/// <summary> /// databind 繫結查詢資料到GridView1 /// </summary> private void databind() { //抓取本頁初次登記的時間 string SessionIDName = "CGD041_" + PageTimeStamp.Value; CGDModel.MaintainCheckQualityStore BCO = new CGDModel.MaintainCheckQualityStore(ConntionDB); DataTable Dt; string strWhere = ""; if (Session[SessionIDName] != null) { Dt = (DataTable)Session[SessionIDName]; } else { ParameterList.Clear(); strWhere += " and MA.PICK_BATCH = '" + this.txtPickBatch.Text.Trim() + "' "; strWhere += " order by MA.CHAN_NO "; ParameterList.Add(strWhere); Dt = BCO.QuerySwitch(CGDModel.CGDCommon.QueryType.QueryStoreData, ParameterList); } if (Dt.Rows.Count == 0) { if (showNoDataMessage == "Y") ErrorMsgLabel.Text = "查無資料"; //ScriptManager.RegisterStartupScript(Page, this.GetType(), "CGD041.aspx", "alert(' 查無資料 ');", true); } Session[SessionIDName] = Dt; DataView DV1 = Dt.DefaultView; strWhere = ""; TextBox _ChanNo = (TextBox)this.txtChanNo.FindControl("TextBoxCode"); string tmpChanNo = Request[_ChanNo.UniqueID].ToString(); if (tmpChanNo != "") { strWhere += "CHAN_NO = '" + tmpChanNo + "' "; } TextBox _Store = (TextBox)this.txtStore.FindControl("TextBoxCode"); string tmpStore = Request[_Store.UniqueID].ToString(); if (tmpStore != "") { if (strWhere == "") { strWhere += "STORE = '" + tmpStore + "' "; } else { strWhere += " and STORE = '" + tmpStore + "' "; } } if (this.SLP_StartDate.Text.Trim() != "") { if (strWhere == "") { strWhere += "START_DATE = CONVERT('" + this.SLP_StartDate.Text.Trim() + "','System.DateTime')" ; } else { strWhere += " and START_DATE = CONVERT('" + this.SLP_StartDate.Text.Trim() + "','System.DateTime')"; } } if (this.SLP_EndDate.Text.Trim() != "") { if (strWhere == "") { strWhere += "END_DATE = CONVERT('" + this.SLP_EndDate.Text.Trim() + "','System.DateTime')"; } else { strWhere += " and END_DATE = CONVERT('" + this.SLP_EndDate.Text.Trim() + "','System.DateTime')"; } } if (strWhere == "") { strWhere += "rownum <= " + TextBoxRowCountLimit.Text.Trim(); } else { strWhere += " and rownum <= " + TextBoxRowCountLimit.Text.Trim() ; } DV1.RowFilter = strWhere; GridView1.DataSource = DV1; //設定分頁大小 GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); GridView1.PageIndex = 0; GridView1.DataBind(); }