/// <summary> /// 初始檢視&編輯模式 /// </summary> private void Page_Status_VIEW_EDIT_LOAD() { if (hid_Page_Status.Value == "VIEW" || hid_Page_Status.Value == "EDIT") { #region 清空所有欄位 this.slp_YearMonth.Text = string.Empty;//所屬年月 this.SLP_INVOICE_TYPE.Text = string.Empty;//發票性質 this.txt_INVOICE_TRACK.Text = string.Empty;//字軌 this.SLP_STAR_NO.Text = string.Empty;//起始號碼 this.SLP_END_NO.Text = string.Empty;//迄止號碼 this.txt_CURRENT_NO.Text = string.Empty;//目前使用號碼 this.slp_CLOSEUID.Text = string.Empty;//月結人員 this.slp_CLOSEDATE.Text = string.Empty;//月結日期 this.slp_CREATEUID.Text = string.Empty;//建立人員 this.slp_CREATEDATE.Text = string.Empty;//建立日期-起 this.slp_UPDATEUID.Text = string.Empty;//維護人員 this.slp_UPDATEDATE.Text = string.Empty;//維護日期-起 #endregion #region 取得檢視資料 string strCode = string.Empty; try { if (Request["V_Code"] == null) { throw new Exception("載入頁面失敗!"); } else { strCode = Request["V_Code"].ToString(); } } catch { } ParameterList.Clear(); ParameterList.Add(strCode); ParameterList.Add(Session["UID"].ToString()); ParameterList.Add(DateTime.Now); CAAModel.MaintainInvoiceTrack BCO = new CAAModel.MaintainInvoiceTrack(ConntionDB); dt = BCO.QueryInvTrackByFind(ParameterList); string s_RequestString = Request.QueryString["CAA152_Type"]; if (dt.Rows.Count != 1 && s_RequestString != "ToolBar") { throw new Exception("查無" + strCode + "的相關資料"); } else if (dt.Rows.Count != 1 && s_RequestString == "ToolBar") { throw new Exception("查無此筆資料或已被其他使用者刪除,請點選上一筆/下一筆鈕或回查詢頁重新查詢!"); } #endregion #region 將資料寫入頁面 this.SLP_STAR_NO.Text = dt.Rows[0]["STAR_NO"].ToString();//起始號碼 this.SLP_END_NO.Text = dt.Rows[0]["END_NO"].ToString();//迄止號碼 this.slp_YearMonth.Text = dt.Rows[0]["INVOICE_MONTH"].ToString();//所屬年月 this.SLP_INVOICE_TYPE.Text = dt.Rows[0]["INVOICE_TYPE"].ToString();//發票性質 this.txt_INVOICE_TRACK.Text = dt.Rows[0]["INVOICE_TRACK"].ToString();//字軌 this.txt_CURRENT_NO.Text = dt.Rows[0]["CURRENT_NO"].ToString();//目前使用號碼 this.slp_CLOSEUID.Text = dt.Rows[0]["CLOSEUID"].ToString();//月結人員 this.slp_CLOSEDATE.Text = dt.Rows[0]["CLOSEDATE"].ToString();//月結日期 this.slp_CREATEUID.Text = dt.Rows[0]["CREATEUID"].ToString();//建立人員 this.slp_CREATEDATE.Text = dt.Rows[0]["CREATEDATE"].ToString();//建立日期 this.slp_UPDATEUID.Text = dt.Rows[0]["UPDATEUID"].ToString();//維護人員 this.slp_UPDATEDATE.Text = dt.Rows[0]["UPDATEDATE"].ToString();//維護日期 #endregion #region 設定ReadOnly if (this.hid_Page_Status.Value == "VIEW") { #region 檢視模式 this.slp_YearMonth.ReadOnly = true;//所屬年月 this.SLP_INVOICE_TYPE.ReadOnly = true;//發票性質 this.txt_INVOICE_TRACK.ReadOnly = true;//字軌 this.txt_INVOICE_TRACK.CssClass = "readtxtbox"; this.SLP_STAR_NO.ReadOnly = true;//起始號碼 this.SLP_END_NO.ReadOnly = true;//迄止號碼 this.txt_CURRENT_NO.ReadOnly = true;//目前使用號碼 this.slp_CLOSEUID.ReadOnly = true;//月結人員 this.slp_CLOSEDATE.ReadOnly = true;//月結日期 this.slp_CREATEUID.ReadOnly = true;//建立人員 this.slp_CREATEDATE.ReadOnly = true;//建立日期 this.slp_UPDATEUID.ReadOnly = true;//維護人員 this.slp_UPDATEDATE.ReadOnly = true;//維護日期 #endregion } if (this.hid_Page_Status.Value == "EDIT") { #region 編輯模式 this.txt_CURRENT_NO.ReadOnly = true;//目前使用號碼 this.slp_CLOSEUID.ReadOnly = true;//月結人員 this.slp_CLOSEDATE.ReadOnly = true;//月結日期 this.slp_CREATEUID.ReadOnly = true;//建立人員 this.slp_CREATEDATE.ReadOnly = true;//建立日期 this.slp_UPDATEUID.ReadOnly = true;//維護人員 this.slp_UPDATEDATE.ReadOnly = true;//維護日期 #endregion } #endregion } }
/// <summary> /// BUTTON 存檔 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { try { #region 檢查條件 CAAModel.CAACommon CAAComm = new CAAModel.CAACommon(); ArrayList arl_Check_Condition = Check_Condition(); #region 如果檢查有誤,則Return if (arl_Check_Condition[1].ToString() != string.Empty) { #region 錯誤訊息 this.ErrorMsgLabel.Text = arl_Check_Condition[1].ToString(); #endregion #region Focus欄位 if (arl_Check_Condition[0].ToString() != string.Empty) { string s_ScriptManager_Script = CAAComm.ToMakeUp_SetFocus_Script(arl_Check_Condition[0].ToString(), true); ScriptManager.RegisterStartupScript(this.up_ErrorMsg, typeof(UpdatePanel), "CAA152", s_ScriptManager_Script, true); } #endregion return; } #endregion #endregion #region 新增 if (this.hid_Page_Status.Value == "INSERT") { CAAModel.MaintainInvoiceTrack BCO = new CAAModel.MaintainInvoiceTrack(ConntionDB); string strMsg = string.Empty; string strNowDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); string strCode = this.slp_YearMonth.Text.Trim() + this.txt_INVOICE_TRACK.Text.Trim().ToUpper() + this.SLP_STAR_NO.Text.Trim(); ParameterList.Clear(); ParameterList.Add(strCode);//V_CODE ParameterList.Add(this.slp_YearMonth.Text.Trim());//V_INVOICE_MONTH ParameterList.Add(this.SLP_INVOICE_TYPE.Text);//V_INVOICE_TYPE ParameterList.Add(this.txt_INVOICE_TRACK.Text.Trim().ToUpper()); //V_INVOICE_TRACK ParameterList.Add(this.SLP_STAR_NO.Text.Trim());//V_STAR_NO ParameterList.Add(this.SLP_END_NO.Text.Trim());//V_END_NO ParameterList.Add(this.txt_CURRENT_NO.Text.Trim());//V_CURRENT_NO ParameterList.Add(Session["UID"].ToString());//V_CREATEUID ParameterList.Add(strNowDate);//D_CREATEDATE ParameterList.Add(Session["UID"].ToString());//V_UPDATEUID ParameterList.Add(strNowDate);//D_UPDATEDATE ArrayList ary = BCO.CreateInvTrackRecord(ParameterList, null); if (ary[0].ToString() == "Y") { strMsg = "alert('" + ary[1].ToString() + "');location.replace('CAA152.aspx?V_Code=" + strCode + "&mode=VIEW&Code=CAA15');"; } else { strMsg = "alert('" + ary[1].ToString() + "');"; } ScriptManager.RegisterStartupScript(Page, this.GetType(), "TO_CAA152.aspx", strMsg, true); } #endregion #region 編輯 else if (this.hid_Page_Status.Value == "EDIT") { CAAModel.MaintainInvoiceTrack BCO = new CAAModel.MaintainInvoiceTrack(ConntionDB); string strMsg = string.Empty; string strNowDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); string strCode = this.slp_YearMonth.Text.Trim() + this.txt_INVOICE_TRACK.Text.Trim().ToUpper() + this.SLP_STAR_NO.Text.Trim(); ParameterList.Clear(); //舊資料 ParameterList.Add(dt.Rows[0]["CODE"].ToString());//V_OLD_CODE ParameterList.Add(dt.Rows[0]["INVOICE_MONTH"].ToString());//V_OLD_INVOICE_MONTH ParameterList.Add(dt.Rows[0]["INVOICE_TYPE"].ToString());//V_OLD_INVOICE_TYPE ParameterList.Add(dt.Rows[0]["INVOICE_TRACK"].ToString());//V_OLD_INVOICE_TRACK ParameterList.Add(dt.Rows[0]["STAR_NO"].ToString());//V_OLD_STAR_NO ParameterList.Add(dt.Rows[0]["CREATEUID"].ToString());//V_OLD_CREATEUID ParameterList.Add(dt.Rows[0]["CREATEDATE"].ToString());//D_OLD_CREATEDATE ParameterList.Add(dt.Rows[0]["UPDATEUID"].ToString());//V_OLD_UPDATEUID if (dt.Rows[0]["UPDATEDATE"].ToString() != "") { ParameterList.Add(DateTime.Parse(dt.Rows[0]["UPDATEDATE"].ToString())); }//D_OLD_UPDATEDATE else { ParameterList.Add(DBNull.Value); }//D_OLD_UPDATEDATE //新資料 ParameterList.Add(strCode);//V_NEW_CODE ParameterList.Add(this.slp_YearMonth.Text.Trim());//V_NEW_INVOICE_MONTH ParameterList.Add(this.SLP_INVOICE_TYPE.Text);//V_NEW_INVOICE_TYPE ParameterList.Add(this.txt_INVOICE_TRACK.Text.Trim().ToUpper()); //V_NEW_INVOICE_TRACK ParameterList.Add(this.SLP_STAR_NO.Text.Trim());//V_NEW_STAR_NO ParameterList.Add(this.SLP_END_NO.Text.Trim());//V_NEW_END_NO ParameterList.Add(Session["UID"].ToString());//V_NEW_UPDATEUID ParameterList.Add(strNowDate);//D_NEW_UPDATEDATE ArrayList aryUpd = BCO.UpdateInvTrackRecord(ParameterList, null); #region 組合跳轉頁面字串 string s_ADDLocation_Replace_String = string.Empty; try { int i_Count = int.Parse(Request.QueryString["CAA152_COUNT"]); string s_Request_Key = Request.QueryString["CAA152_PageTimeStamp"]; s_ADDLocation_Replace_String = "&CAA152_COUNT=" + i_Count.ToString() + "&CAA152_PageTimeStamp=" + s_Request_Key; } catch { s_ADDLocation_Replace_String = string.Empty; } #endregion if (aryUpd[0].ToString() == "Y") { strMsg = "alert('" + aryUpd[1].ToString() + "');location.replace('CAA152.aspx?V_Code=" + strCode + "&mode=VIEW&Code=CAA15" + s_ADDLocation_Replace_String + "');"; } else { if (aryUpd[2].ToString() != "0") { strMsg = "alert('" + aryUpd[1].ToString() + "');location.replace('CAA152.aspx?V_Code=" + dt.Rows[0]["CODE"].ToString() + "&mode=VIEW&Code=CAA15" + s_ADDLocation_Replace_String + "');"; } } ScriptManager.RegisterStartupScript(this.btnSave, this.GetType(), "TO_CAA152.aspx", strMsg, true); } #endregion } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message; } }
/// <summary> /// BUTTON 編輯 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEdit_Click(object sender, EventArgs e) { try { CAAModel.CAACommon CAAComm = new CAAModel.CAACommon(); ParameterList.Clear(); ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_YearMonth.Text, "string", false)); //V_INVOICE_MONTH ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_INVOICE_TRACK.Text, "string", false)); //V_INVOICE_TRACK ParameterList.Add(CAAComm.GetValueSetParameter(this.SLP_STAR_NO.Text, "string", false)); //V_STAR_NO CAAModel.MaintainInvoiceTrack BCO = new CAAModel.MaintainInvoiceTrack(ConntionDB); ArrayList ary = BCO.GetInvTrackStatus(ParameterList, null); if (ary[1].ToString() == "Y") { if (this.hid_Page_Status.Value == "VIEW") { #region 組合跳轉頁面字串 string s_ADDLocation_Replace_String = string.Empty; try { int i_Count = int.Parse(Request.QueryString["CAA152_COUNT"]); string s_Request_Key = Request.QueryString["CAA152_PageTimeStamp"]; s_ADDLocation_Replace_String = "&CAA152_COUNT=" + i_Count.ToString() + "&CAA152_PageTimeStamp=" + s_Request_Key; } catch { s_ADDLocation_Replace_String = string.Empty; } #endregion string strCode = dt.Rows[0]["CODE"].ToString(); System.Web.UI.ScriptManager.RegisterStartupScript(this.btnEdit, this.GetType(), "TO_CAA152.aspx", "location.replace('CAA152.aspx?V_Code=" + strCode + "&mode=EDIT&Code=CAA15" + s_ADDLocation_Replace_String + "');", true); } } else { string strMsg = "alert('" + ary[0].ToString() + "');"; ScriptManager.RegisterStartupScript(Page, this.GetType(), "TO_CAA152.aspx", strMsg, true); } } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message; } finally { } }
/// <summary> /// BUTTON 查詢 /// </summary> protected void btnQuery_Click(object sender, EventArgs e) { try { //txt_INVOICE_TYPE預設值 //string strType = "1"; #region 傳入參數 CAAModel.CAACommon CAAComm = new CAAModel.CAACommon(); ParameterList.Clear(); ParameterList.Add(CAAComm.GetValueSetParameter(this.TextBoxRowCountLimit.Text, "int", false));//N_ROW_NUM ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_YearMonth.Text, "string", false));//V_INVOICE_MONTH ParameterList.Add(CAAComm.GetValueSetParameter(this.SLP_INVOICE_TYPE.Text, "string", false));//V_INVOICE_TYPE ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_INVOICE_TRACK.Text.ToUpper(), "string", this.chb_Like_Search.Checked));//V_INVOICE_TRACK ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_STAR_NO.Text, "string", this.chb_Like_Search.Checked));//V_STAR_NO ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_END_NO.Text, "string", this.chb_Like_Search.Checked));//V_END_NO ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_CURRENT_NO.Text, "string", this.chb_Like_Search.Checked));//V_CURRENT_NO ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CLOSEUID.Text, "string", false));//V_CLOSEUID ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CLOSEDATE.Text, "string", false));//V_CLOSEDATE ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CREATEUID.Text, "string", false));//V_CREATEUID ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CREATEDATE_S.Text, "string", false));//V_CREATEDATE_S ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_CREATEDATE_E.Text, "string", false));//V_CREATEDATE_E ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_UPDATEUID.Text, "string", false));//V_UPDATEUID ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_UPDATEDATE_S.Text, "string", false));//V_UPDATEDATE_S ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_UPDATEDATE_E.Text, "string", false));//V_UPDATEDATE_E #endregion #region 連結資料庫 DataTable dt = new DataTable(); CAAModel.MaintainInvoiceTrack bco = new CAAModel.MaintainInvoiceTrack(ConntionDB); dt = bco.QueryInvTrackByLike(ParameterList); #endregion #region 資料與GridView繫結 //抓取本頁初次登記的時間 string SessionIDName = "CAA151_" + PageTimeStamp.Value; Session["SessionID"] = SessionIDName; Session[SessionIDName] = dt; gv_Track.DataSource = dt; gv_Track.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text); gv_Track.PageIndex = 0; gv_Track.DataBind(); #region 將Key值存到Session中 ArrayList arl_Key = new ArrayList(); foreach (DataRow drRow in dt.Rows) { arl_Key.Add(drRow["CODE"].ToString()); } Session["CAA152_SortKey" + this.PageTimeStamp.Value] = arl_Key; #endregion #endregion #region 檢查回傳資料 if (dt.Rows.Count == 0) { this.ErrorMsgLabel.Text = "查無資料"; } #endregion } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message; } finally { } }