/// <summary> /// 設定折讓對帳單列印資料 /// </summary> /// <param name="dt_Temp_Result">折讓對帳單列印資料 Temp Table</param> /// <param name="d_Now">列印日期時間</param> /// <param name="dr_Temp_Main1">折讓對帳單左邊主檔資料區</param> /// <param name="dr_Temp_Main2">折讓對帳單右邊發票資料區</param> /// <param name="dr_Temp_Detl_Purchase">折讓對帳單進貨明細資料區</param> /// <param name="dr_Temp_Detl_Return">折讓對帳單退貨明細資料區</param> /// <param name="dr_Temp_Store">折讓對帳單店號相關資料</param> /// <param name="s_TAB_Index">2=折讓對帳單,4=單店未開發票對帳單</param> /// <returns></returns> private DataTable Collate_Information_Disc(DataTable dt_Temp_Result, DateTime d_Now, DataRow[] dr_Temp_Main1, DataRow[] dr_Temp_Main2, DataRow[] dr_Temp_Detl_Purchase, DataRow[] dr_Temp_Detl_Return, DataRow[] dr_Temp_Store, string s_TAB_Index, string strPROMTE) { #region 錯誤資料 //沒有明細資料 OR 沒有店號的資料皆屬於錯誤資料 if ((dr_Temp_Detl_Purchase == null && dr_Temp_Detl_Return == null) || (dr_Temp_Store == null)) { DataRow dr_Temp_Result = dt_Temp_Result.NewRow(); string s_Err_Disc_No = string.Empty; foreach (DataRow dr_Main1 in dr_Temp_Main1) { if (s_Err_Disc_No == string.Empty) { s_Err_Disc_No += dr_Main1["DISC_NO"].ToString(); } else { s_Err_Disc_No += "," + dr_Main1["DISC_NO"].ToString(); } } dr_Temp_Result["MAIN_LEFT_14"] = "資料異常,無法正確列印對帳單,折讓單號碼:" + s_Err_Disc_No; dt_Temp_Result.Rows.Add(dr_Temp_Result); } #endregion #region 正確資料 else { #region 設定變數 #region 列印日期 and 時間 string s_Print_Date = d_Now.ToString("yyyy/MM/dd");//列印日期 string s_Print_Time = d_Now.ToString("HH:mm:ss");//列印時間 #endregion #region 設定行數 int i_Detl_Count = 50;//設定Detl明細資料總共有幾行(包含[頁首][內容]頁尾[小計][單店小計][總計]) int i_Detl_Title = 4;//設定Detl頁首有幾行 int i_Detl_Total = 10;//設定Detl頁尾[小計][單店小計]&[總計]共有幾行 int i_Detl_Content = i_Detl_Count - i_Detl_Title;//設定Detl內容行數 bool b_IsFinally = false;//設定明細資料是否為最後一筆 int i_Actual_Total = 0;//設定Detl頁尾單店小計&總計執行到第幾筆 #endregion #region 設定折讓單號碼 string s_DISC_NO_Able = string.Empty;//應稅發票號碼 string s_DISC_NO_Free = string.Empty;//免稅發票號碼 string s_DISC_NO_Zero = string.Empty;//零稅率發票號碼 #endregion #region 計算[小計]金額 decimal dec_Subtotal_TOT_AMT_Purchase = 0;//[小計]-進貨未稅金額 decimal dec_Subtotal_TOT_AMT_AND_TAX_Purchase = 0;//[小計]-進貨含稅金額 decimal dec_Subtotal_TOT_AMT_Return = 0;//[小計]-退貨未稅金額 decimal dec_Subtotal_TOT_AMT_AND_TAX_Return = 0;//[小計]-退貨含稅金額 #endregion #region 計算[單店小計]金額 decimal dec_Single_Amount_Able = 0;//單店小計-[應稅]的[合計] decimal dec_Single_Amount_Free = 0;//單店小計-[免稅]的[合計] decimal dec_Single_Amount_Zero = 0;//單店小計-[零稅]的[合計] decimal dec_Single_Tax_Able = 0;//單店小計-[應稅]的[稅額] decimal dec_Single_Tax_Zero = 0;//單店小計-[零稅]的[稅額] #endregion #region 計算[總計]金額 int i_Total_Amount_Able = 0;//總計-[應稅]的[未稅金額] int i_Total_Amount_Free = 0;//總計-[免稅]的[未稅金額] int i_Total_Amount_Zero = 0;//總計-[零稅]的[未稅金額] int i_Total_Tax_Able = 0;//總計-[應稅]的[稅額] int i_Total_Tax_Zero = 0;//總計-[零稅]的[稅額] int i_Total_Disc_Able = 0;//總計-[應稅]的[折讓總額] int i_Total_Disc_Free = 0;//總計-[免稅]的[折讓總額] int i_Total_Disc_Zero = 0;//總計-[零稅]的[折讓總額] #endregion #endregion #region 計算需要幾頁來印這一筆資料 #region 設定變數 int i_dt_Temp_Result_Count_Inv = 0;//計算右邊主檔發票資料需要幾頁來列印 int i_dt_Temp_Result_Count_Purchase = 0;//計算進貨的DETL資料需要幾頁來列印 int i_dt_Temp_Result_Count_Return = 0;//計算退貨的DETL資料需要幾頁來列印 int i_dt_Temp_Result_Count = 0;//最後需要幾頁來列印 ArrayList arl_Inv_Statistics = new ArrayList(); ArrayList arl_Disc_Statistics = new ArrayList(); #endregion #region 計算右邊主檔發票資料需要幾頁來列印 if (s_TAB_Index == "2")//折讓對帳單 { DataTable dt_Temp_Right = new DataTable(); for (int i_Main1 = 0; i_Main1 < dr_Temp_Main1.Length; i_Main1++) { #region 設定變數 int i_Main2_Statistics = 0;//計算該張折讓單對應到的發票張數 #endregion #region 計算每一張折讓單需要幾頁來列印 //算出該張折讓單對應到幾筆發票資料 for (int i_Main2 = 0; i_Main2 < dr_Temp_Main2.Length; i_Main2++) { if (dr_Temp_Main1[i_Main1]["DISC_NO"].ToString() == dr_Temp_Main2[i_Main2]["DISC_NO"].ToString()) { i_Main2_Statistics += 1; //將資料存入ArrayList中 //文字陣列有2個參數 //(1)折讓單號在dr_Temp_Main1陣列中是第幾筆資料 //(2)發票號碼在dr_Temp_Main2陣列中是第幾筆資料 arl_Inv_Statistics.Add(new string[] { i_Main1.ToString(), i_Main2.ToString() }); } } //計算該張折讓單需要幾頁列印 if (i_Main2_Statistics % 5 > 0) { i_Main2_Statistics = (i_Main2_Statistics / 5) + 1; } else { i_Main2_Statistics = i_Main2_Statistics / 5; } //將資料存入ArrayList中 //文字陣列有2個參數 //(1)折讓單號 //(2)該張折讓單需要幾頁來顯示 //(3)該張折讓單已經顯示幾頁 arl_Disc_Statistics.Add(new string[] { dr_Temp_Main1[i_Main1]["DISC_NO"].ToString(), i_Main2_Statistics.ToString(), "0" }); #endregion #region 不滿五筆資料中間補空白 for (int q = 0; q < arl_Inv_Statistics.Count % 5; q++) { arl_Inv_Statistics.Add("空白"); } #endregion i_dt_Temp_Result_Count_Inv += i_Main2_Statistics; } } #endregion #region 計算進貨的DETL資料需要幾頁來列印 i_dt_Temp_Result_Count_Purchase = (dr_Temp_Detl_Purchase.Length + i_Detl_Total) / i_Detl_Content; if ((dr_Temp_Detl_Purchase.Length + i_Detl_Total) % i_Detl_Content > 0) { i_dt_Temp_Result_Count_Purchase += 1; } #endregion #region 計算退貨的DETL資料需要幾頁來列印 i_dt_Temp_Result_Count_Return = (dr_Temp_Detl_Return.Length + i_Detl_Total) / i_Detl_Content; if ((dr_Temp_Detl_Return.Length + i_Detl_Total) % i_Detl_Content > 0) { i_dt_Temp_Result_Count_Return += 1; } #endregion //取最大值 i_dt_Temp_Result_Count = Math.Max(i_dt_Temp_Result_Count_Inv, Math.Max(i_dt_Temp_Result_Count_Purchase, i_dt_Temp_Result_Count_Return)); #region 把紀錄發票的變數的筆數補滿最大的頁數 //折讓對帳單,有可能左邊明細資料需要5頁來印,但右邊發票只要1頁來印就可以 //這時紀錄發票的變數(arl_Inv_Statistics)只有紀錄第一頁的五筆資料,2,3,4,5頁都沒紀錄, //所以要在這邊補滿"空白"這個字串,不然後面程式判斷會有誤 if (i_dt_Temp_Result_Count * 5 > arl_Inv_Statistics.Count) { int i_fill = i_dt_Temp_Result_Count * 5 - arl_Inv_Statistics.Count; for (int i_fill_variable = 0; i_fill_variable < i_fill; i_fill_variable++) { arl_Inv_Statistics.Add("空白"); } } #endregion #endregion #region 計算總計金額 & 紀錄折讓單號 foreach (DataRow dr_Main1 in dr_Temp_Main1) { #region 應稅 if (dr_Main1["TAX_TYPE"].ToString() == "0") { i_Total_Amount_Able += int.Parse(dr_Main1["DISC_UAMT"].ToString());//總計-[應稅]的[未稅金額] i_Total_Tax_Able += int.Parse(dr_Main1["DISC_TAX"].ToString());//總計-[應稅]的[稅額] i_Total_Disc_Able += int.Parse(dr_Main1["DISC_AMT"].ToString());//總計-[應稅]的[折讓總額] s_DISC_NO_Able += (s_DISC_NO_Able == string.Empty) ? dr_Main1["DISC_NO"].ToString() : "," + dr_Main1["DISC_NO"].ToString(); } #endregion #region 免稅 else if (dr_Main1["TAX_TYPE"].ToString() == "1") { i_Total_Amount_Free += int.Parse(dr_Main1["DISC_UAMT"].ToString());//總計-[免稅]的[未稅金額] i_Total_Disc_Free += int.Parse(dr_Main1["DISC_AMT"].ToString());//總計-[免稅]的[折讓總額] s_DISC_NO_Free += (s_DISC_NO_Free == string.Empty) ? dr_Main1["DISC_NO"].ToString() : "," + dr_Main1["DISC_NO"].ToString(); } #endregion #region 零稅 else if (dr_Main1["TAX_TYPE"].ToString() == "2") { i_Total_Amount_Zero += int.Parse(dr_Main1["DISC_UAMT"].ToString());//總計-[零稅]的[未稅金額] i_Total_Tax_Zero += int.Parse(dr_Main1["DISC_TAX"].ToString());//總計-[零稅]的[稅額] i_Total_Disc_Zero += int.Parse(dr_Main1["DISC_AMT"].ToString());//總計-[零稅]的[折讓總額] s_DISC_NO_Zero += (s_DISC_NO_Zero == string.Empty) ? dr_Main1["DISC_NO"].ToString() : "," + dr_Main1["DISC_NO"].ToString(); } #endregion } #endregion #region 將資料寫入TempTable for (int a = 0; a < i_dt_Temp_Result_Count; a++) { DataRow dr_Temp_Result = dt_Temp_Result.NewRow(); #region 左邊主檔資料區 dr_Temp_Result["MAIN_LEFT_0"] = "列印日期:" + s_Print_Date;//列印日期 dr_Temp_Result["MAIN_LEFT_1"] = "列印時間:" + s_Print_Time;//列印時間 dr_Temp_Result["MAIN_LEFT_2"] = Convert.ToString(a + 1) + "/" + i_dt_Temp_Result_Count.ToString();//頁次 dr_Temp_Result["MAIN_LEFT_3"] = dr_Temp_Store[0]["Z_O"].ToString();//營業所 dr_Temp_Result["MAIN_LEFT_4"] = dr_Temp_Store[0]["ROUTE"].ToString();//路線 dr_Temp_Result["MAIN_LEFT_5"] = dr_Temp_Store[0]["STEP"].ToString();//路順 dr_Temp_Result["MAIN_LEFT_6"] = dr_Temp_Store[0]["D_SIR_NAME"].ToString();//物流士 dr_Temp_Result["MAIN_LEFT_7"] = dr_Temp_Store[0]["CLOSE_MONTH"].ToString();//結帳年月 dr_Temp_Result["MAIN_LEFT_8"] = dr_Temp_Store[0]["GROUP_NO"].ToString();//店群 dr_Temp_Result["MAIN_LEFT_9"] = dr_Temp_Store[0]["STORE"].ToString();//店號 dr_Temp_Result["MAIN_LEFT_10"] = dr_Temp_Store[0]["STORE_NAME"].ToString();//店名 dr_Temp_Result["MAIN_LEFT_11"] = dr_Temp_Store[0]["STORE_TEL"].ToString();//電話 dr_Temp_Result["MAIN_LEFT_12"] = dr_Temp_Store[0]["AC_UID"].ToString();//帳務人員 dr_Temp_Result["MAIN_LEFT_13"] = dr_Temp_Store[0]["INV_ADDR"].ToString();//地址 dr_Temp_Result["MAIN_LEFT_15"] = dr_Temp_Store[0]["SAL_ID"].ToString();//帳務人員 #endregion #region 訊息告知欄位區 dr_Temp_Result["MAIN_LEFT_14"] = strPROMTE;//檔期編號 20110427 rika insert #endregion #region 右邊主檔資料區(印發票的地方) //頁籤=[折讓對帳單]時,才有右邊主檔資料區 if (s_TAB_Index == "2")//折讓對帳單 { #region 設定變數 #region 規則 /* * 折讓對帳單右邊列印發票部份為一式四份,每一式可列印五張發票 * 折讓單必須分別列印 * EX: * 假設STORE1在同一天有A,B兩張折讓單 * A折讓單對應6張發票,B折讓單對應3張發票 * 則該份折讓對帳單應該列印出三張 * 第一張:A折讓單 & 對應的前5張發票 * 第二張:A折讓單 & 對應的最後一張發票 * 第三張:B折讓單 & 對應的三張發票 */ #endregion #region 將折讓日期由西元年轉為民國年 DateTime d_DISC_DATE = DateTime.Parse(dr_Temp_Main1[0]["DISC_DATE"].ToString()); System.Globalization.TaiwanCalendar g_TaiwanCalendar = new System.Globalization.TaiwanCalendar(); string s_DISC_Year = g_TaiwanCalendar.GetYear(d_DISC_DATE).ToString(); //折讓日期(年) string s_DISC_Month = g_TaiwanCalendar.GetMonth(d_DISC_DATE).ToString(); //折讓日期(月) string s_DISC_Date = g_TaiwanCalendar.GetDayOfMonth(d_DISC_DATE).ToString(); //折讓日期(日) #endregion string s_VOUCH_RFNO = string.Empty; bool b_Is_Bearing_Page = false;//折讓單[合計]是否顯示"續下頁" string s_Disc_Total_String = string.Empty; #endregion //一張折讓對帳單是[一式四份] for (int b = 0; b < 4; b++) { #region 將發票資料寫入TempTable //一式包含[五張發票] for (int c = 0; c < 5; c++) { if (arl_Inv_Statistics.Count > 0 && arl_Inv_Statistics[a * 5 + c].ToString() != "空白") { int i_dr_Temp_Main2_Count = int.Parse(((string[])(arl_Inv_Statistics[a * 5 + c]))[1].ToString()); #region 將發票日期由西元年轉換成民國年 DateTime d_INV_DATE = DateTime.Parse(dr_Temp_Main2[i_dr_Temp_Main2_Count]["INV_DATE"].ToString()); string s_INV_Year = g_TaiwanCalendar.GetYear(d_INV_DATE).ToString(); //發票日期(年) string s_INV_Month = g_TaiwanCalendar.GetMonth(d_INV_DATE).ToString(); //發票日期(月) string s_INV_Date = g_TaiwanCalendar.GetDayOfMonth(d_INV_DATE).ToString(); //發票日期(日) #endregion #region 設定[字軌號碼][品名][數量] BCO.CAACommon CAAComm = new BCO.CAACommon(); string s_Item_Name = string.Empty; int i_Item_Name_Length = 0; s_Item_Name = dr_Temp_Main2[i_dr_Temp_Main2_Count]["ITEM_NAME"].ToString().Trim(); i_Item_Name_Length = CAAComm.Get_Byte_Length(s_Item_Name); //如果[品名]的byte長度超過16,則一次減掉一個字 //減到[品名]的byte長度小於或等於16,則跳出迴圈 if (i_Item_Name_Length > 16) { for (int i_Length = 0; i_Length < s_Item_Name.Length; i_Length++) { if (CAAComm.Get_Byte_Length(s_Item_Name.Substring(0, s_Item_Name.Length - i_Length)) <= 16) { s_Item_Name = s_Item_Name.Substring(0, s_Item_Name.Length - i_Length) + string.Empty.PadRight(16 - CAAComm.Get_Byte_Length(s_Item_Name.Substring(0, s_Item_Name.Length - i_Length)), ' '); break; } } } else { s_Item_Name = s_Item_Name + string.Empty.PadRight(16 - CAAComm.Get_Byte_Length(s_Item_Name), ' '); } #endregion #region 將資料寫入Temp Table dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_0"] = dr_Temp_Main2[i_dr_Temp_Main2_Count]["INV_FORM"].ToString();//聯式 dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_1"] = s_INV_Year;//年 dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_2"] = s_INV_Month;//月 dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_3"] = s_INV_Date;//日 dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_4"] = dr_Temp_Main2[i_dr_Temp_Main2_Count]["INV_NO"].ToString().Trim();//字軌號碼 dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_4"] += string.Empty.PadLeft(1, ' ');//字軌號碼與品名之間的空白(全形空白) dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_4"] += s_Item_Name;//品名 dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_4"] += string.Empty.PadLeft(1, ' ');//品名與數量之間的空白(全形空白) dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_4"] += "1";//數量 dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_5"] = dr_Temp_Main2[i_dr_Temp_Main2_Count]["DISC_UAMT"].ToString();//末稅金額 dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_6"] = dr_Temp_Main2[i_dr_Temp_Main2_Count]["DISC_TAX"].ToString();//稅額 dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_7"] = dr_Temp_Main2[i_dr_Temp_Main2_Count]["TAX_TYPE"].ToString() == "0" ? "V" : string.Empty;//應稅 dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_8"] = dr_Temp_Main2[i_dr_Temp_Main2_Count]["TAX_TYPE"].ToString() == "2" ? "V" : string.Empty;//零稅 dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_" + c.ToString() + "_9"] = dr_Temp_Main2[i_dr_Temp_Main2_Count]["TAX_TYPE"].ToString() == "1" ? "V" : string.Empty;//免稅 #endregion } } #endregion #region 如果發票明細有資料,才將折讓單資訊寫入表頭 if (dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_0_0"].ToString() != string.Empty) { if (arl_Inv_Statistics.Count > 0 && arl_Inv_Statistics[a * 5 + 0].ToString() != "空白") { /* * 右邊發票資料是一式四份 * 每一式上方和下方是折讓單資料,中間是發票資料 * 每一張折讓對帳單中的發票資料會對應到同一張折讓單,不會對應到多筆折讓單 * 所以折讓單資料就抓每一式的第一張發票所對應的折讓單 */ int i_dr_Temp_Main1_Count = int.Parse(((string[])(arl_Inv_Statistics[a * 5 + 0]))[0].ToString()); #region 設定欄位[統一編號] s_VOUCH_RFNO = Get_VOUCH_RFNO(dr_Temp_Main1[i_dr_Temp_Main1_Count]["RFNO"].ToString()); #endregion #region 設定欄位[合計]的顯示方式 if (b == 0) { for (int i_Show_All = 0; i_Show_All < arl_Disc_Statistics.Count; i_Show_All++) { string[] s_Disc_Array = (string[])arl_Disc_Statistics[i_Show_All]; if (s_Disc_Array[0].ToString() == dr_Temp_Main1[i_dr_Temp_Main1_Count]["DISC_NO"].ToString()) { s_Disc_Array[2] = Convert.ToString(Convert.ToInt32(s_Disc_Array[2]) + 1); if (s_Disc_Array[1] != s_Disc_Array[2]) { b_Is_Bearing_Page = true; } s_Disc_Total_String = s_Disc_Array[2] + "/" + s_Disc_Array[1]; } } } #endregion #region 將折讓資料寫入TempTable dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_0"] = s_DISC_Year;//年 dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_1"] = s_DISC_Month;//月 dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_2"] = s_DISC_Date;//日 dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_3"] = dr_Temp_Main1[i_dr_Temp_Main1_Count]["DISC_NO"].ToString();//折讓單號 dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_4"] = dr_Temp_Main1[i_dr_Temp_Main1_Count]["Z_O"].ToString();//營業所 dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_5"] = dr_Temp_Main1[i_dr_Temp_Main1_Count]["AC_UID"].ToString();//帳務人員 decimal decDISC_UAMT = decimal.Parse(dr_Temp_Main1[i_dr_Temp_Main1_Count]["DISC_UAMT"].ToString()); decimal decDISC_TAX = decimal.Parse(dr_Temp_Main1[i_dr_Temp_Main1_Count]["DISC_TAX"].ToString()); //if (dr_Temp_Main1[i_dr_Temp_Main1_Count]["DISC_FORM"].ToString().Trim() == "34") //{ // decDISC_UAMT = decDISC_UAMT + decDISC_TAX; // decDISC_TAX = 0; //} dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_6"] = (b_Is_Bearing_Page == true) ? "續下頁" : decDISC_UAMT.ToString();//金額(不含稅之進貨額) dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_7"] = (b_Is_Bearing_Page == true) ? string.Empty : decDISC_TAX.ToString();//營業稅額 dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_8"] = (b_Is_Bearing_Page == true) ? string.Empty : ((dr_Temp_Main1[i_dr_Temp_Main1_Count]["TAX_TYPE"].ToString() == "0") ? "V" : string.Empty);//應稅 dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_9"] = (b_Is_Bearing_Page == true) ? string.Empty : ((dr_Temp_Main1[i_dr_Temp_Main1_Count]["TAX_TYPE"].ToString() == "2") ? "V" : string.Empty);//零稅率 dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_10"] = (b_Is_Bearing_Page == true) ? string.Empty : ((dr_Temp_Main1[i_dr_Temp_Main1_Count]["TAX_TYPE"].ToString() == "1") ? "V" : string.Empty);//免稅 dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_11"] = dr_Temp_Main1[i_dr_Temp_Main1_Count]["STORE_ID"].ToString() + " " + dr_Temp_Main1[i_dr_Temp_Main1_Count]["TITLE"].ToString();//原進貨營業人(或原買受人)名稱 dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_12"] = s_VOUCH_RFNO;//營業事業統一編號 dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_13"] = s_Disc_Total_String;//幾分之幾(1/3,2/3...) dr_Temp_Result["MAIN_RIGHT_Main_" + b.ToString() + "_14"] = dr_Temp_Main1[i_dr_Temp_Main1_Count]["PROFIT_NO"].ToString();//利潤中心 #endregion } } else { dr_Temp_Result["MAIN_RIGHT_Detl_" + b.ToString() + "_0_6"] = "空白"; }//品名 #endregion } } #endregion #region 明細資料區 #region 設定Detl頁首 if (b_IsFinally == false) { #region [群分類][書展] dr_Temp_Result["DETL_0_0"] += dr_Temp_Main1[0]["ROOT_NO"].ToString().PadRight(10, ' ');//群分類 dr_Temp_Result["DETL_0_0"] += dr_Temp_Main1[0]["IS_SCHEDULE"].ToString().PadRight(10, ' ');//書展 dr_Temp_Result["DETL_0_0"] += "可扣款日:"; dr_Temp_Result["DETL_0_0"] += (dr_Temp_Main1[0]["DUE_DATE"].ToString() == string.Empty) ? " " : DateTime.Parse(dr_Temp_Main1[0]["DUE_DATE"].ToString()).ToString("yyyy/MM/dd"); dr_Temp_Result["DETL_0_0"] += " "; dr_Temp_Result["DETL_0_0"] += "可扣款總額:"; dr_Temp_Result["DETL_0_0"] += string.Format("{0:#,0}", i_Total_Disc_Able + i_Total_Disc_Free + i_Total_Disc_Zero).PadLeft(10);//總計-[應稅]的[折讓總額] #endregion #region 頁首上面[橫線] dr_Temp_Result["DETL_1_0"] = "-----------"; dr_Temp_Result["DETL_1_1"] = "----------------------"; dr_Temp_Result["DETL_1_2"] = "----------------------"; dr_Temp_Result["DETL_1_3"] = "----------------------"; dr_Temp_Result["DETL_1_4"] = "----------------------"; dr_Temp_Result["DETL_1_5"] = "----------------------"; dr_Temp_Result["DETL_1_6"] = "----------------------"; dr_Temp_Result["DETL_1_7"] = "-----|-----"; dr_Temp_Result["DETL_1_8"] = "--------------"; dr_Temp_Result["DETL_1_9"] = "----------------------"; dr_Temp_Result["DETL_1_10"] = "----------------------"; dr_Temp_Result["DETL_1_11"] = "----------------------"; dr_Temp_Result["DETL_1_12"] = "----------------------"; dr_Temp_Result["DETL_1_13"] = "----------------------"; dr_Temp_Result["DETL_1_14"] = "----------------------"; #endregion #region 頁首[標題] dr_Temp_Result["DETL_2_0"] = "日期"; dr_Temp_Result["DETL_2_1"] = "屬性"; dr_Temp_Result["DETL_2_2"] = "稅別"; dr_Temp_Result["DETL_2_3"] = "高見單號"; dr_Temp_Result["DETL_2_4"] = "通路單號"; dr_Temp_Result["DETL_2_5"] = "未稅金額"; dr_Temp_Result["DETL_2_6"] = "含稅金額"; dr_Temp_Result["DETL_2_7"] = "|"; dr_Temp_Result["DETL_2_8"] = "日期"; dr_Temp_Result["DETL_2_9"] = "屬性"; dr_Temp_Result["DETL_2_10"] = "稅別"; dr_Temp_Result["DETL_2_11"] = "高見單號"; dr_Temp_Result["DETL_2_12"] = "通路單號"; dr_Temp_Result["DETL_2_13"] = "未稅金額"; dr_Temp_Result["DETL_2_14"] = "含稅金額"; #endregion #region 頁首下面[橫線] dr_Temp_Result["DETL_3_0"] = "-----------"; dr_Temp_Result["DETL_3_1"] = "----------------------"; dr_Temp_Result["DETL_3_2"] = "----------------------"; dr_Temp_Result["DETL_3_3"] = "----------------------"; dr_Temp_Result["DETL_3_4"] = "----------------------"; dr_Temp_Result["DETL_3_5"] = "----------------------"; dr_Temp_Result["DETL_3_6"] = "----------------------"; dr_Temp_Result["DETL_3_7"] = "-----|-----"; dr_Temp_Result["DETL_3_8"] = "--------------"; dr_Temp_Result["DETL_3_9"] = "----------------------"; dr_Temp_Result["DETL_3_10"] = "----------------------"; dr_Temp_Result["DETL_3_11"] = "----------------------"; dr_Temp_Result["DETL_3_12"] = "----------------------"; dr_Temp_Result["DETL_3_13"] = "----------------------"; dr_Temp_Result["DETL_3_14"] = "----------------------"; #endregion } #endregion #region 設定Detl內容 int i_Actual_Purchase = 0;//進貨實際寫入筆數 int i_Actual_Return = 0;//退貨實際寫入筆數 decimal dec_TOT_AMT_AND_TAX = 0;//計算含稅金額 //i_Detl_Content = Detl內容行數 for (int d = 0; d < i_Detl_Content; d++) { int i_dr_Temp_Detl_Count = a * i_Detl_Content + d; #region 進貨部分 if (dr_Temp_Detl_Purchase.Length > i_dr_Temp_Detl_Count) { #region 計算含稅金額 #region 規則 /* * 原本的規則: * 如果稅別 = 應稅&零稅,含稅金額 = VDS_CAM_ACCT_CHECK_OUT.TOT_AMT + VDS_CAM_ACCT_CHECK_OUT.TOT_AMT_TAX * 如果稅別 = 免稅,含稅金額直接放0 * 20091005 秀玲修改規則 * 不管它的稅別,含稅金額 = VDS_CAM_ACCT_CHECK_OUT.TOT_AMT + VDS_CAM_ACCT_CHECK_OUT.TOT_AMT_TAX */ #endregion dec_TOT_AMT_AND_TAX = decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString()) + decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString()); #endregion #region 寫入資料 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_0"] = DateTime.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["ACCT_DATE"].ToString()).ToString("yyyy/MM/dd");//日期 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_1"] = dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["ACCT_KD"];//屬性 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_2"] = dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TAX_TYPE"];//稅別 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_3"] = dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["EA_NO"];//高見單號 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_4"] = dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["CHAN_SOURCE_NO"];//通路單號 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_5"] = (Math.Abs(decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString())) > 1000000) ? "******" : string.Format("{0:N}", dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"]);//未稅金額 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_6"] = (Math.Abs(dec_TOT_AMT_AND_TAX) > 1000000) ? "******" : string.Format("{0:N}", dec_TOT_AMT_AND_TAX);//含稅金額 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_7"] = "|"; #endregion #region 計算[進貨]的明細最後是寫到哪一行 i_Actual_Purchase = i_Detl_Title + d; #endregion #region 計算[小計]金額 dec_Subtotal_TOT_AMT_Purchase += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//[小計]-進貨未稅金額 dec_Subtotal_TOT_AMT_AND_TAX_Purchase += dec_TOT_AMT_AND_TAX;//[小計]-進貨含稅金額 #endregion #region 計算[單店小計]金額 if (dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "應稅") { dec_Single_Amount_Able += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//單店小計-[應稅]的[合計] dec_Single_Tax_Able += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString());//單店小計-[應稅]的[稅額] } else if (dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "免稅") { dec_Single_Amount_Free += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString()); }//單店小計-[免稅]的[合計] else if (dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "零稅") { dec_Single_Amount_Zero += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//單店小計-[零稅]的[合計] dec_Single_Tax_Zero += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString()); //單店小計-[零稅]的[稅額] } #endregion } #endregion #region 退貨部分 if (dr_Temp_Detl_Return.Length > i_dr_Temp_Detl_Count) { #region 計算含稅金額 #region 規則 /* * 原本的規則: * 如果稅別 = 應稅&零稅,含稅金額 = VDS_CAM_ACCT_CHECK_OUT.TOT_AMT + VDS_CAM_ACCT_CHECK_OUT.TOT_AMT_TAX * 如果稅別 = 免稅,含稅金額直接放0 * 20091005 秀玲修改規則 * 不管它的稅別,含稅金額 = VDS_CAM_ACCT_CHECK_OUT.TOT_AMT + VDS_CAM_ACCT_CHECK_OUT.TOT_AMT_TAX */ #endregion dec_TOT_AMT_AND_TAX = decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString()) + decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString()); #endregion #region 寫入資料 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_7"] = "|"; dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_8"] = DateTime.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["ACCT_DATE"].ToString()).ToString("yyyy/MM/dd");//日期 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_9"] = dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["ACCT_KD"];//屬性 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_10"] = dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TAX_TYPE"];//稅別 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_11"] = dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["EA_NO"];//高見單號 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_12"] = dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["CHAN_SOURCE_NO"];//通路單號 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_13"] = (Math.Abs(decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString())) > 1000000) ? "******" : string.Format("{0:N}", dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"]);//未稅金額 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_14"] = (Math.Abs(dec_TOT_AMT_AND_TAX) > 1000000) ? "******" : string.Format("{0:N}", dec_TOT_AMT_AND_TAX);//含稅金額 #endregion #region 計算[退貨]的明細最後是寫到哪一行 i_Actual_Return = i_Detl_Title + d; #endregion #region 計算[小計]金額 dec_Subtotal_TOT_AMT_Return += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//[小計]-退貨未稅金額 dec_Subtotal_TOT_AMT_AND_TAX_Return += dec_TOT_AMT_AND_TAX;//[小計]-退貨含稅金額 #endregion #region 計算[單店小計]金額 if (dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "應稅") { dec_Single_Amount_Able += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//單店小計-[應稅]的[合計] dec_Single_Tax_Able += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString());//單店小計-[應稅]的[稅額] } else if (dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "免稅") { dec_Single_Amount_Free += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString()); }//單店小計-[免稅]的[合計] else if (dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "零稅") { dec_Single_Amount_Zero += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//單店小計-[零稅]的[合計] dec_Single_Tax_Zero += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString()); //單店小計-[零稅]的[稅額] } #endregion } #endregion } #endregion #region 設定Detl頁尾[小計]&[單店小計]&[總計] //取得Detl頁尾小計從哪一行開始 int i_Detl_Subtotal_Begin = ((i_Actual_Purchase > i_Actual_Return) ? i_Actual_Purchase : i_Actual_Return) + 1; //判斷是否為最後一筆 if ((i_Detl_Content * a + i_Detl_Subtotal_Begin - i_Detl_Title == ((dr_Temp_Detl_Purchase.Length > dr_Temp_Detl_Return.Length) ? dr_Temp_Detl_Purchase.Length : dr_Temp_Detl_Return.Length)) || (b_IsFinally == true)) { //i_Detl_Count = Detl明細資料總共有幾行(包含[頁首][內容][頁尾小計][頁尾總計]) //i_Detl_Subtotal = Detl頁尾小計有幾行 int i_Detl_Total_Begin = 0;//紀錄Detl頁尾單店小計&總計從哪一行開始 int i_Actual_Detl_Total_Begin = 0;//設定小計總計是要在哪一行 int i_Original_i_Actual_Total = 0;//若是這一頁是只印小計總計部分,這個變數紀錄上一頁是印到第幾筆 if (b_IsFinally == true) { i_Original_i_Actual_Total = i_Actual_Total; } else { i_Detl_Total_Begin = i_Detl_Subtotal_Begin; } #region 小計 #region [小計]上方那一條線 if ((i_Detl_Total_Begin + 0 < i_Detl_Count) && (i_Actual_Total < 1)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 0; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] = "--------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_1"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_2"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_3"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_4"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_5"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_6"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_7"] = "-----|-----"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_8"] = "--------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_9"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_10"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_11"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_12"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_13"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_14"] = "----------------------"; i_Actual_Total = 1; } #endregion #region [小計]資料 if ((i_Detl_Total_Begin + 1 < i_Detl_Count) && (i_Actual_Total < 2)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 1; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] = "小計"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_5"] = (Math.Abs(dec_Subtotal_TOT_AMT_Purchase) > 1000000) ? "******" : string.Format("{0:N}", dec_Subtotal_TOT_AMT_Purchase);//進貨[未稅金額]小計 dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_6"] = (Math.Abs(dec_Subtotal_TOT_AMT_AND_TAX_Purchase) > 1000000) ? "******" : string.Format("{0:N}", dec_Subtotal_TOT_AMT_AND_TAX_Purchase);//進貨[含稅金額]小計 dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_7"] = "|"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_13"] = (Math.Abs(dec_Subtotal_TOT_AMT_Return) > 1000000) ? "******" : string.Format("{0:N}", dec_Subtotal_TOT_AMT_Return);//退貨[未稅金額]小計 dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_14"] = (Math.Abs(dec_Subtotal_TOT_AMT_AND_TAX_Return) > 1000000) ? "******" : string.Format("{0:N}", dec_Subtotal_TOT_AMT_AND_TAX_Return);//退貨[含稅金額]小計 i_Actual_Total = 2; } #endregion #region [小計]下方那一條線 if ((i_Detl_Total_Begin + 2 < i_Detl_Count) && (i_Actual_Total < 3)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 2; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] = "--------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_1"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_2"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_3"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_4"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_5"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_6"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_7"] = "-----|-----"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_8"] = "--------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_9"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_10"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_11"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_12"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_13"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_14"] = "----------------------"; i_Actual_Total = 3; } #endregion #endregion #region 單店小計 if ((i_Detl_Total_Begin + 3 < i_Detl_Count) && (i_Actual_Total < 4)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 3; } //注意:[應稅 合計:$]中間的空白,是[全型]的空白 dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "單店小計".PadRight(4, ' '); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(45); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "應稅 :未稅金額"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Able, MidpointRounding.AwayFromZero)).PadLeft(10); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "稅額:$"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Tax_Able, MidpointRounding.AwayFromZero)).PadLeft(10); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); if (dec_Single_Amount_Able < 0) { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; } else { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Able, MidpointRounding.AwayFromZero) + System.Math.Round(dec_Single_Tax_Able, MidpointRounding.AwayFromZero)).PadLeft(10); i_Actual_Total = 4; } if ((i_Detl_Total_Begin + 4 < i_Detl_Count) && (i_Actual_Total < 5)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 4; } //注意:[免稅 合計:$]中間的空白,是[全型]的空白 dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(4, ' '); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(45); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "免稅 :未稅金額"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Free, MidpointRounding.AwayFromZero)).PadLeft(10); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadLeft(8); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadLeft(10); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); if (dec_Single_Amount_Free < 0) { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; } else { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Free, MidpointRounding.AwayFromZero)).PadLeft(10); i_Actual_Total = 5; } if ((i_Detl_Total_Begin + 5 < i_Detl_Count) && (i_Actual_Total < 6)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 5; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(4, ' '); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(45); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "零稅率:未稅金額"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Zero, MidpointRounding.AwayFromZero)).PadLeft(10); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "稅額:$"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Tax_Zero, MidpointRounding.AwayFromZero)).PadLeft(10); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); if (dec_Single_Amount_Zero < 0) { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; } else { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Zero, MidpointRounding.AwayFromZero) + System.Math.Round(dec_Single_Tax_Zero, MidpointRounding.AwayFromZero)).PadLeft(10); i_Actual_Total = 6; } #endregion #region 中間空一行 if ((i_Detl_Total_Begin + 6 < i_Detl_Count) && (i_Actual_Total < 7)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 6; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] = string.Empty; i_Actual_Total = 7; } #endregion #region 總計 if ((i_Detl_Total_Begin + 7 < i_Detl_Count) && (i_Actual_Total < 8)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 7; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總計".PadRight(4, ' '); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "應稅折讓號碼 :"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += (s_DISC_NO_Able.Length > 28) ? s_DISC_NO_Able.Substring(0, 27) : s_DISC_NO_Able.PadRight(27); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(2); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "應稅 :未稅金額"; i_Total_Amount_Able = i_Total_Amount_Able * -1; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Amount_Able).PadLeft(10);//總計-[應稅]的[未稅金額] dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "稅額:$"; i_Total_Tax_Able = i_Total_Tax_Able * -1; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Tax_Able).PadLeft(10);//總計-[應稅]的[稅額] dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "折讓總額:$";//折讓總額 i_Total_Disc_Able = i_Total_Disc_Able * -1; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Disc_Able).PadLeft(10);//總計-[應稅]的[折讓總額] i_Actual_Total = 8; } if ((i_Detl_Total_Begin + 8 < i_Detl_Count) && (i_Actual_Total < 9)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 8; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(4, ' '); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "免稅折讓號碼 :"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += (s_DISC_NO_Free.Length > 28) ? s_DISC_NO_Free.Substring(0, 27) : s_DISC_NO_Free.PadRight(27); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(2); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "免稅 :未稅金額"; i_Total_Amount_Free = i_Total_Amount_Free * -1; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Amount_Free).PadLeft(10);//總計-[免稅]的[未稅金額] dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadLeft(8); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadLeft(10); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "折讓總額:$";//折讓總額 i_Total_Disc_Free = i_Total_Disc_Free * -1; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Disc_Free).PadLeft(10);//總計-[免稅]的[折讓總額] i_Actual_Total = 9; } if ((i_Detl_Total_Begin + 9 < i_Detl_Count) && (i_Actual_Total < 10)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 9; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(4, ' '); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "零稅率折讓號碼:"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += (s_DISC_NO_Zero.Length > 28) ? s_DISC_NO_Zero.Substring(0, 27) : s_DISC_NO_Zero.PadRight(27); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(2); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "零稅率:未稅金額"; i_Total_Amount_Zero = i_Total_Amount_Zero * -1; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Amount_Zero).PadLeft(10);//總計-[零稅]的[未稅金額] dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "稅額:$"; i_Total_Tax_Zero = i_Total_Tax_Zero * -1; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Tax_Zero).PadLeft(10);//總計-[零稅]的[稅額] dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "折讓總額:$"; i_Total_Disc_Zero = i_Total_Disc_Zero * -1; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Disc_Zero).PadLeft(10);//總計-[零稅]的[折讓總額] i_Actual_Total = 10; } #endregion //設定明細資料是否為最後一筆 b_IsFinally = true; } #endregion #endregion dt_Temp_Result.Rows.Add(dr_Temp_Result); } #endregion } #endregion return dt_Temp_Result; }
/// <summary> /// 頁籤=計算機發票 /// </summary> /// <param name="ParameterList"></param> /// <returns></returns> public DataTable CAA24_5(ArrayList ParameterList) { #region 宣告變數 BCO.CAACommon CAAComm = new BCO.CAACommon(); ArrayList arl_ReportService = new ArrayList(); #endregion #region 傳入參數 #region 規則 /* * 當頁籤=發票對帳單時 * 抓取[單店開立]的資料 * 當頁籤=單店未開發票對帳單 * 抓取[單店開立]&[總部彙開]的資料 * 當頁籤=計算機發票 * 抓取[單店開立]&[總部彙開]的資料 */ #endregion arl_ReportService.Clear(); arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[0].ToString(), "string", false));//[結帳年月](0) arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[1].ToString(), "string", false));//[店群]起(1) arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[2].ToString(), "string", false));//[店群]迄(2) arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[3].ToString(), "string", false));//[路線]起(3) arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[4].ToString(), "string", false));//[路線]迄(4) arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[5].ToString(), "string", false));//[結帳統編](5) arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[6].ToString(), "string", false));//[店號](6) arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[7].ToString(), "string", false));//[商品群分類](7) arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[8].ToString(), "int", false));//[路線](8) arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[9].ToString(), "string", false));//[發票對帳單送達](9) arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[10].ToString(), "int", false));//[列印註記](0=未列印,1=已列印)(10) arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[11].ToString(), "int", false));//[判斷抓取資料範圍](0=單店開立,1=總部彙開+單店開立)(11) arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[12].ToString(), "string", false));//登入人員(12) arl_ReportService.Add(CAAComm.GetValueSetParameter(ParameterList[13].ToString(), "string", false));//那一個頁籤(13) arl_ReportService.Add(CAAComm.GetValueSetParameter("0", "string", false));//發票未作廢(14) #endregion #region 連結資料庫 DataTable dt_Return = new DataTable(); BCO.CheckSheetPrint bco = new BCO.CheckSheetPrint(ConntionDB); dt_Return = bco.GetInvData(null, arl_ReportService); #endregion #region 檢查回傳資料,如果有資料,則依照[帳務人員][店號][稅別][發票號碼]排序資料 #region 規則 /* 20100318秀玲與USER確認更改需求 * 頁籤=計算機發票,排序依照[帳務人員][店號][稅別][發票號碼]排序資料 */ #endregion if (dt_Return.Rows.Count == 0) { throw new Exception("查無資料"); } else { dt_Return = new DataView(dt_Return, string.Empty, "AC_UID_RANK,STORE_ID_RANK,TAX_TYPE,INV_NO", DataViewRowState.CurrentRows).ToTable(); } #endregion #region 整理列印資料 #region 設定 dt_Temp_Result 的框架 #region 設定變數 int i_Main_Row_Right = 25;//設定右邊主檔資料區有幾個欄位(一個發票的欄位) DataTable dt_Temp_Result = new DataTable(); #endregion #region 右邊主檔資料區(印發票的地方) for (int c = 0; c < i_Main_Row_Right; c++) { dt_Temp_Result.Columns.Add("MAIN_RIGHT_" + c.ToString(), typeof(string)); } #endregion #endregion foreach (DataRow dr_Row in dt_Return.Rows) { #region 設定變數 DateTime d_INV_DATE = DateTime.Parse(dr_Row["INV_DATE"].ToString()); System.Globalization.TaiwanCalendar g_TaiwanCalendar = new System.Globalization.TaiwanCalendar(); string s_Year = g_TaiwanCalendar.GetYear(d_INV_DATE).ToString(); //發票日期(年) string s_Month = g_TaiwanCalendar.GetMonth(d_INV_DATE).ToString(); //發票日期(月) string s_Date = g_TaiwanCalendar.GetDayOfMonth(d_INV_DATE).ToString(); //發票日期(日) string s_INV_AMT = Conversion_Number(dr_Row["INV_AMT"].ToString(), 9); string s_VOUCH_RFNO = string.Empty;//統一編號 DataRow dr_Temp_Result = dt_Temp_Result.NewRow(); #endregion #region 將資料寫入TempTable for (int i = 0; i < i_Main_Row_Right; i++) { #region 設定統一編號 s_VOUCH_RFNO = Get_VOUCH_RFNO(dr_Row["VOUCH_RFNO"].ToString()); #endregion decimal decINV_UAMT = decimal.Parse(dr_Row["INV_UAMT"].ToString()); decimal decINV_TAX = decimal.Parse(dr_Row["INV_TAX"].ToString()); if (dr_Row["INV_FORM"].ToString().Trim() == "32") { decINV_UAMT = decINV_UAMT + decINV_TAX; decINV_TAX = 0; } dr_Temp_Result["MAIN_RIGHT_0"] = s_Year;//年 dr_Temp_Result["MAIN_RIGHT_1"] = s_Month;//月 dr_Temp_Result["MAIN_RIGHT_2"] = s_Date;//日 dr_Temp_Result["MAIN_RIGHT_3"] = dr_Row["INV_CHKNO"].ToString();//檢查號碼 dr_Temp_Result["MAIN_RIGHT_4"] = dr_Row["INV_NO"].ToString();//發票號碼 dr_Temp_Result["MAIN_RIGHT_5"] = dr_Row["TITLE"].ToString();//買受人 dr_Temp_Result["MAIN_RIGHT_6"] = s_VOUCH_RFNO;//統一編號 dr_Temp_Result["MAIN_RIGHT_7"] = dr_Row["ITEM_NAME"].ToString();//品名 dr_Temp_Result["MAIN_RIGHT_8"] = string.Format("{0:N}", decINV_UAMT).Replace(".00", string.Empty);//金額(20100329秀玲修改需求,改抓未稅金額) dr_Temp_Result["MAIN_RIGHT_9"] = (dr_Row["TAX_TYPE"].ToString() == "0") ? "V" : string.Empty;//應稅 dr_Temp_Result["MAIN_RIGHT_10"] = (dr_Row["TAX_TYPE"].ToString() == "2") ? "V" : string.Empty;//零稅 dr_Temp_Result["MAIN_RIGHT_11"] = (dr_Row["TAX_TYPE"].ToString() == "1") ? "V" : string.Empty;//免稅 dr_Temp_Result["MAIN_RIGHT_12"] = string.Format("{0:N}", decINV_UAMT).Replace(".00", string.Empty);//銷售額合計 dr_Temp_Result["MAIN_RIGHT_13"] = string.Format("{0:N}", decINV_TAX).Replace(".00", string.Empty);//營業稅 dr_Temp_Result["MAIN_RIGHT_14"] = string.Format("{0:N}", int.Parse(dr_Row["INV_AMT"].ToString())).Replace(".00", string.Empty);//總計 dr_Temp_Result["MAIN_RIGHT_24"] = s_INV_AMT.Substring(0, 1);//億 dr_Temp_Result["MAIN_RIGHT_15"] = s_INV_AMT.Substring(1, 1);//千萬 dr_Temp_Result["MAIN_RIGHT_16"] = s_INV_AMT.Substring(2, 1);//百萬 dr_Temp_Result["MAIN_RIGHT_17"] = s_INV_AMT.Substring(3, 1);//十萬 dr_Temp_Result["MAIN_RIGHT_18"] = s_INV_AMT.Substring(4, 1);//萬 dr_Temp_Result["MAIN_RIGHT_19"] = s_INV_AMT.Substring(5, 1);//千 dr_Temp_Result["MAIN_RIGHT_20"] = s_INV_AMT.Substring(6, 1);//百 dr_Temp_Result["MAIN_RIGHT_21"] = s_INV_AMT.Substring(7, 1);//拾 dr_Temp_Result["MAIN_RIGHT_22"] = s_INV_AMT.Substring(8, 1);//元 //20100503新增該欄位(小張計算機發票備註欄位下面加上店號) //發票對帳單的備註欄位下方的店號是抓VDS_CAM_ACCT_CHECK_OUT的店號,但計算機發票是抓VDS_CAA_INV_MAIN的店號 //但發票對帳單只列印單店分別開的發票,這一些發票在發票主檔中的欄位[店號]也是放單店 //而總部彙開的發票在發票主檔的欄位[店號]是放總部店號 //所以小張計算機發票的欄位[店號]直接抓VDS_CAA_INV_MAIN的店號即可 dr_Temp_Result["MAIN_RIGHT_23"] = dr_Row["STORE_ID_RANK"].ToString();//店號 } dt_Temp_Result.Rows.Add(dr_Temp_Result); #endregion } #endregion #region 檢查列印資料 if (dt_Temp_Result.Rows.Count == 0) { throw new Exception("查無資料!!"); } #endregion #region 更新發票主檔的列印註記 #region 規則 /* * 當頁籤 = 發票對帳單 & 計算機發票 * 查詢完成後必須更新發票主檔的列印註記 * 當頁籤 = 單店未開發票對帳單 * 查詢完成後不必更新發票主檔的列印註記 */ #endregion DateTime d_Now = DateTime.Now; string s_LogUser = arl_ReportService[12].ToString(); bco.CAA241_UPDATE_INV_MAIN(null, dt_Return, d_Now, s_LogUser); #endregion return dt_Temp_Result; }
/// <summary> /// 設定發票對帳單列印資料 /// </summary> /// <param name="dt_Temp_Result">發票對帳單列印資料 Temp Table</param> /// <param name="d_Now">列印日期時間</param> /// <param name="dr_Temp_Main">發票對帳單左邊主檔資料區</param> /// <param name="dr_Temp_Detl_Purchase">折讓對帳單進貨明細資料區</param> /// <param name="dr_Temp_Detl_Return">折讓對帳單退貨明細資料區</param> /// <param name="dr_Temp_Detl_Return">發票對帳單店號相關資料</param> /// <param name="s_TAB_Index">1=發票對帳單,3=單店對帳單</param> /// strPROMTE /// <returns></returns> private DataTable Collate_Information_Inv(DataTable dt_Temp_Result, DateTime d_Now, DataRow[] dr_Temp_Main, DataRow[] dr_Temp_Detl_Purchase, DataRow[] dr_Temp_Detl_Return, DataRow[] dr_Temp_Store, string s_TAB_Index, string strPROMTE) { #region 錯誤資料 if ((dr_Temp_Detl_Purchase == null && dr_Temp_Detl_Return == null) || (dr_Temp_Store == null)) { DataRow dr_Temp_Result = dt_Temp_Result.NewRow(); string s_Err_Inv_No = string.Empty; foreach (DataRow dr_Main in dr_Temp_Main) { if (s_Err_Inv_No == string.Empty) { s_Err_Inv_No += dr_Main["INV_NO"].ToString(); } else { s_Err_Inv_No += "," + dr_Main["INV_NO"].ToString(); } } dr_Temp_Result["MAIN_LEFT_14"] = "資料異常,無法正確列印對帳單,發票號碼:" + s_Err_Inv_No; dt_Temp_Result.Rows.Add(dr_Temp_Result); } #endregion #region 正確資料 else { #region 設定變數 #region 列印日期 and 時間 string s_Print_Date = d_Now.ToString("yyyy/MM/dd");//列印日期 string s_Print_Time = d_Now.ToString("HH:mm:ss");//列印時間 #endregion #region 設定行數 int i_Detl_Count = 50;//設定Detl明細資料總共有幾行(包含[頁首][內容]頁尾[小計][單店小計][總計]) int i_Detl_Title = 4;//設定Detl頁首有幾行 int i_Detl_Total = 10;//設定Detl頁尾[小計][單店小計]&[總計]共有幾行 int i_Detl_Content = i_Detl_Count - i_Detl_Title;//設定Detl內容行數 bool b_IsFinally = false;//設定明細資料是否為最後一筆 int i_Actual_Total = 0;//設定Detl頁尾單店小計&總計執行到第幾筆 #endregion #region 設定發票號碼 string s_INV_NO_Able = string.Empty;//應稅發票號碼 string s_INV_NO_Free = string.Empty;//免稅發票號碼 string s_INV_NO_Zero = string.Empty;//零稅率發票號碼 #endregion #region 計算[小計]金額 decimal dec_Subtotal_TOT_AMT_Purchase = 0;//[小計]-進貨未稅金額 decimal dec_Subtotal_TOT_AMT_AND_TAX_Purchase = 0;//[小計]-進貨含稅金額 decimal dec_Subtotal_TOT_AMT_Return = 0;//[小計]-退貨未稅金額 decimal dec_Subtotal_TOT_AMT_AND_TAX_Return = 0;//[小計]-退貨含稅金額 #endregion #region 計算[單店小計]金額 decimal dec_Single_Amount_Able = 0;//單店小計-[應稅]的[合計] decimal dec_Single_Amount_Free = 0;//單店小計-[免稅]的[合計] decimal dec_Single_Amount_Zero = 0;//單店小計-[零稅]的[合計] decimal dec_Single_Tax_Able = 0;//單店小計-[應稅]的[稅額] decimal dec_Single_Tax_Zero = 0;//單店小計-[零稅]的[稅額] #endregion #region 計算[總計]金額 int i_Total_Amount_Able = 0;//總計-[應稅]的[未稅金額] int i_Total_Amount_Free = 0;//總計-[免稅]的[未稅金額] int i_Total_Amount_Zero = 0;//總計-[零稅]的[未稅金額] int i_Total_Tax_Able = 0;//總計-[應稅]的[稅額] int i_Total_Tax_Zero = 0;//總計-[零稅]的[稅額] int i_Total_Inv_Able = 0;//總計-[應稅]的[發票總額] int i_Total_Inv_Free = 0;//總計-[免稅]的[發票總額] int i_Total_Inv_Zero = 0;//總計-[零稅]的[發票總額] #endregion #endregion #region 計算需要幾頁來印這一筆資料 int i_dt_Temp_Result_Count_Inv = 0;//計算右邊主檔發票資料需要幾頁來列印 int i_dt_Temp_Result_Count_Purchase = 0;//計算進貨的DETL資料需要幾頁來列印 int i_dt_Temp_Result_Count_Return = 0;//計算退貨的DETL資料需要幾頁來列印 int i_dt_Temp_Result_Count = 0;//最後需要幾頁來列印 #region 計算右邊主檔發票資料需要幾頁來列印 if (s_TAB_Index == "1")//發票對帳單 { if (dr_Temp_Main.Length % 2 > 0) { i_dt_Temp_Result_Count_Inv = (dr_Temp_Main.Length / 2) + 1; } else { i_dt_Temp_Result_Count_Inv = dr_Temp_Main.Length / 2; } } #endregion #region 計算進貨的DETL資料需要幾頁來列印 if (dr_Temp_Detl_Purchase != null) { i_dt_Temp_Result_Count_Purchase = (dr_Temp_Detl_Purchase.Length + i_Detl_Total) / i_Detl_Content; if ((dr_Temp_Detl_Purchase.Length + i_Detl_Total) % i_Detl_Content > 0) { i_dt_Temp_Result_Count_Purchase += 1; } } #endregion #region 計算退貨的DETL資料需要幾頁來列印 if (dr_Temp_Detl_Return != null) { i_dt_Temp_Result_Count_Return = (dr_Temp_Detl_Return.Length + i_Detl_Total) / i_Detl_Content; if ((dr_Temp_Detl_Return.Length + i_Detl_Total) % i_Detl_Content > 0) { i_dt_Temp_Result_Count_Return += 1; } } #endregion //取最大值 i_dt_Temp_Result_Count = Math.Max(i_dt_Temp_Result_Count_Inv, Math.Max(i_dt_Temp_Result_Count_Purchase, i_dt_Temp_Result_Count_Return)); #endregion #region 計算總計金額 & 紀錄發票號碼 foreach (DataRow dr_Main in dr_Temp_Main) { //[TAX_TYPE] 0=應稅,1=免稅,2=零稅 #region 應稅 if (dr_Main["TAX_TYPE"].ToString() == "0") { i_Total_Amount_Able += int.Parse(dr_Main["INV_UAMT"].ToString());//總計-[應稅]的[未稅金額] i_Total_Tax_Able += int.Parse(dr_Main["INV_TAX"].ToString());//總計-[應稅]的[稅額] i_Total_Inv_Able += int.Parse(dr_Main["INV_AMT"].ToString());//總計-[應稅]的[發票總額] s_INV_NO_Able += (s_INV_NO_Able == string.Empty) ? dr_Main["INV_NO"].ToString() : "," + dr_Main["INV_NO"].ToString(); } #endregion #region 免稅 else if (dr_Main["TAX_TYPE"].ToString() == "1") { i_Total_Amount_Free += int.Parse(dr_Main["INV_UAMT"].ToString());//總計-[免稅]的[未稅金額] i_Total_Inv_Free += int.Parse(dr_Main["INV_AMT"].ToString());//總計-[免稅]的[發票總額] s_INV_NO_Free += (s_INV_NO_Free == string.Empty) ? dr_Main["INV_NO"].ToString() : "," + dr_Main["INV_NO"].ToString(); } #endregion #region 零稅 else if (dr_Main["TAX_TYPE"].ToString() == "2") { i_Total_Amount_Zero += int.Parse(dr_Main["INV_UAMT"].ToString());//總計-[零稅]的[未稅金額] i_Total_Tax_Zero += int.Parse(dr_Main["INV_TAX"].ToString());//總計-[零稅]的[稅額] i_Total_Inv_Zero += int.Parse(dr_Main["INV_AMT"].ToString());//總計-[零稅]的[發票總額] s_INV_NO_Zero += (s_INV_NO_Zero == string.Empty) ? dr_Main["INV_NO"].ToString() : "," + dr_Main["INV_NO"].ToString(); } #endregion } #endregion #region 將資料寫入TempTable for (int a = 0; a < i_dt_Temp_Result_Count; a++) { DataRow dr_Temp_Result = dt_Temp_Result.NewRow(); #region 左邊主檔資料區 //取第一筆發票的資料 dr_Temp_Result["MAIN_LEFT_0"] = "列印日期:" + s_Print_Date;//列印日期 dr_Temp_Result["MAIN_LEFT_1"] = "列印時間:" + s_Print_Time;//列印時間 dr_Temp_Result["MAIN_LEFT_2"] = Convert.ToString(a + 1) + "/" + i_dt_Temp_Result_Count.ToString();//頁次 dr_Temp_Result["MAIN_LEFT_3"] = dr_Temp_Store[0]["ROUTE"].ToString();//路線 dr_Temp_Result["MAIN_LEFT_4"] = dr_Temp_Store[0]["STEP"].ToString();//路順 dr_Temp_Result["MAIN_LEFT_5"] = dr_Temp_Store[0]["D_SIR_NAME"].ToString();//物流士 dr_Temp_Result["MAIN_LEFT_6"] = dr_Temp_Store[0]["CLOSE_MONTH"].ToString();//結帳年月 dr_Temp_Result["MAIN_LEFT_7"] = dr_Temp_Store[0]["INV_ADDR"].ToString();//地址 dr_Temp_Result["MAIN_LEFT_8"] = dr_Temp_Store[0]["GROUP_NO"].ToString();//店群 dr_Temp_Result["MAIN_LEFT_9"] = dr_Temp_Store[0]["STORE"].ToString();//店號 dr_Temp_Result["MAIN_LEFT_10"] = dr_Temp_Store[0]["STORE_NAME"].ToString();//店名 dr_Temp_Result["MAIN_LEFT_11"] = dr_Temp_Store[0]["STORE_TEL"].ToString();//電話 dr_Temp_Result["MAIN_LEFT_12"] = dr_Temp_Store[0]["AC_UID"].ToString();//帳務人員 dr_Temp_Result["MAIN_LEFT_13"] = dr_Temp_Store[0]["PAY_ACCOUNT"].ToString();//匯款帳號 dr_Temp_Result["MAIN_LEFT_15"] = dr_Temp_Store[0]["SAL_ID"].ToString();//帳務人員 #endregion #region 訊息告知欄位區 dr_Temp_Result["MAIN_LEFT_14"] = strPROMTE;//檔期編號 20110427 rika insert #endregion #region 右邊主檔資料區(印發票的地方) if (s_TAB_Index == "1")//發票對帳單 { #region 規則 /* * 只有頁籤為[發票對帳單]右邊才需要印發票 * 一張發票對帳單右邊有四格印發票的位置 * 每一張發票要印兩小格 * 所以一張發票對帳單只能印兩張發票 */ #endregion #region 設定變數 int i_Temp_Main_Count = 0;//計算第幾筆發票 int i_Right_B = 0; int i_Right_E = 0; string s_VOUCH_RFNO = string.Empty;//統一編號 #endregion #region 將發票資料寫入TempTable for (int b = 0; b < 2; b++) { #region 設定該讀取第幾筆資料 i_Temp_Main_Count = (a * 2) + b; //第一筆資料 if (b == 0) { i_Right_B = 0; i_Right_E = 1; } //第二筆資料 else { i_Right_B = 2; i_Right_E = 3; } #endregion #region 有資料,則顯示資料 if (dr_Temp_Main.Length > i_Temp_Main_Count) { DateTime d_INV_DATE = DateTime.Parse(dr_Temp_Main[i_Temp_Main_Count]["INV_DATE"].ToString()); System.Globalization.TaiwanCalendar g_TaiwanCalendar = new System.Globalization.TaiwanCalendar(); string s_INV_Year = g_TaiwanCalendar.GetYear(d_INV_DATE).ToString(); //發票日期(年) string s_INV_Month = g_TaiwanCalendar.GetMonth(d_INV_DATE).ToString(); //發票日期(月) string s_INV_Date = g_TaiwanCalendar.GetDayOfMonth(d_INV_DATE).ToString(); //發票日期(日) string s_INV_AMT = Conversion_Number(dr_Temp_Main[i_Temp_Main_Count]["INV_AMT"].ToString(), 9); #region 設定統一編號 s_VOUCH_RFNO = Get_VOUCH_RFNO(dr_Temp_Main[i_Temp_Main_Count]["VOUCH_RFNO"].ToString()); #endregion for (int c = i_Right_B; c <= i_Right_E; c++) { decimal decINV_UAMT = decimal.Parse(dr_Temp_Main[i_Temp_Main_Count]["INV_UAMT"].ToString()); decimal decINV_TAX = decimal.Parse(dr_Temp_Main[i_Temp_Main_Count]["INV_TAX"].ToString()); if (dr_Temp_Main[i_Temp_Main_Count]["INV_FORM"].ToString().Trim() == "32") { decINV_UAMT = decINV_UAMT + decINV_TAX; decINV_TAX = 0; } dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_0"] = s_INV_Year;//年 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_1"] = s_INV_Month;//月 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_2"] = s_INV_Date;//日 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_3"] = dr_Temp_Main[i_Temp_Main_Count]["INV_CHKNO"].ToString();//檢查號碼 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_4"] = dr_Temp_Main[i_Temp_Main_Count]["INV_NO"].ToString();//發票號碼 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_5"] = dr_Temp_Main[i_Temp_Main_Count]["TITLE"].ToString();//買受人 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_6"] = s_VOUCH_RFNO;//統一編號 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_7"] = dr_Temp_Main[i_Temp_Main_Count]["ITEM_NAME"].ToString();//品名 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_8"] = decINV_UAMT; dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_9"] = (dr_Temp_Main[i_Temp_Main_Count]["TAX_TYPE"].ToString() == "0") ? "V" : string.Empty;//應稅 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_10"] = (dr_Temp_Main[i_Temp_Main_Count]["TAX_TYPE"].ToString() == "2") ? "V" : string.Empty;//零稅 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_11"] = (dr_Temp_Main[i_Temp_Main_Count]["TAX_TYPE"].ToString() == "1") ? "V" : string.Empty;//免稅 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_12"] = decINV_UAMT.ToString();//銷售額合計 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_13"] = decINV_TAX.ToString();//營業稅 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_14"] = dr_Temp_Main[i_Temp_Main_Count]["INV_AMT"].ToString();//總計 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_23"] = s_INV_AMT.Substring(0, 1);//億 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_15"] = s_INV_AMT.Substring(1, 1);//千萬 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_16"] = s_INV_AMT.Substring(2, 1);//百萬 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_17"] = s_INV_AMT.Substring(3, 1);//十萬 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_18"] = s_INV_AMT.Substring(4, 1);//萬 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_19"] = s_INV_AMT.Substring(5, 1);//千 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_20"] = s_INV_AMT.Substring(6, 1);//百 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_21"] = s_INV_AMT.Substring(7, 1);//拾 dr_Temp_Result["MAIN_RIGHT_" + c.ToString() + "_22"] = s_INV_AMT.Substring(8, 1);//元 } } #endregion #region 沒有資料,則顯示空白 else { dr_Temp_Result["MAIN_RIGHT_" + i_Right_B + "_7"] = "空白";//品名 dr_Temp_Result["MAIN_RIGHT_" + i_Right_E + "_7"] = "空白";//品名 } #endregion } #endregion } #endregion #region 明細資料區 //如果發票主檔中的發票號碼與VDS_CAM_ACCT_CHECK_OUT無相對應資料 //但必須秀出發票的資料,明細部分空白(與秀玲確認無誤) if (dr_Temp_Detl_Purchase != null && dr_Temp_Detl_Return != null) { #region 設定Detl頁首 if (b_IsFinally == false) { #region [群分類][書展][應付款日] dr_Temp_Result["DETL_0_0"] += dr_Temp_Main[0]["ROOT_NO"].ToString().PadRight(10, ' ');//群分類 dr_Temp_Result["DETL_0_0"] += dr_Temp_Main[0]["IS_SCHEDULE"].ToString().PadRight(10, ' ');//書展 dr_Temp_Result["DETL_0_0"] += "應付款日:";//應付款日 TITLE dr_Temp_Result["DETL_0_0"] += (dr_Temp_Main[0]["DUE_DATE"].ToString() == string.Empty) ? " " : DateTime.Parse(dr_Temp_Main[0]["DUE_DATE"].ToString()).ToString("yyyy/MM/dd");//應付款日 dr_Temp_Result["DETL_0_0"] += " "; dr_Temp_Result["DETL_0_0"] += "應付總額:"; dr_Temp_Result["DETL_0_0"] += string.Format("{0:#,0}", i_Total_Inv_Able + i_Total_Inv_Free + i_Total_Inv_Zero).PadLeft(10); #endregion #region 頁首上面[橫線] dr_Temp_Result["DETL_1_0"] = "-----------"; dr_Temp_Result["DETL_1_1"] = "----------------------"; dr_Temp_Result["DETL_1_2"] = "----------------------"; dr_Temp_Result["DETL_1_3"] = "----------------------"; dr_Temp_Result["DETL_1_4"] = "----------------------"; dr_Temp_Result["DETL_1_5"] = "----------------------"; dr_Temp_Result["DETL_1_6"] = "----------------------"; dr_Temp_Result["DETL_1_7"] = "-----|-----"; dr_Temp_Result["DETL_1_8"] = "--------------"; dr_Temp_Result["DETL_1_9"] = "----------------------"; dr_Temp_Result["DETL_1_10"] = "----------------------"; dr_Temp_Result["DETL_1_11"] = "----------------------"; dr_Temp_Result["DETL_1_12"] = "----------------------"; dr_Temp_Result["DETL_1_13"] = "----------------------"; dr_Temp_Result["DETL_1_14"] = "----------------------"; #endregion #region 頁首[標題] dr_Temp_Result["DETL_2_0"] = "日期"; dr_Temp_Result["DETL_2_1"] = "屬性"; dr_Temp_Result["DETL_2_2"] = "稅別"; dr_Temp_Result["DETL_2_3"] = "高見單號"; dr_Temp_Result["DETL_2_4"] = "通路單號"; dr_Temp_Result["DETL_2_5"] = "未稅金額"; dr_Temp_Result["DETL_2_6"] = "含稅金額"; dr_Temp_Result["DETL_2_7"] = "|"; dr_Temp_Result["DETL_2_8"] = "日期"; dr_Temp_Result["DETL_2_9"] = "屬性"; dr_Temp_Result["DETL_2_10"] = "稅別"; dr_Temp_Result["DETL_2_11"] = "高見單號"; dr_Temp_Result["DETL_2_12"] = "通路單號"; dr_Temp_Result["DETL_2_13"] = "未稅金額"; dr_Temp_Result["DETL_2_14"] = "含稅金額"; #endregion #region 頁首下面[橫線] dr_Temp_Result["DETL_3_0"] = "-----------"; dr_Temp_Result["DETL_3_1"] = "----------------------"; dr_Temp_Result["DETL_3_2"] = "----------------------"; dr_Temp_Result["DETL_3_3"] = "----------------------"; dr_Temp_Result["DETL_3_4"] = "----------------------"; dr_Temp_Result["DETL_3_5"] = "----------------------"; dr_Temp_Result["DETL_3_6"] = "----------------------"; dr_Temp_Result["DETL_3_7"] = "-----|-----"; dr_Temp_Result["DETL_3_8"] = "--------------"; dr_Temp_Result["DETL_3_9"] = "----------------------"; dr_Temp_Result["DETL_3_10"] = "----------------------"; dr_Temp_Result["DETL_3_11"] = "----------------------"; dr_Temp_Result["DETL_3_12"] = "----------------------"; dr_Temp_Result["DETL_3_13"] = "----------------------"; dr_Temp_Result["DETL_3_14"] = "----------------------"; #endregion } #endregion #region 設定Detl內容 int i_Actual_Purchase = 0;//進貨實際寫入筆數 int i_Actual_Return = 0;//退貨實際寫入筆數 decimal dec_TOT_AMT_AND_TAX = 0;//計算含稅金額 //i_Detl_Content = Detl內容行數 for (int d = 0; d < i_Detl_Content; d++) { int i_dr_Temp_Detl_Count = a * i_Detl_Content + d; #region 進貨部分 if (dr_Temp_Detl_Purchase.Length > i_dr_Temp_Detl_Count) { #region 計算含稅金額 #region 規則 /* * 原本的規則: * 如果稅別 = 應稅&零稅,含稅金額 = VDS_CAM_ACCT_CHECK_OUT.TOT_AMT + VDS_CAM_ACCT_CHECK_OUT.TOT_AMT_TAX * 如果稅別 = 免稅,含稅金額直接放0 * 20091005 秀玲修改規則 * 不管它的稅別,含稅金額 = VDS_CAM_ACCT_CHECK_OUT.TOT_AMT + VDS_CAM_ACCT_CHECK_OUT.TOT_AMT_TAX */ #endregion dec_TOT_AMT_AND_TAX = decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString()) + decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString()); #endregion #region 寫入資料 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_0"] = DateTime.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["ACCT_DATE"].ToString()).ToString("yyyy/MM/dd");//日期 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_1"] = dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["ACCT_KD"];//屬性 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_2"] = dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TAX_TYPE"];//稅別 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_3"] = dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["EA_NO"];//高見單號 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_4"] = dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["CHAN_SOURCE_NO"];//通路單號 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_5"] = (Math.Abs(decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString())) > 1000000) ? "******" : string.Format("{0:N}", dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"]);//未稅金額 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_6"] = (Math.Abs(dec_TOT_AMT_AND_TAX) > 1000000) ? "******" : string.Format("{0:N}", dec_TOT_AMT_AND_TAX);//含稅金額 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_7"] = "|"; #endregion #region 計算[進貨]的明細最後是寫到哪一行 i_Actual_Purchase = i_Detl_Title + d; #endregion #region 計算[小計]金額 dec_Subtotal_TOT_AMT_Purchase += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//[小計]-進貨未稅金額 dec_Subtotal_TOT_AMT_AND_TAX_Purchase += dec_TOT_AMT_AND_TAX;//[小計]-進貨含稅金額 #endregion #region 計算[單店小計]金額 if (dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "應稅") { dec_Single_Amount_Able += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//單店小計-[應稅]的[合計] dec_Single_Tax_Able += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString());//單店小計-[應稅]的[稅額] } else if (dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "免稅") { dec_Single_Amount_Free += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString()); }//單店小計-[免稅]的[合計] else if (dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "零稅") { dec_Single_Amount_Zero += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//單店小計-[零稅]的[合計] dec_Single_Tax_Zero += decimal.Parse(dr_Temp_Detl_Purchase[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString()); //單店小計-[零稅]的[稅額] } #endregion } #endregion #region 退貨部分 if (dr_Temp_Detl_Return.Length > i_dr_Temp_Detl_Count) { #region 計算含稅金額 #region 規則 /* * 原本的規則: * 如果稅別 = 應稅&零稅,含稅金額 = VDS_CAM_ACCT_CHECK_OUT.TOT_AMT + VDS_CAM_ACCT_CHECK_OUT.TOT_AMT_TAX * 如果稅別 = 免稅,含稅金額直接放0 * 20091005 秀玲修改規則 * 不管它的稅別,含稅金額 = VDS_CAM_ACCT_CHECK_OUT.TOT_AMT + VDS_CAM_ACCT_CHECK_OUT.TOT_AMT_TAX */ #endregion dec_TOT_AMT_AND_TAX = decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString()) + decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString()); #endregion #region 寫入資料 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_7"] = "|"; dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_8"] = DateTime.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["ACCT_DATE"].ToString()).ToString("yyyy/MM/dd");//日期 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_9"] = dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["ACCT_KD"];//屬性 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_10"] = dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TAX_TYPE"];//稅別 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_11"] = dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["EA_NO"];//高見單號 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_12"] = dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["CHAN_SOURCE_NO"];//通路單號 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_13"] = (Math.Abs(decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString())) > 1000000) ? "******" : string.Format("{0:N}", dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"]);//未稅金額 dr_Temp_Result["DETL_" + Convert.ToString(i_Detl_Title + d) + "_14"] = (Math.Abs(dec_TOT_AMT_AND_TAX) > 1000000) ? "******" : string.Format("{0:N}", dec_TOT_AMT_AND_TAX);//含稅金額 #endregion #region 計算[退貨]的明細最後是寫到哪一行 i_Actual_Return = i_Detl_Title + d; #endregion #region 計算[小計]金額 dec_Subtotal_TOT_AMT_Return += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//[小計]-退貨未稅金額 dec_Subtotal_TOT_AMT_AND_TAX_Return += dec_TOT_AMT_AND_TAX;//[小計]-退貨含稅金額 #endregion #region 計算[單店小計]金額 if (dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "應稅") { dec_Single_Amount_Able += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//單店小計-[應稅]的[合計] dec_Single_Tax_Able += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString());//單店小計-[應稅]的[稅額] } else if (dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "免稅") { dec_Single_Amount_Free += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString()); }//單店小計-[免稅]的[合計] else if (dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TAX_TYPE"].ToString() == "零稅") { dec_Single_Amount_Zero += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT"].ToString());//單店小計-[零稅]的[合計] dec_Single_Tax_Zero += decimal.Parse(dr_Temp_Detl_Return[i_dr_Temp_Detl_Count]["TOT_AMT_TAX"].ToString()); //單店小計-[零稅]的[稅額] } #endregion } #endregion } #endregion #region 設定Detl頁尾[小計]&[單店小計]&[總計] #region 規則 /* * 單店小計中發票總額的計算方式,必須與昭宜開立發票的程式相同 * 與昭宜確認過 * 發票總額的計算方式= * (1)所有明細資料的 VDS_CAM_ACCT_CHECK_OUT.TOT_AMT 先加總後,四捨五入的金額 * 加上 * (2)所有明細資料的 VDS_CAM_ACCT_CHECK_OUT.TOT_AMT_TAX 先加總後,四捨五入的金額 */ #endregion //取得Detl頁尾[小計]&[單店小計]&[總計]從哪一行開始 int i_Detl_Subtotal_Begin = ((i_Actual_Purchase > i_Actual_Return) ? i_Actual_Purchase : i_Actual_Return) + 1; //判斷是否為最後一筆 if ((i_Detl_Content * a + i_Detl_Subtotal_Begin - i_Detl_Title == ((dr_Temp_Detl_Purchase.Length > dr_Temp_Detl_Return.Length) ? dr_Temp_Detl_Purchase.Length : dr_Temp_Detl_Return.Length)) || (b_IsFinally == true)) { //i_Detl_Count = Detl明細資料總共有幾行(包含[頁首][內容][頁尾小計][頁尾總計]) //i_Detl_Subtotal = Detl頁尾小計有幾行 int i_Detl_Total_Begin = 0;//紀錄Detl頁尾[小計]&[單店小計]&[總計]從哪一行開始 int i_Actual_Detl_Total_Begin = 0;//設定[小計]&[單店小計]&[總計]是要在哪一行 int i_Original_i_Actual_Total = 0;//若是這一頁是只印[小計]&[單店小計]&[總計]部分,這個變數紀錄上一頁是印到第幾筆 if (b_IsFinally == true) { i_Original_i_Actual_Total = i_Actual_Total; } else { i_Detl_Total_Begin = i_Detl_Subtotal_Begin; } #region 小計 #region [小計]上方那一條線 if ((i_Detl_Total_Begin + 0 < i_Detl_Count) && (i_Actual_Total < 1)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 0; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] = "--------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_1"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_2"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_3"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_4"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_5"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_6"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_7"] = "-----|-----"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_8"] = "--------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_9"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_10"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_11"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_12"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_13"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_14"] = "----------------------"; i_Actual_Total = 1; } #endregion #region [小計]資料 if ((i_Detl_Total_Begin + 1 < i_Detl_Count) && (i_Actual_Total < 2)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 1; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] = "小計"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_5"] = (Math.Abs(dec_Subtotal_TOT_AMT_Purchase) > 1000000) ? "******" : string.Format("{0:N}", dec_Subtotal_TOT_AMT_Purchase);//進貨[未稅金額]小計 dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_6"] = (Math.Abs(dec_Subtotal_TOT_AMT_AND_TAX_Purchase) > 1000000) ? "******" : string.Format("{0:N}", dec_Subtotal_TOT_AMT_AND_TAX_Purchase);//進貨[含稅金額]小計 dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_7"] = "|"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_13"] = (Math.Abs(dec_Subtotal_TOT_AMT_Return) > 1000000) ? "******" : string.Format("{0:N}", dec_Subtotal_TOT_AMT_Return);//退貨[未稅金額]小計 dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_14"] = (Math.Abs(dec_Subtotal_TOT_AMT_AND_TAX_Return) > 1000000) ? "******" : string.Format("{0:N}", dec_Subtotal_TOT_AMT_AND_TAX_Return);//退貨[含稅金額]小計 i_Actual_Total = 2; } #endregion #region [小計]下方那一條線 if ((i_Detl_Total_Begin + 2 < i_Detl_Count) && (i_Actual_Total < 3)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 2; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] = "--------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_1"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_2"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_3"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_4"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_5"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_6"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_7"] = "-----|-----"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_8"] = "--------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_9"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_10"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_11"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_12"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_13"] = "----------------------"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_14"] = "----------------------"; i_Actual_Total = 3; } #endregion #endregion #region 單店小計 if ((i_Detl_Total_Begin + 3 < i_Detl_Count) && (i_Actual_Total < 4)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 3; } //注意:[應稅 合計:$]中間的空白,是[全型]的空白 dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "單店小計".PadRight(4, ' '); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(39); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "應稅 :未稅金額"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Able, MidpointRounding.AwayFromZero)).PadLeft(10); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "稅額:$"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Tax_Able, MidpointRounding.AwayFromZero)).PadLeft(10); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); if (dec_Single_Amount_Able < 0) { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; } else { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Able, MidpointRounding.AwayFromZero) + System.Math.Round(dec_Single_Tax_Able, MidpointRounding.AwayFromZero)).PadLeft(10); i_Actual_Total = 4; } if ((i_Detl_Total_Begin + 4 < i_Detl_Count) && (i_Actual_Total < 5)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 4; } //注意:[免稅 合計:$]中間的空白,是[全型]的空白 dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(4, ' '); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(39); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "免稅 :未稅金額"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Free, MidpointRounding.AwayFromZero)).PadLeft(10); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadLeft(8); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadLeft(10); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); if (dec_Single_Amount_Free < 0) { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; } else { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Free, MidpointRounding.AwayFromZero)).PadLeft(10); i_Actual_Total = 5; } if ((i_Detl_Total_Begin + 5 < i_Detl_Count) && (i_Actual_Total < 6)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 5; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(4, ' '); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(39); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "零稅率:未稅金額"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Zero, MidpointRounding.AwayFromZero)).PadLeft(10); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "稅額:$"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Tax_Zero, MidpointRounding.AwayFromZero)).PadLeft(10); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); if (dec_Single_Amount_Zero < 0) { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; } else { dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總額:$"; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", System.Math.Round(dec_Single_Amount_Zero, MidpointRounding.AwayFromZero) + System.Math.Round(dec_Single_Tax_Zero, MidpointRounding.AwayFromZero)).PadLeft(10); i_Actual_Total = 6; } #endregion #region 中間空一行 if ((i_Detl_Total_Begin + 6 < i_Detl_Count) && (i_Actual_Total < 7)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 6; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] = string.Empty; i_Actual_Total = 7; } #endregion #region 總計 if ((i_Detl_Total_Begin + 7 < i_Detl_Count) && (i_Actual_Total < 8)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 7; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "總計".PadRight(4, ' '); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "應稅發票號碼 :"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += (s_INV_NO_Able.Length > 22) ? s_INV_NO_Able.Substring(0, 21) : s_INV_NO_Able.PadRight(21); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(2); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "應稅 :未稅金額"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Amount_Able).PadLeft(10);//總計-[應稅]的[未稅金額] dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "稅額:$"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Tax_Able).PadLeft(10);//總計-[應稅]的[稅額] dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "發票總額:$"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Inv_Able).PadLeft(10);//總計-[應稅]的[發票總額] i_Actual_Total = 8; } if ((i_Detl_Total_Begin + 8 < i_Detl_Count) && (i_Actual_Total < 9)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 8; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(4, ' '); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "免稅發票號碼 :"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += (s_INV_NO_Free.Length > 22) ? s_INV_NO_Free.Substring(0, 21) : s_INV_NO_Free.PadRight(21); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(2); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "免稅 :未稅金額"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Amount_Free).PadLeft(10);//總計-[免稅]的[未稅金額] dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadLeft(8); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadLeft(10); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "發票總額:$"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Inv_Free).PadLeft(10);//總計-[免稅]的[發票總額] i_Actual_Total = 9; } if ((i_Detl_Total_Begin + 9 < i_Detl_Count) && (i_Actual_Total < 10)) { if (b_IsFinally == true) { i_Actual_Detl_Total_Begin = i_Actual_Total - i_Original_i_Actual_Total; } else { i_Actual_Detl_Total_Begin = i_Detl_Total_Begin + 9; } dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(4, ' '); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "零稅率發票號碼:"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += (s_INV_NO_Zero.Length > 22) ? s_INV_NO_Zero.Substring(0, 21) : s_INV_NO_Zero.PadRight(21); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(2); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "零稅率:未稅金額"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Amount_Zero).PadLeft(10);//總計-[零稅]的[未稅金額] dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "稅額:$"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Tax_Zero).PadLeft(10);//總計-[零稅]的[稅額] dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Empty.PadRight(5); dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += "發票總額:$"; dr_Temp_Result["DETL_" + i_Actual_Detl_Total_Begin.ToString() + "_0"] += string.Format("{0:#,0}", i_Total_Inv_Zero).PadLeft(10);//總計-[零稅]的[發票總額] i_Actual_Total = 10; } #endregion //設定明細資料是否為最後一筆 b_IsFinally = true; } #endregion } #endregion dt_Temp_Result.Rows.Add(dr_Temp_Result); } #endregion } #endregion return dt_Temp_Result; }