/// <summary> /// 折讓項目,欄位[發票號碼]TextChanged事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void txt_Disc_INV_NO_TextChanged(object sender, EventArgs e) { try { #region 新增模式 & 檢視模式 if (this.hid_PageStatus.Value == "insert" || this.hid_PageStatus.Value == "edit") { #region 設定變數 BCO.CAACommon CAAComm = new BCO.CAACommon(); #endregion #region 檢查傳入欄位[發票號碼]的值 if (this.txt_Disc_INV_NO.Text.Trim() == string.Empty) { Set_Disc_NewItem_Default(); return; } #endregion #region 若輸入的發票號碼存在於按折讓開立查出的資料 bool b_IsExist_GetDiscInv = Set_Disc_NewItem_Value(this.txt_Disc_INV_NO.Text, dt_NewItem); #endregion #region 若輸入的發票號碼不存在於按折讓開立查出的資料 if (b_IsExist_GetDiscInv == false) { #region 傳入參數 ParameterList.Clear(); ParameterList.Add(CAAComm.GetValueSetParameter("TEXT", "string", false));//[查詢型態] if (this.hid_PageStatus.Value == "insert") { ParameterList.Add(CAAComm.GetValueSetParameter(DateTime.Now.ToString(), "date", false)); } else if (this.hid_PageStatus.Value == "edit") { ParameterList.Add(CAAComm.GetValueSetParameter(this.hid_Record_Date.Value, "date", false)); }//[履歷時間] ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_STORE_ID.Text, "string", false));//[店號] ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_RFNO.Text, "string", false));//[統一編號] ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_ROOT_NO.Text, "string", false));//[商品群分類] ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_TAX_TYPE.Text, "int", false));//[稅別] ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_Disc_INV_NO.Text, "string", false));//[發票號碼] ParameterList.Add(CAAComm.GetValueSetParameter("1", "int", false));//只取第1筆 ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//V_LOG_UPDATEUID #endregion #region 連結資料庫 BCO.MaintainDiscRecord bco = new BCO.MaintainDiscRecord(ConntionDB); DataTable dt_Return = bco.GetDetailRecord(ParameterList); #endregion #region 檢查回傳資料 #region 如果沒資料 if (dt_Return.Rows.Count == 0) { this.ErrorMsgLabel2.Text = "查無發票號碼:" + this.txt_Disc_INV_NO.Text + "的相關資料"; Set_Disc_NewItem_Default(); } #endregion #region 如果有資料 else { Set_Disc_NewItem_Value(this.txt_Disc_INV_NO.Text, dt_Return); #region 使用XML,將資料放置到前端 xml_VDS_CAA_INV_MAIN_Data.InnerHtml = dt_Return.DataSet.GetXml(); #endregion #region Focus欄位 string s_ScriptManager_Script = CAAComm.ToMakeUp_SetFocus_Script(slp_Disc_DISC_UAMT.TextBox_Code.ClientID, true); ScriptManager.RegisterStartupScript(this.up_DiscItem, typeof(UpdatePanel), "CAA182", s_ScriptManager_Script, true); #endregion } #endregion #endregion } else { #region Focus欄位 string s_ScriptManager_Script = CAAComm.ToMakeUp_SetFocus_Script(slp_Disc_DISC_UAMT.TextBox_Code.ClientID, true); ScriptManager.RegisterStartupScript(this.up_DiscItem, typeof(UpdatePanel), "CAA182", s_ScriptManager_Script, true); #endregion } #endregion } #endregion } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel2.Text = ex.Message; } finally { Finally_Function(); } }
/// <summary> /// BUTTON [折讓開立]鈕 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void but_GetDiscInv_Click(object sender, EventArgs e) { try { #region 新增狀態 if (this.hid_PageStatus.Value == "insert") { #region 檢查條件 BCO.CAACommon CAAComm = new BCO.CAACommon(); ArrayList arl_Check_Condition = Check_Condition("BUTTON [折讓開立]鈕"); #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_Msg, typeof(UpdatePanel), "CAA182", s_ScriptManager_Script, true); } #endregion return; } #endregion #endregion #region 清空變數 if (dt_NewItem != null) { dt_NewItem.Clear(); } #endregion #region 清空新增項目 #region 將新增項目的Panel關閉 this.panel_Disc_NewItem.Visible = false; #endregion #region 設定新增項目的初始狀態 Set_Disc_NewItem_Default(); #endregion #endregion #region 傳入參數 ParameterList.Clear(); ParameterList.Add(CAAComm.GetValueSetParameter("BUTTON", "string", false));//[查詢型態] ParameterList.Add(CAAComm.GetValueSetParameter(DateTime.Now.ToString(), "date", false));//[履歷時間] ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_STORE_ID.Text, "string", false));//[店號] ParameterList.Add(CAAComm.GetValueSetParameter(this.txt_RFNO.Text, "string", false));//[統一編號] ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_ROOT_NO.Text, "string", false));//[商品群分類] ParameterList.Add(CAAComm.GetValueSetParameter(this.slp_TAX_TYPE.Text, "int", false));//[稅別] ParameterList.Add(CAAComm.GetValueSetParameter(string.Empty, "string", false));//[發票號碼] ParameterList.Add(CAAComm.GetValueSetParameter("100", "int", false));//只取前100筆 ParameterList.Add(CAAComm.GetValueSetParameter(Session["UID"].ToString(), "string", false));//V_LOG_UPDATEUID #endregion #region 連結資料庫 BCO.MaintainDiscRecord bco = new BCO.MaintainDiscRecord(ConntionDB); dt_NewItem = bco.GetDetailRecord(ParameterList); #endregion #region 資料與GridView繫結 this.gv_DiscInv.DataSource = dt_NewItem; this.gv_DiscInv.PageSize = 10;//設定一頁10筆資料 this.gv_DiscInv.PageIndex = 0; this.gv_DiscInv.DataBind(); #endregion #region 檢查回傳資料 #region 不管有沒有資料,[新增項目]鈕都要可以按 this.but_Disc_NewItem.Enabled = true; #endregion #region 計算欄位[折讓金額(未稅)][折讓稅額][總金額] int i_txt_DISC_UAMT = 0;//折讓金額(未稅) int i_txt_DISC_TAX = 0;//折讓稅額 int i_txt_DISC_AMT = 0;//含稅金額 foreach (DataRow dr_Count in dt_NewItem.Rows) { i_txt_DISC_UAMT += int.Parse(dr_Count["DISC_UAMT"].ToString());//折讓金額(未稅) i_txt_DISC_TAX += int.Parse(dr_Count["DISC_TAX"].ToString());//折讓稅額 i_txt_DISC_AMT += int.Parse(dr_Count["DISC_AMT"].ToString());//含稅金額 } this.slp_DISC_UAMT.Text = i_txt_DISC_UAMT.ToString();//折讓金額(未稅) this.slp_DISC_TAX.Text = i_txt_DISC_TAX.ToString();//折讓稅額 this.slp_DISC_AMT.Text = i_txt_DISC_AMT.ToString();//總金額 #endregion #region 將畫面鎖起來 this.slp_DISC_FORM.ReadOnly = true;//格式代號 this.slp_STORE_ID.ReadOnly = true;//店號 this.slp_DISC_TYPE.ReadOnly = true;//型式 this.slp_ROOT_NO.ReadOnly = true;//商品群分類 this.slp_TAX_TYPE.ReadOnly = true;//稅別 this.txt_ACT_DISC_NO.ReadOnly = true;//財會折讓單號 this.txt_ACT_DISC_NO.CssClass = "readtxtbox"; this.slp_CHG_DISC_DATE.ReadOnly = true;//異動折讓日期 this.chb_PROOF_FLG.Enabled = false;//憑證已回 this.slp_PROOF_DATE.ReadOnly = true;//憑證已回日期 this.chb_REPROOF_FLG.Enabled = false;//取具進項憑証 this.txt_REPROOF_NO.ReadOnly = true;//發票號碼/收據 this.txt_REPROOF_NO.CssClass = "readtxtbox"; this.chb_RECEIPT_FLG.Enabled = false;//取具收據 this.slp_CLOSE_MONTH.ReadOnly = true;//結帳年月 this.txt_MEMO.ReadOnly = true;//備註 this.txt_MEMO.CssClass = "readtxtbox"; #endregion #endregion } #endregion } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message; } finally { Finally_Function(); } }