Bez popisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Main.cs 138KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using NUnit.Framework.Constraints;
  6. using TMPro;
  7. using Unity.Mathematics;
  8. using Unity.VisualScripting;
  9. using System.Text.RegularExpressions;
  10. using UnityEngine;
  11. using UnityEngine.SceneManagement;
  12. using UnityEngine.UI;
  13. using UnityEngine.Video;
  14. using System.Linq;
  15. public class Main : MonoBehaviour{
  16. [SerializeField] TextMeshProUGUI 使用者_tb,日期_tb,彈跳文字_tb,報告書流水號_tb,報告書扶手總長_tb,報告書申請人_tb,報告書開立人_tb,提示_tb,圖片讀取_tb,相片目前_tb,相片總數_tb,
  17. 扶手已使用長度_tb,扶手可使用長度_tb,輸入單項扶手總長度_tb,單項扶手長度_tb,扶手總長2_lb,扶手長度_lb,請輸入扶手總長度_lb,扶手總長度_lb,已使用扶手長度_lb,可使用扶手長度_lb,
  18. 扶手長度2_lb,項目清單2_lb,更換照片提示_tb,評估主頁抬頭_tb,報告書人員資料_申請人_tb,報告書人員資料_客編_tb,報告書人員資料_聯繫人_tb,報告書人員資料_聯繫人電話_tb,
  19. 報告書人員資料_地址_tb,報告書人員資料_聯繫人2_tb,報告書人員資料_聯繫人2電話_tb,報告書項目清單_報告書號_tb,報告書新增客編_tb,相關文件相片總數_tb,相關文件相片目前_tb,
  20. 施作圖片相片總數_tb,施作圖片相片目前_tb,施作圖片相片文件號_tb,文件圖片相片文件號_tb,施工前_tb,施工後_tb;
  21. [SerializeField] GameObject 背景_pl,首頁_pl,系統設定_pl,彈跳_pl,評估_pl,表頭_pl,複製體1,複製體2,評估主頁_pl,評估詳細_pl,拍照頁面_pl,評估紀錄_pl,圖片讀取_pl,新建_pl,選擇客戶_pl,
  22. 客戶清單表頭_pl,報告書圖片_pl,新增項目_pl,文件號_sv,項目清單_sv,報告書資料_pl,項目清單_lb,長照類_sv,圖片寬度_pl,頁面高度_pl,扶手總長_lb,扶手總長_tb,輸入扶手長度_pl,
  23. 輸入單項扶手長度_pl,備註_pl,更換照片_pl,報告書_pl,新客戶_pl,小工具_pl,倍瑞菲_pl,系統設定2_pl,主頁_pl,大主頁_pl,查詢_pl, 報告書人員清單_pl,報告書人員資料_pl,表頭2_pl,
  24. 報告書項目清單_pl,報告書新增人員_pl,報告書人員清單_年份_cb,報告書文件圖片讀取_pl,報告書文件圖片寬度_pl,報告書文件圖片_pl,施作項目_lb,施作項目_sv,施作圖片_pl,
  25. 評估報告書1_物料清單_sv,施作圖片圖片讀取_pl,施作圖片圖片寬度_pl;
  26. [SerializeField] GameObject 長照類_bt,身障類_bt,自費類_bt,返回3_bt,發送通知_bt,回選單_bt,新增項目_bt,刪除項目_bt,更換照片資料夾_bt,更換照片文件號_bt,更換照片確認_bt,
  27. 更換照片取消_bt,更換照片拍照確認_bt,核銷文件_bt,更換照片_bt,刪除照片_bt,業務系統_bt,系統設定_bt,施工前_bt,施工後_bt,拍照_bt,回上頁_bt,文件號_bt,返回8_bt,
  28. 長照類_相關文件_bt,長照類_核定通知書_bt,長照類_評估報告書1_bt,長照類_評估報告書2_bt,返回4_bt,長照類_申請人身分證反面_bt,長照類_受託人身分證反面_bt,長照類_所有權人身分證反面_bt,
  29. 長照類_房屋所有權狀_bt,長照類_土地所有權狀_bt,長照類_房屋稅籍證明_bt,長照類_土地稅籍證明_bt,長照類_房屋稅單_bt,長照類_土地稅單_bt,返回5_bt,拍照1_bt,刪除1_bt,存檔1_bt,返回1_bt,
  30. 返回2_bt,返回2_1_bt,查詢1_bt,新增客戶1_bt,長照類_申請人身心障礙證明_bt,拍照_文件號_bt,拍照_施工前_bt,拍照_施工後_bt,拍照_申請人身分證正反面_bt,拍照_委託人身分證正反面_bt,
  31. 拍照_所有權人身分證正反面_bt, 拍照_申請人身心障礙證明正反面_bt,拍照_房屋所有權狀_bt,拍照_土地所有權狀_bt,拍照_房屋稅籍證明_bt,拍照_土地稅籍證明_bt,拍照_房屋稅單_bt,
  32. 拍照_土地稅單_bt,施作項目_新增_bt,施作項目_刪除_bt,返回6_bt,返回7_bt,拍照_評估報告書1_bt,備註_bt,拍照_評估報告書2_bt,長照類_案場1_bt,長照類_案場2_bt,長照類_案場3_bt,
  33. 施作顯示_tb,存檔2_bt,拍照_核定通知書_bt,拍照_案場1_bt,拍照_案場2_bt,拍照_案場3_bt,產品序號_bt,彈跳是_bt,彈跳否_bt;
  34. [SerializeField] Image 施工前_img,施工後_img,產品序號_img,文件圖片_img,施作圖片_img;
  35. [SerializeField] TMP_InputField 輸入扶手總長_tb,扶手長度_tb,備註_tb,報告書查詢1_tb,報告書新增申請人_tb,報告書新增住址_tb,報告書新增電話_tb,報告書新增聯繫人_tb,
  36. 報告書新增聯繫人電話_tb,報告書新增聯繫人2_tb,報告書新增聯繫人2電話_tb,施作_tb;
  37. [SerializeField] RawImage 拍照用,放圖用,更換照片放圖用,更換照片拍照用,文件圖片_rawimage,施作圖片_rawimage;
  38. //[SerializeField] GridLayoutGroup gridLayout;
  39. private WebCamTexture myCam;
  40. public TMP_FontAsset myFont;
  41. public Sprite UIsprite;
  42. public Transform 報告書人員清單_tp;public GameObject 報告書人員清單_rpf;public GameObject 報告書人員清單_ct;public GameObject 報告書人員清單_lpf;
  43. public Transform 報告書清單_tp;public GameObject 報告書清單_rpf;public GameObject 報告書清單_ct;public GameObject 報告書清單_lpf;
  44. public Transform 文件號清單_tp;public GameObject 文件號清單_rpf;public GameObject 文件號清單_ct;public GameObject 文件號清單_lpf;
  45. public Transform 報告書項目清單_tp;public GameObject 報告書項目清單_rpf;public GameObject 報告書項目清單_ct;public GameObject 報告書項目清單_lpf;
  46. public Transform 報告書施工圖片_tp;public GameObject 報告書施工圖片_rpf;public GameObject 報告書施工圖片_ct;public GameObject 報告書施工圖片_lpf;
  47. public Transform 客戶清單_tp;public GameObject 客戶清單_rpf;public GameObject 客戶清單_ct;public GameObject 客戶清單_lpf;
  48. public Transform 長照物料清單_tp;public GameObject 長照物料清單_rpf;public GameObject 長照物料清單_ct;public GameObject 長照物料清單_lpf;
  49. public Transform 報告書施作項目清單_tp;public GameObject 報告書施作項目清單_rpf;public GameObject 報告書施作項目清單_ct;public GameObject 報告書施作項目清單_lpf;
  50. public Transform 報告書施作圖片_物料清單_tp;public GameObject 報告書施作圖片_物料清單_rpf;public GameObject 報告書施作圖片_物料清單_ct;public GameObject 報告書施作圖片_物料清單_lpf;
  51. public SQL_LINE sql_line;
  52. public CanvasScaler canvasScaler;
  53. float screenWidth,screenHeight;
  54. private string loadingText = "";
  55. private string 目前階段 = "",目前階段2="";
  56. private Texture2D currentTexture;
  57. private int dotCount = 0;
  58. void Start(){
  59. Screen.autorotateToPortrait = false;
  60. Screen.orientation = ScreenOrientation.Portrait;
  61. screenWidth = Screen.width;
  62. screenHeight = Screen.height;
  63. float rate = 900.0f / 1900.0f;
  64. if (canvasScaler == null)
  65. {
  66. canvasScaler = GetComponent<CanvasScaler>();
  67. }
  68. if (Screen.width<Screen.height)
  69. {
  70. Main.Global.rate = screenWidth/screenHeight;
  71. Main.Global.rate_ = 1/Main.Global.rate;
  72. if (Main.Global.rate>rate)
  73. {
  74. canvasScaler.matchWidthOrHeight = 1f;
  75. }
  76. else
  77. {
  78. canvasScaler.matchWidthOrHeight = 0f;
  79. }
  80. }
  81. else
  82. {
  83. Main.Global.rate_ = screenWidth/screenHeight;
  84. Main.Global.rate = 1/Main.Global.rate_;
  85. if (Main.Global.rate>rate)
  86. {
  87. canvasScaler.matchWidthOrHeight = 1f;
  88. }
  89. else
  90. {
  91. canvasScaler.matchWidthOrHeight = 0f;
  92. }
  93. }
  94. DateTime today = DateTime.Today;
  95. 使用者_tb.text = Global.使用者暱稱;
  96. 日期_tb.text = today.Year.ToString().PadLeft(2,'0')+" 年 "+today.Month.ToString().PadLeft(2,'0')+" 月 "+today.Day.ToString().PadLeft(2,'0')+" 日 "+ GetChineseDayOfWeek(today.DayOfWeek);
  97. Global.複製體1 = 複製體1;Global.複製體2 = 複製體2;
  98. StartCoroutine(AnimateText());
  99. }
  100. void Update(){
  101. }
  102. public void 系統設定2_bt(){
  103. 主頁_pl.SetActive(false);系統設定2_pl.SetActive(true);
  104. }
  105. public void 回主頁_bt(){
  106. 主頁_pl.SetActive(true);系統設定2_pl.SetActive(false);
  107. }
  108. public void 報告書_pl_bt(){
  109. 大主頁_pl.SetActive(false);主頁_pl.SetActive(false);系統設定2_pl.SetActive(false);報告書_pl.SetActive(true);
  110. 評估_pl.SetActive(true);新建_pl.SetActive(false);報告書新增人員_pl.SetActive(false);查詢1_bt.SetActive(true);新增客戶1_bt.SetActive(true);
  111. 報告書人員清單_年份_cb.GetComponent<TMP_Dropdown>().ClearOptions();
  112. List<string> yearList = new();
  113. int currentYear = DateTime.Now.Year;
  114. int defaultIndex = 0;
  115. SQL_Comm.SQL_客戶資料表_年份();
  116. while (SQL_Module.dr.Read()){
  117. string yearStr = SQL_Module.dr["年份"].ToString();
  118. yearList.Add(yearStr);
  119. if (yearStr == currentYear.ToString()) {
  120. defaultIndex = yearList.Count - 1;
  121. }
  122. }
  123. 報告書人員清單_年份_cb.GetComponent<TMP_Dropdown>().AddOptions(yearList);
  124. 報告書人員清單_年份_cb.GetComponent<TMP_Dropdown>().value=defaultIndex;
  125. 報告書人員清單_年份_cb.GetComponent<TMP_Dropdown>().RefreshShownValue();
  126. Set_報告書人員清單("");
  127. }
  128. public void 報告書返回1(){
  129. 大主頁_pl.SetActive(true);主頁_pl.SetActive(false);系統設定2_pl.SetActive(false);報告書_pl.SetActive(false);
  130. }
  131. public void 報告書清單返回1(){
  132. 大主頁_pl.SetActive(true);主頁_pl.SetActive(true);系統設定2_pl.SetActive(false);報告書_pl.SetActive(false);
  133. }
  134. public void 報告書清單返回2(){
  135. 報告書人員清單_pl.SetActive(true);報告書人員資料_pl.SetActive(false);報告書項目清單_pl.SetActive(false);報告書新增人員_pl.SetActive(false);
  136. 返回1_bt.SetActive(true);查詢1_bt.SetActive(true);新增客戶1_bt.SetActive(true);返回2_bt.SetActive(false);返回2_1_bt.SetActive(false);
  137. }
  138. public void 報告書清單返回3(){
  139. 報告書人員清單_pl.SetActive(false);報告書人員資料_pl.SetActive(true);報告書項目清單_pl.SetActive(false);
  140. 返回2_bt.SetActive(true);返回3_bt.SetActive(false);
  141. }
  142. public void 報告書清單返回4(){
  143. 長照類_bt.SetActive(true);身障類_bt.SetActive(true);自費類_bt.SetActive(true);返回3_bt.SetActive(true);
  144. 長照類_核定通知書_bt.SetActive(false);長照類_相關文件_bt.SetActive(false);長照類_評估報告書1_bt.SetActive(false);
  145. 長照類_評估報告書2_bt.SetActive(false);返回4_bt.SetActive(false);
  146. }
  147. public void 報告書清單返回8(){
  148. 長照類_bt.SetActive(true);身障類_bt.SetActive(true);自費類_bt.SetActive(true);返回3_bt.SetActive(true);
  149. 長照類_案場1_bt.SetActive(false);長照類_案場2_bt.SetActive(false);長照類_案場3_bt.SetActive(false);返回8_bt.SetActive(false);
  150. }
  151. public void 報告書清單返回5(){
  152. 長照類_核定通知書_bt.SetActive(true);長照類_相關文件_bt.SetActive(true);長照類_評估報告書1_bt.SetActive(true);
  153. 長照類_評估報告書2_bt.SetActive(true);返回4_bt.SetActive(true);
  154. 長照類_申請人身分證反面_bt.SetActive(false);長照類_受託人身分證反面_bt.SetActive(false);長照類_所有權人身分證反面_bt.SetActive(false);
  155. 長照類_房屋所有權狀_bt.SetActive(false);長照類_土地所有權狀_bt.SetActive(false);長照類_房屋稅籍證明_bt.SetActive(false);長照類_土地稅籍證明_bt.SetActive(false);
  156. 長照類_房屋稅單_bt.SetActive(false);長照類_土地稅單_bt.SetActive(false);返回5_bt.SetActive(false);拍照1_bt.SetActive(false);刪除1_bt.SetActive(false);
  157. 存檔1_bt.SetActive(false);報告書文件圖片_pl.SetActive(false);長照類_申請人身心障礙證明_bt.SetActive(false);
  158. RectTransform rt = 報告書文件圖片_pl.GetComponent<RectTransform>();
  159. rt.offsetMax = new Vector2(rt.offsetMax.x, -706.66f);
  160. }
  161. public void 報告書清單搜尋1(){
  162. 查詢_pl.SetActive(true);報告書查詢1_tb.text="";
  163. }
  164. public void 報告書清單搜尋確認1(){
  165. 查詢_pl.SetActive(false);string 搜尋條件 = " AND (客戶資料表.負責人 LIKE N'%" + 報告書查詢1_tb.text + "%' OR 客戶資料表.聯繫人1 LIKE N'%" + 報告書查詢1_tb.text + "%') ";
  166. Set_報告書人員清單(搜尋條件);
  167. }
  168. public void 主頁新增(){
  169. 大主頁_pl.SetActive(false);主頁_pl.SetActive(false);系統設定2_pl.SetActive(false);報告書_pl.SetActive(true);
  170. 評估_pl.SetActive(true);新建_pl.SetActive(false);
  171. Global.主頁新增=true;
  172. 真新增();
  173. }
  174. private void 真新增(){
  175. 報告書新增人員_pl.SetActive(true);報告書新增客編_tb.text="";報告書新增申請人_tb.text="";報告書新增住址_tb.text="";報告書新增電話_tb.text="";報告書新增聯繫人_tb.text="";
  176. 報告書新增聯繫人電話_tb.text="";
  177. 報告書人員清單_pl.SetActive(false);報告書人員資料_pl.SetActive(true);報告書項目清單_pl.SetActive(false);
  178. 評估主頁抬頭_tb.text = "";報告書人員資料_申請人_tb.text = "";報告書人員資料_客編_tb.text = "";報告書人員資料_聯繫人_tb.text = "";
  179. 報告書人員資料_聯繫人電話_tb.text = "";報告書人員資料_地址_tb.text = "";報告書人員資料_聯繫人2_tb.text="";報告書人員資料_聯繫人2電話_tb.text="";
  180. 返回1_bt.SetActive(false);查詢1_bt.SetActive(false);新增客戶1_bt.SetActive(false);
  181. if(Global.主頁新增){
  182. 返回2_bt.SetActive(false);返回2_1_bt.SetActive(true);
  183. }else{
  184. 返回2_bt.SetActive(true);返回2_1_bt.SetActive(false);
  185. }
  186. string 加盟商代號;
  187. SQL_Comm.SQL_載入供應商代號(Global.gUser區域);
  188. if(SQL_Module.dr.Read()){
  189. 加盟商代號=SQL_Module.dr["加盟商代號"].ToString();
  190. }else{
  191. 加盟商代號 = "CN";
  192. }
  193. SQL_Comm.SQL_客戶資料表_最後一筆資料(Global.gUser區域);
  194. if (SQL_Module.dr.Read()){
  195. 報告書新增客編_tb.text = SQL_Module.dr["流水號"].ToString();
  196. }else{
  197. 報告書新增客編_tb.text = $"{加盟商代號}{DateTime.Today:yyMM}000";
  198. }
  199. string 年份 = DateTime.Today.ToString("yy");
  200. string 月份 = DateTime.Today.ToString("MM");
  201. if (報告書新增客編_tb.text.Length >= 加盟商代號.Length + 4){
  202. if (報告書新增客編_tb.text.Substring(加盟商代號.Length, 2) == 年份 && 報告書新增客編_tb.text.Substring(加盟商代號.Length + 2, 2) == 月份){
  203. string lastThreeDigits = 報告書新增客編_tb.text[^3..];
  204. if (int.TryParse(lastThreeDigits, out int num)){
  205. num += 1;
  206. 報告書新增客編_tb.text = $"{加盟商代號}{年份}{月份}{num:000}";
  207. }else{
  208. 報告書新增客編_tb.text = $"{加盟商代號}{年份}{月份}001";
  209. }
  210. }else{
  211. 報告書新增客編_tb.text = $"{加盟商代號}{年份}{月份}001";
  212. }
  213. }else{
  214. 報告書新增客編_tb.text = $"{加盟商代號}{年份}{月份}001";
  215. }
  216. }
  217. public void 報告書清單新增人員1(){
  218. Global.主頁新增=false;真新增();
  219. }
  220. public void 報告書清單確認新增1(){
  221. 報告書新增人員_pl.SetActive(false);報告書人員資料_客編_tb.text = 報告書新增客編_tb.text;報告書人員資料_申請人_tb.text = 報告書新增申請人_tb.text;
  222. 報告書人員資料_聯繫人_tb.text = 報告書新增聯繫人_tb.text;報告書人員資料_聯繫人電話_tb.text = 報告書新增聯繫人電話_tb.text;報告書人員資料_地址_tb.text = 報告書新增住址_tb.text;
  223. 報告書人員資料_聯繫人2_tb.text = 報告書新增聯繫人2_tb.text;報告書人員資料_聯繫人2電話_tb.text = 報告書新增聯繫人2電話_tb.text;
  224. SQL_Comm.SQL_客戶資料表_新增(報告書人員資料_客編_tb.text,DateTime.Today.ToString("yyyy/MM/dd"),"","",報告書人員資料_地址_tb.text,報告書人員資料_申請人_tb.text,
  225. Global.gUserName,報告書人員資料_聯繫人_tb.text,報告書人員資料_聯繫人電話_tb.text,"","",Global.gUser區域,"","",報告書人員資料_聯繫人2_tb.text,
  226. 報告書人員資料_聯繫人2電話_tb.text,"","","","");
  227. 報告書人員清單_年份_cb.GetComponent<TMP_Dropdown>().ClearOptions();
  228. List<string> yearList = new();
  229. int currentYear = DateTime.Now.Year;
  230. int defaultIndex = 0;
  231. SQL_Comm.SQL_客戶資料表_年份();
  232. while (SQL_Module.dr.Read()){
  233. string yearStr = SQL_Module.dr["年份"].ToString();
  234. yearList.Add(yearStr);
  235. if (yearStr == currentYear.ToString()) {
  236. defaultIndex = yearList.Count - 1;
  237. }
  238. }
  239. 報告書人員清單_年份_cb.GetComponent<TMP_Dropdown>().AddOptions(yearList);
  240. 報告書人員清單_年份_cb.GetComponent<TMP_Dropdown>().value=defaultIndex;
  241. 報告書人員清單_年份_cb.GetComponent<TMP_Dropdown>().RefreshShownValue();
  242. Set_報告書人員清單("");
  243. }
  244. public void 報告書新增報告書(){
  245. double NUM1;string dat1;string 報告書號;string 圖檔資料庫="";
  246. Set_日期格式轉換();
  247. SQL_Comm.SQL_取得加盟商編號(Global.gUser區域);
  248. if(SQL_Module.dr.Read()){
  249. Global.gUser加盟商編號=SQL_Module.dr[0].ToString();
  250. }else{
  251. Global.gUser加盟商編號="未設定加盟商";
  252. }
  253. SQL_Comm.SQL_報告書_查詢流水號(Global.gUser區域);
  254. if(SQL_Module.dr.Read()){
  255. 報告書號 = SQL_Module.dr["流水號"].ToString();
  256. }else{
  257. 報告書號 = "RE" + Global.DTP1[2..] + "00-" + Global.gUser加盟商編號;
  258. }
  259. dat1 = 報告書號.Substring(2, 6);
  260. if(dat1 != Global.DTP1[2..]){
  261. NUM1 = 1;
  262. }else{
  263. NUM1 = double.Parse(報告書號.Substring(8, 2)) + 1;
  264. }
  265. 報告書號 = "RE" + Global.DTP1[2..] + NUM1.ToString().PadLeft(2, '0') + "-" + Global.gUser加盟商編號;
  266. SQL_Comm.SQL_查詢圖檔資料庫();
  267. if(SQL_Module.dr.Read()){
  268. 圖檔資料庫 = SQL_Module.dr[0].ToString();
  269. SQL_Comm.SQL_報告書_新增(報告書號, 報告書人員資料_客編_tb.text, DateTime.Today.ToString("yyyy/MM/dd"), Global.gUserName, Global.gUser區域, 圖檔資料庫);
  270. Set_報告書清單(報告書人員資料_客編_tb.text,報告書人員資料_申請人_tb.text,報告書人員資料_聯繫人_tb.text,報告書人員資料_聯繫人電話_tb.text,報告書人員資料_地址_tb.text,報告書人員資料_聯繫人2_tb.text,報告書人員資料_聯繫人2電話_tb.text);
  271. }
  272. }
  273. public void 報告書清單拍照1(){
  274. 拍照頁面_pl.SetActive(true);
  275. 拍照_文件號_bt.SetActive(false);拍照_施工前_bt.SetActive(false);拍照_施工後_bt.SetActive(false);拍照_申請人身分證正反面_bt.SetActive(false);拍照_委託人身分證正反面_bt.SetActive(false);
  276. 拍照_所有權人身分證正反面_bt.SetActive(false);拍照_申請人身心障礙證明正反面_bt.SetActive(false);拍照_房屋所有權狀_bt.SetActive(false);拍照_土地所有權狀_bt.SetActive(false);
  277. 拍照_房屋稅籍證明_bt.SetActive(false);拍照_土地稅籍證明_bt.SetActive(false);拍照_房屋稅單_bt.SetActive(false);拍照_土地稅單_bt.SetActive(false);拍照_評估報告書2_bt.SetActive(false);
  278. 拍照_評估報告書1_bt.SetActive(false);拍照_案場1_bt.SetActive(false);拍照_案場2_bt.SetActive(false);拍照_案場3_bt.SetActive(false);拍照_核定通知書_bt.SetActive(false);
  279. if(Global.報告書選項2 =="評估報告書1"){
  280. 拍照_評估報告書1_bt.SetActive(true);
  281. }else if(Global.報告書選項2 =="評估報告書2"){
  282. 拍照_評估報告書2_bt.SetActive(true);
  283. }else if(Global.報告書選項2 =="核定通知書"){
  284. 拍照_核定通知書_bt.SetActive(true);
  285. }else if(Global.報告書選項2 =="案場1"){
  286. 拍照_案場1_bt.SetActive(true);
  287. }else if(Global.報告書選項2 =="案場2"){
  288. 拍照_案場2_bt.SetActive(true);
  289. }else if(Global.報告書選項2 =="案場3"){
  290. 拍照_案場3_bt.SetActive(true);
  291. }else{
  292. if(Global.報告書選項3 =="申請人身分證正反面"){拍照_申請人身分證正反面_bt.SetActive(true);}
  293. else if(Global.報告書選項3 =="委託人身分證正反面"){拍照_委託人身分證正反面_bt.SetActive(true);}
  294. else if(Global.報告書選項3 =="所有權人身分證正反面"){拍照_所有權人身分證正反面_bt.SetActive(true);}
  295. else if(Global.報告書選項3 =="申請人身心障礙證明正反面"){拍照_申請人身心障礙證明正反面_bt.SetActive(true);}
  296. else if(Global.報告書選項3 =="房屋所有權狀"){拍照_房屋所有權狀_bt.SetActive(true);}
  297. else if(Global.報告書選項3 =="土地所有權狀"){拍照_土地所有權狀_bt.SetActive(true);}
  298. else if(Global.報告書選項3 =="房屋稅籍證明"){拍照_房屋稅籍證明_bt.SetActive(true);}
  299. else if(Global.報告書選項3 =="土地稅籍證明"){拍照_土地稅籍證明_bt.SetActive(true);}
  300. else if(Global.報告書選項3 =="房屋稅單"){拍照_房屋稅單_bt.SetActive(true);}
  301. else if(Global.報告書選項3 =="土地稅單"){拍照_土地稅單_bt.SetActive(true);}
  302. }
  303. StartCoroutine(open_Camera(60));
  304. 提示_tb.text ="拍照中";
  305. //拍照2(Global.報告書選項3);
  306. 拍照用.gameObject.SetActive(true);
  307. 放圖用.gameObject.SetActive(false);
  308. }
  309. private Texture2D 鏡像圖片(Texture2D original){
  310. Texture2D flipped = new(original.width, original.height);
  311. for (int y = 0; y < original.height; y++){
  312. flipped.SetPixels(0, y, original.width, 1, original.GetPixels(0, original.height - 1, original.width, 1));
  313. }
  314. flipped.Apply();
  315. return flipped;
  316. }
  317. public void 拍照2(string 階段){
  318. if (拍照用.gameObject.activeSelf && !放圖用.gameObject.activeSelf){
  319. Texture2D photo = new Texture2D(myCam.width, myCam.height);
  320. photo.SetPixels(myCam.GetPixels());
  321. photo.Apply();
  322. Texture2D 上傳圖 = RotateTexture(photo, true);
  323. Texture2D 鏡像後 = 鏡像圖片(photo);
  324. 放圖用.rectTransform.sizeDelta = new Vector2(720f, 1280f);
  325. 放圖用.texture = 鏡像後;
  326. byte[] imageBytes = 上傳圖.EncodeToPNG();
  327. SQL_Comm.SQL_取得報告書資料(報告書流水號_tb.text);
  328. if (SQL_Module.dr.Read()){
  329. Global.圖檔資料庫 = SQL_Module.dr["圖檔資料庫"].ToString();
  330. SQL_CommString.SQL_連線字串_圖片_SQL(Global.圖檔資料庫, Global.資料庫IP);
  331. if(階段=="評估報告書1" || 階段=="評估報告書2" || 階段=="案場1" || 階段=="案場2" || 階段=="案場3"){
  332. SQL_Comm.SQL_讀取施工圖檔流水號(報告書流水號_tb.text,Global.報告書施工狀態,Global.報告書選項2,Global.報告書物料料號,Global.報告書物料明細流水號);
  333. int 流水號2;if(SQL_Module.dr.Read()){流水號2=int.Parse(SQL_Module.dr[0].ToString()[2..]);}else{流水號2 = 0;}流水號2+=1;
  334. SQL_Comm.SQL_上傳施工圖檔(報告書流水號_tb.text,Global.報告書施工狀態,Global.報告書選項2,Global.報告書物料料號,imageBytes,"JPG","IM"+流水號2.ToString().PadLeft(3,'0'),"0",Global.報告書物料明細流水號);
  335. }else{
  336. SQL_Comm.SQL_讀取相關文件圖檔流水號(報告書流水號_tb.text,階段);
  337. int 流水號;if(SQL_Module.dr.Read()){流水號=int.Parse(SQL_Module.dr["流水號"].ToString()[^8..]);}else{流水號 = 0;}流水號+=1;
  338. SQL_Comm.SQL_上傳相關文件圖檔("IM"+流水號.ToString().PadLeft(8,'0'),報告書流水號_tb.text,階段,imageBytes,"JPG","");
  339. }
  340. 拍照結束2(階段);
  341. }
  342. myCam.Stop();
  343. myCam = null;
  344. 提示_tb.text ="";
  345. }
  346. }
  347. private void 拍照結束2(string 階段){
  348. 拍照頁面_pl.SetActive(false);
  349. //PhotoScroll.清除currentPage();
  350. if(階段=="評估報告書1" || 階段=="評估報告書2" || 階段=="案場1" || 階段=="案場2" || 階段=="案場3"){
  351. //Set_評估報告書1清單("評估報告書1");
  352. 載入圖片清單2(Global.報告書施工狀態,施作圖片圖片讀取_pl);
  353. }else{
  354. 載入圖片清單(階段,報告書文件圖片讀取_pl);
  355. }
  356. }
  357. public void Set_報告書人員清單年份刷新(){
  358. Set_報告書人員清單("");
  359. }
  360. private void 載入圖片清單(string 階段,GameObject 圖片讀取){
  361. SQL_Comm.SQL_取得報告書資料(報告書項目清單_報告書號_tb.text);
  362. if(SQL_Module.dr.Read()){
  363. 報告書申請人_tb.text = SQL_Module.dr["負責人"].ToString();
  364. 報告書開立人_tb.text = SQL_Module.dr["開立人"].ToString();
  365. Global.圖檔資料庫 = SQL_Module.dr["圖檔資料庫"].ToString();
  366. Debug.Log(Global.圖檔資料庫);
  367. SQL_CommString.SQL_連線字串_圖片_SQL(Global.圖檔資料庫,Global.資料庫IP);
  368. SQL_Comm.SQL_報告書_相關文件圖片清單(報告書項目清單_報告書號_tb.text,階段);
  369. DataSet ds1 = new();
  370. SQL_Module.da.Fill(ds1);
  371. 目前階段 = 階段;
  372. if(ds1.Tables[0].Rows.Count>0){
  373. 相關文件相片目前_tb.text="1";相關文件相片總數_tb.text=ds1.Tables[0].Rows.Count.ToString();
  374. 文件圖片相片文件號_tb.text=ds1.Tables[0].Rows[0][0].ToString();
  375. 圖片讀取.SetActive(true);
  376. 載入報告書圖片2(階段);
  377. 圖片讀取.SetActive(false);
  378. }else{
  379. 相關文件相片目前_tb.text="-";相關文件相片總數_tb.text="-";文件圖片相片文件號_tb.text="文件號";
  380. 文件圖片_img.sprite = null;
  381. }
  382. Global.報告書相關文件_table = ds1.Tables[0];
  383. }
  384. }
  385. private void 載入報告書圖片2(string 階段){
  386. SQL_Comm.SQL_報告書_相關文件讀取圖片(報告書項目清單_報告書號_tb.text,階段,文件圖片相片文件號_tb.text);
  387. if (SQL_Module.dr.Read() && !SQL_Module.dr.IsDBNull(0)){
  388. byte[] imageData = (byte[])SQL_Module.dr["圖片"];
  389. Sprite sp = ByteArrayToSprite(imageData);
  390. 文件圖片_img.sprite =sp;
  391. 文件圖片_img.preserveAspect = true;
  392. 文件圖片_img.SetNativeSize();
  393. 限制圖片不超過Panel範圍();
  394. }
  395. }
  396. private void 限制圖片不超過Panel範圍(){
  397. RectTransform imageRT = 文件圖片_img.GetComponent<RectTransform>();
  398. RectTransform panelRT = 文件圖片_img.transform.parent.GetComponent<RectTransform>();
  399. float panelWidth = panelRT.rect.width;
  400. float panelHeight = panelRT.rect.height;
  401. float imageWidth = imageRT.rect.width;
  402. float imageHeight = imageRT.rect.height;
  403. float widthRatio = panelWidth / imageWidth;
  404. float heightRatio = panelHeight / imageHeight;
  405. float minRatio = Mathf.Min(widthRatio, heightRatio, 1f); // 不放大,只縮小
  406. imageRT.sizeDelta = new Vector2(imageWidth * minRatio, imageHeight * minRatio);
  407. imageRT.anchoredPosition = Vector2.zero; // 置中
  408. }
  409. public void 下一張圖片(){
  410. int currentIndex = int.Parse(相關文件相片目前_tb.text);
  411. int total = Global.報告書相關文件_table.Rows.Count;
  412. if (currentIndex < total){
  413. currentIndex++;
  414. 相關文件相片目前_tb.text = currentIndex.ToString();
  415. 文件圖片相片文件號_tb.text = Global.報告書相關文件_table.Rows[currentIndex - 1][0].ToString();
  416. 載入報告書圖片2(目前階段);
  417. }else{
  418. }
  419. }
  420. public void 上一張圖片(){
  421. int currentIndex = int.Parse(相關文件相片目前_tb.text);
  422. if (currentIndex > 1){
  423. currentIndex--;
  424. 相關文件相片目前_tb.text = currentIndex.ToString();
  425. 文件圖片相片文件號_tb.text = Global.報告書相關文件_table.Rows[currentIndex - 1][0].ToString();
  426. 載入報告書圖片2(目前階段);
  427. }else{
  428. }
  429. }
  430. private Sprite ByteArrayToSprite(byte[] imageData) {
  431. if (currentTexture != null) Destroy(currentTexture);
  432. currentTexture = new Texture2D(2, 2);
  433. if (imageData != null && currentTexture.LoadImage(imageData)){
  434. Rect rect = new Rect(0, 0, currentTexture.width, currentTexture.height);
  435. return Sprite.Create(currentTexture, rect, new Vector2(0.5f, 0.5f));
  436. }
  437. return null;
  438. }
  439. void 更新按鈕顏色(string 階段){
  440. Dictionary<string, GameObject> 按鈕對應表 = new(){
  441. { "申請人身分證正反面", 長照類_申請人身分證反面_bt },{ "委託人身分證正反面", 長照類_受託人身分證反面_bt },{ "所有權人身分證正反面", 長照類_所有權人身分證反面_bt },
  442. { "申請人身心障礙證明正反面", 長照類_申請人身心障礙證明_bt },{ "房屋所有權狀", 長照類_房屋所有權狀_bt }, { "土地所有權狀", 長照類_土地所有權狀_bt },
  443. { "房屋稅籍證明", 長照類_房屋稅籍證明_bt },{ "土地稅籍證明", 長照類_土地稅籍證明_bt },{ "房屋稅單", 長照類_房屋稅單_bt },{ "土地稅單", 長照類_土地稅單_bt }
  444. };
  445. GameObject[] 所有按鈕 = {
  446. 長照類_申請人身分證反面_bt,長照類_申請人身心障礙證明_bt,長照類_所有權人身分證反面_bt,長照類_受託人身分證反面_bt,長照類_房屋所有權狀_bt,長照類_房屋稅籍證明_bt,
  447. 長照類_房屋稅單_bt,長照類_土地所有權狀_bt,長照類_土地稅籍證明_bt,長照類_土地稅單_bt
  448. };
  449. foreach (var 按鈕 in 所有按鈕){
  450. var image = 按鈕.transform.Find("Image")?.GetComponent<Image>();if (image != null) {image.color = new Color32(255, 255, 255, 255);}
  451. }
  452. if (按鈕對應表.TryGetValue(階段, out GameObject 高亮按鈕)) {
  453. var image = 高亮按鈕.transform.Find("Image")?.GetComponent<Image>();if (image != null){image.color = new Color32(158, 255, 183, 255);}
  454. }
  455. }
  456. public void 報告書相關文件(string 階段){
  457. Global.報告書選項3 = 階段;
  458. 更新按鈕顏色(階段);
  459. 載入圖片清單(階段,報告書文件圖片讀取_pl);
  460. }
  461. public void 新增報告書_bt_Click(string 階段){
  462. Global.報告書選項3 = 階段;
  463. 載入圖片清單(階段,報告書文件圖片讀取_pl);
  464. }
  465. private void 讀取施作(string 文件號){
  466. SQL_Comm.SQL_報告書_查詢施作(報告書流水號_tb.text,文件號);
  467. if(SQL_Module.dr.Read()){
  468. Global.報告書物料明細流水號=SQL_Module.dr[0].ToString();
  469. Global.報告書物料料號 = SQL_Module.dr[1].ToString();
  470. 施作_tb.text=SQL_Module.dr[1].ToString();
  471. }else{
  472. SQL_Comm.SQL_報告書_讀取流水號();
  473. string 流水號;
  474. if(SQL_Module.dr.Read()){
  475. 流水號 = SQL_Module.dr[0].ToString();
  476. }else{
  477. 流水號 = "WS00000000";
  478. }
  479. int 新流;
  480. if(流水號.Contains("-")){
  481. string[] 前後 = 流水號.Split('-');
  482. 新流 = int.Parse(前後[0][2..]) + 1;
  483. }else{
  484. 新流 = int.Parse(流水號[2..]) + 1;
  485. }
  486. string 欣欣 = "WS"+新流.ToString().PadLeft(8,'0');
  487. Global.報告書物料明細流水號=欣欣;
  488. Global.報告書物料料號 = "";
  489. 施作_tb.text="";
  490. SQL_Comm.SQL_報告書_新增施作("",報告書流水號_tb.text,文件號,欣欣);
  491. }
  492. }
  493. public void 長照類_案場1_bt_click(){
  494. 長照類_案場1_bt.SetActive(false);長照類_案場2_bt.SetActive(false);長照類_案場3_bt.SetActive(false);返回8_bt.SetActive(false);
  495. 施作項目_lb.SetActive(true);施作項目_sv.SetActive(false);施作圖片_pl.SetActive(true);施作項目_新增_bt.SetActive(false);施作項目_刪除_bt.SetActive(false);
  496. 施作顯示_tb.SetActive(true);存檔2_bt.SetActive(true);
  497. 返回6_bt.SetActive(true);施工前_bt.SetActive(true);施工後_bt.SetActive(true);備註_bt.SetActive(true);產品序號_bt.SetActive(false);
  498. 施工前_tb.text = "施工前";施工後_tb.text = "施工後";
  499. Set_評估報告書1清單("案場1");
  500. Global.報告書選項2="案場1";
  501. 讀取施作(Global.報告書選項2);
  502. }
  503. public void 長照類_案場2_bt_click(){
  504. 長照類_案場1_bt.SetActive(false);長照類_案場2_bt.SetActive(false);長照類_案場3_bt.SetActive(false);返回8_bt.SetActive(false);
  505. 施作項目_lb.SetActive(true);施作項目_sv.SetActive(false);施作圖片_pl.SetActive(true);施作項目_新增_bt.SetActive(false);施作項目_刪除_bt.SetActive(false);
  506. 施作顯示_tb.SetActive(true);存檔2_bt.SetActive(true);
  507. 返回6_bt.SetActive(true);施工前_bt.SetActive(true);施工後_bt.SetActive(true);備註_bt.SetActive(true);產品序號_bt.SetActive(false);
  508. 施工前_tb.text = "施工前";施工後_tb.text = "施工後";
  509. Set_評估報告書1清單("案場2");
  510. Global.報告書選項2="案場2";
  511. 讀取施作(Global.報告書選項2);
  512. }
  513. public void 長照類_案場3_bt_click(){
  514. 長照類_案場1_bt.SetActive(false);長照類_案場2_bt.SetActive(false);長照類_案場3_bt.SetActive(false);返回8_bt.SetActive(false);
  515. 施作項目_lb.SetActive(true);施作項目_sv.SetActive(false);施作圖片_pl.SetActive(true);施作項目_新增_bt.SetActive(false);施作項目_刪除_bt.SetActive(false);
  516. 施作顯示_tb.SetActive(true);存檔2_bt.SetActive(true);
  517. 返回6_bt.SetActive(true);施工前_bt.SetActive(true);施工後_bt.SetActive(true);備註_bt.SetActive(true);產品序號_bt.SetActive(false);
  518. Set_評估報告書1清單("案場3");
  519. 施工前_tb.text = "施工前";施工後_tb.text = "施工後";
  520. Global.報告書選項2="案場3";
  521. 讀取施作(Global.報告書選項2);
  522. }
  523. public void 長照類_存檔2_bt_click(){
  524. Global.報告書物料料號 = 施作_tb.text;
  525. SQL_Comm.SQL_報告書_修改施作(施作_tb.text,報告書流水號_tb.text,Global.報告書選項2,Global.報告書物料明細流水號);
  526. SQL_Comm.SQL_取得報告書資料(報告書流水號_tb.text);
  527. if(SQL_Module.dr.Read()){
  528. Global.圖檔資料庫 = SQL_Module.dr["圖檔資料庫"].ToString();
  529. SQL_CommString.SQL_連線字串_圖片_SQL(Global.圖檔資料庫,Global.資料庫IP);
  530. SQL_Comm.SQL_報告書_修改施作2(施作_tb.text,報告書流水號_tb.text,Global.報告書選項2);
  531. }
  532. }
  533. public void 長照類_評估報告書1_bt_click(){
  534. 長照類_核定通知書_bt.SetActive(false);長照類_相關文件_bt.SetActive(false);長照類_評估報告書1_bt.SetActive(false);
  535. 長照類_評估報告書2_bt.SetActive(false);返回4_bt.SetActive(false);
  536. 施作項目_lb.SetActive(true);施作項目_sv.SetActive(true);施作圖片_pl.SetActive(true);施作項目_新增_bt.SetActive(true);施作項目_刪除_bt.SetActive(true);
  537. 返回6_bt.SetActive(true);施工前_bt.SetActive(true);施工後_bt.SetActive(true);備註_bt.SetActive(true);產品序號_bt.SetActive(false);
  538. 施工前_tb.text = "施工前";施工後_tb.text = "施工後";
  539. Set_評估報告書1清單("評估報告書1");
  540. Global.報告書選項2="評估報告書1";
  541. }
  542. public void 長照類_評估報告書2_bt_click(){
  543. 長照類_核定通知書_bt.SetActive(false);長照類_相關文件_bt.SetActive(false);長照類_評估報告書1_bt.SetActive(false);
  544. 長照類_評估報告書2_bt.SetActive(false);返回4_bt.SetActive(false);
  545. 施作項目_lb.SetActive(true);施作項目_sv.SetActive(true);施作圖片_pl.SetActive(true);施作項目_新增_bt.SetActive(true);施作項目_刪除_bt.SetActive(true);
  546. 返回6_bt.SetActive(true);施工前_bt.SetActive(true);施工後_bt.SetActive(true);備註_bt.SetActive(true);產品序號_bt.SetActive(true);
  547. Set_評估報告書1清單("評估報告書2");
  548. if(Global.報告書選項1=="身障類" || Global.報告書選項1=="長照類"){
  549. 施工前_tb.text = "空拍輔具";施工後_tb.text = "使用中";
  550. }else{
  551. 施工前_tb.text = "施工前";施工後_tb.text = "施工後";
  552. }
  553. Global.報告書選項2="評估報告書2";
  554. }
  555. public void 報告書清單返回6(){
  556. if(Global.報告書選項2=="評估報告書1" || Global.報告書選項2=="評估報告書2"){
  557. 長照類_核定通知書_bt.SetActive(true);長照類_相關文件_bt.SetActive(true);長照類_評估報告書1_bt.SetActive(true);
  558. 長照類_評估報告書2_bt.SetActive(true);返回4_bt.SetActive(true);
  559. 施作項目_lb.SetActive(false);施作項目_sv.SetActive(false);施作圖片_pl.SetActive(false);施作項目_新增_bt.SetActive(false);施作項目_刪除_bt.SetActive(false);
  560. 施作顯示_tb.SetActive(false);存檔2_bt.SetActive(false);
  561. 返回6_bt.SetActive(false);施工前_bt.SetActive(false);施工後_bt.SetActive(false);備註_bt.SetActive(false);產品序號_bt.SetActive(false);
  562. 拍照1_bt.SetActive(false);刪除1_bt.SetActive(false);存檔1_bt.SetActive(false);
  563. 施作圖片_img.sprite =null;
  564. }else{
  565. 長照類_案場1_bt.SetActive(true);長照類_案場2_bt.SetActive(true);長照類_案場3_bt.SetActive(true);返回8_bt.SetActive(true);
  566. 施作項目_lb.SetActive(false);施作項目_sv.SetActive(false);施作圖片_pl.SetActive(false);施作項目_新增_bt.SetActive(false);施作項目_刪除_bt.SetActive(false);
  567. 施作顯示_tb.SetActive(false);存檔2_bt.SetActive(false);
  568. 返回6_bt.SetActive(false);施工前_bt.SetActive(false);施工後_bt.SetActive(false);備註_bt.SetActive(false);產品序號_bt.SetActive(false);
  569. 拍照1_bt.SetActive(false);刪除1_bt.SetActive(false);存檔1_bt.SetActive(false);
  570. 施作圖片_img.sprite =null;
  571. }
  572. }
  573. private void Set_評估報告書1清單(string 文件號){
  574. SQL_Comm.SQL_取得報告書項目清單2(報告書流水號_tb.text,文件號);
  575. DataSet ds1 = new();
  576. SQL_Module.da.Fill(ds1);
  577. for(int i=0;i<=ds1.Tables[0].Rows.Count-1;i++){
  578. ds1.Tables[0].Rows[i][1] = ds1.Tables[0].Rows[i][2].ToString() + " " + ds1.Tables[0].Rows[i][4].ToString();
  579. }
  580. if(文件號=="評估報告書1"){
  581. Global.報告書評估報告書1清單_tabel = ds1.Tables[0];
  582. }else if(文件號=="案場1"){
  583. Global.報告書案場1清單_tabel = ds1.Tables[0];
  584. }else if(文件號=="案場2"){
  585. Global.報告書案場2清單_tabel = ds1.Tables[0];
  586. }else if(文件號=="案場3"){
  587. Global.報告書案場3清單_tabel = ds1.Tables[0];
  588. }else{
  589. Global.報告書評估報告書2清單_tabel = ds1.Tables[0];
  590. }
  591. 載入報告書項目清單表格("報告書"+文件號+"清單",ds1.Tables[0],報告書施作項目清單_tp,報告書施作項目清單_rpf,報告書施作項目清單_ct,myFont,UIsprite,報告書施作項目清單_lpf,true);
  592. }
  593. public void 報告書評估報告書1新增(){
  594. 評估報告書1_物料清單_sv.SetActive(true);返回6_bt.SetActive(false);施作圖片_pl.SetActive(false);返回7_bt.SetActive(true);
  595. if(Global.報告書選項1=="長照類"){
  596. if(Global.報告書選項2=="評估報告書1"){
  597. Set_長照物料清單("施作項目","C",報告書施作圖片_物料清單_tp,報告書施作圖片_物料清單_rpf,報告書施作圖片_物料清單_ct,報告書施作圖片_物料清單_lpf,Global.報告書選項2+"物料清單");
  598. }else{
  599. Set_長照物料清單("施作項目","C2",報告書施作圖片_物料清單_tp,報告書施作圖片_物料清單_rpf,報告書施作圖片_物料清單_ct,報告書施作圖片_物料清單_lpf,Global.報告書選項2+"物料清單");
  600. }
  601. }else{
  602. if(Global.報告書選項2=="評估報告書1"){
  603. Set_長照物料清單("施作項目","D",報告書施作圖片_物料清單_tp,報告書施作圖片_物料清單_rpf,報告書施作圖片_物料清單_ct,報告書施作圖片_物料清單_lpf,Global.報告書選項2+"物料清單");
  604. }else{
  605. Set_長照物料清單("施作項目","D2",報告書施作圖片_物料清單_tp,報告書施作圖片_物料清單_rpf,報告書施作圖片_物料清單_ct,報告書施作圖片_物料清單_lpf,Global.報告書選項2+"物料清單");
  606. }
  607. }
  608. }
  609. public void 報告書評估報告書1刪除(){
  610. Debug.Log(Global.報告書物料料號);
  611. SQL_Comm.SQL_報告書_刪除報告書明細(報告書流水號_tb.text,Global.報告書選項2,Global.報告書物料料號);
  612. SQL_Comm.SQL_取得報告書資料(報告書流水號_tb.text);
  613. if(SQL_Module.dr.Read()){
  614. Global.圖檔資料庫 = SQL_Module.dr["圖檔資料庫"].ToString();
  615. SQL_CommString.SQL_連線字串_圖片_SQL(Global.圖檔資料庫,Global.資料庫IP);
  616. SQL_Comm.SQL_報告書_刪除報告書施工圖檔(報告書流水號_tb.text,Global.報告書選項2,Global.報告書物料料號);
  617. }
  618. Set_評估報告書1清單(Global.報告書選項2);
  619. }
  620. public void 報告書評估報告書1圖檔刪除(){
  621. if(Global.報告書選項2=="評估報告書1" || Global.報告書選項2=="評估報告書2" || Global.報告書選項2=="案場1" || Global.報告書選項2=="案場2" || Global.報告書選項2=="案場3"){
  622. SQL_Comm.SQL_取得報告書資料(報告書流水號_tb.text);
  623. if(SQL_Module.dr.Read()){
  624. Global.圖檔資料庫 = SQL_Module.dr["圖檔資料庫"].ToString();
  625. SQL_CommString.SQL_連線字串_圖片_SQL(Global.圖檔資料庫,Global.資料庫IP);
  626. string 文件號=施作圖片相片文件號_tb.text;
  627. SQL_Comm.SQL_報告書_刪除報告書施工圖檔照片(報告書流水號_tb.text,Global.報告書選項2,Global.報告書施工狀態,Global.報告書物料明細流水號,Global.報告書物料料號,文件號);
  628. 載入圖片清單2(Global.報告書施工狀態,施作圖片圖片讀取_pl);
  629. }
  630. }else if(Global.報告書選項2=="核定通知書"){
  631. string 文件號 = 文件圖片相片文件號_tb.text;
  632. SQL_Comm.SQL_報告書_刪除報告書相關文件圖檔照片(報告書流水號_tb.text,Global.報告書選項2,文件號);
  633. 載入圖片清單(Global.報告書選項2,報告書文件圖片讀取_pl);
  634. }else{
  635. string 文件號 = 文件圖片相片文件號_tb.text;
  636. SQL_Comm.SQL_報告書_刪除報告書相關文件圖檔照片(報告書流水號_tb.text,Global.報告書選項3,文件號);
  637. 載入圖片清單(Global.報告書選項3,報告書文件圖片讀取_pl);
  638. }
  639. }
  640. public void 報告書清單返回7(){
  641. 評估報告書1_物料清單_sv.SetActive(false);返回6_bt.SetActive(true);施作圖片_pl.SetActive(true);返回7_bt.SetActive(false);
  642. }
  643. public void 長照類_核定通知書_bt_click(){
  644. 長照類_核定通知書_bt.SetActive(false);長照類_相關文件_bt.SetActive(false);長照類_評估報告書1_bt.SetActive(false);
  645. 長照類_評估報告書2_bt.SetActive(false);返回4_bt.SetActive(false);
  646. 返回5_bt.SetActive(true);刪除1_bt.SetActive(true);存檔1_bt.SetActive(true);
  647. 拍照1_bt.SetActive(true);報告書文件圖片_pl.SetActive(true);
  648. RectTransform rt = 報告書文件圖片_pl.GetComponent<RectTransform>();
  649. rt.offsetMax = new Vector2(rt.offsetMax.x, -114f);
  650. Global.報告書選項2="核定通知書";
  651. 限制圖片不超過Panel範圍();
  652. 載入圖片清單(Global.報告書選項2,報告書文件圖片讀取_pl);
  653. }
  654. private void Set_日期格式轉換(){
  655. Global.DTP1 = DateTime.Today.Year.ToString().PadLeft(4,'0')+DateTime.Today.Month.ToString().PadLeft(2,'0')+DateTime.Today.Day.ToString().PadLeft(2,'0');
  656. }
  657. private void Set_報告書人員清單(string 搜尋條件){
  658. 報告書人員清單_pl.SetActive(true);報告書人員資料_pl.SetActive(false);報告書項目清單_pl.SetActive(false);
  659. 評估主頁抬頭_tb.text= "首頁";
  660. string 年份;
  661. if(報告書人員清單_年份_cb.GetComponent<TMP_Dropdown>().options[報告書人員清單_年份_cb.GetComponent<TMP_Dropdown>().value].text==""){
  662. 年份 = "%%";
  663. }else{
  664. 年份 = 報告書人員清單_年份_cb.GetComponent<TMP_Dropdown>().options[報告書人員清單_年份_cb.GetComponent<TMP_Dropdown>().value].text;
  665. }
  666. SQL_Comm.SQL_報告書_人員清單(Global.gUser區域,年份,搜尋條件);
  667. DataSet ds1 = new();
  668. SQL_Module.da.Fill(ds1);
  669. string[] columnNames = new string[] { ds1.Tables[0].Columns[1].ColumnName, ds1.Tables[0].Columns[2].ColumnName};
  670. Global.報告書人員清單_tabel = ds1.Tables[0];
  671. 載入報告書表格("報告書人員清單",ds1.Tables[0].DefaultView.ToTable(false, columnNames),報告書人員清單_tp,報告書人員清單_rpf,報告書人員清單_ct,myFont,UIsprite,報告書人員清單_lpf,true,表頭_pl);
  672. }
  673. private void Set_報告書清單(string 客戶編號,string 申請人,string 聯繫人,string 聯繫人電話,string 住址,string 聯繫人2,string 聯繫人2電話){
  674. 報告書人員清單_pl.SetActive(false);報告書人員資料_pl.SetActive(true);報告書項目清單_pl.SetActive(false);
  675. 評估主頁抬頭_tb.text = 申請人;報告書人員資料_申請人_tb.text = 申請人;報告書人員資料_客編_tb.text = 客戶編號;報告書人員資料_聯繫人_tb.text = 聯繫人;
  676. 報告書人員資料_聯繫人電話_tb.text = 聯繫人電話;報告書人員資料_地址_tb.text = 住址;報告書人員資料_聯繫人2_tb.text=聯繫人2;報告書人員資料_聯繫人2電話_tb.text=聯繫人2電話;
  677. 返回1_bt.SetActive(false);查詢1_bt.SetActive(false);新增客戶1_bt.SetActive(false);返回2_bt.SetActive(true);返回2_1_bt.SetActive(false);
  678. SQL_Comm.SQL_報告書_清單(客戶編號);
  679. DataSet ds1 = new();
  680. SQL_Module.da.Fill(ds1);
  681. string[] columnNames = new string[] { ds1.Tables[0].Columns[0].ColumnName, ds1.Tables[0].Columns[2].ColumnName};
  682. Global.報告書清單_tabel = ds1.Tables[0].DefaultView.ToTable(false, columnNames);
  683. 載入報告書表格("報告書清單",Global.報告書清單_tabel,報告書清單_tp,報告書清單_rpf,報告書清單_ct,myFont,UIsprite,報告書清單_lpf,true,表頭2_pl);
  684. }
  685. private void 載入報告書表格(string table_name,DataTable table,Transform tableParent,GameObject rowPrefab,GameObject ceneter,TMP_FontAsset myFont,Sprite UIsprite,
  686. GameObject LinePrefab,bool overflowMode,GameObject 表頭){
  687. Module.清除控件(表頭);
  688. float 表格高度 = 160f;
  689. for (int j = 0; j <= table.Columns.Count-1; j++){
  690. GameObject headerText = new(table_name+"_Headers (Clone)");
  691. headerText.transform.SetParent(表頭.transform, false);
  692. headerText.AddComponent<TextMeshProUGUI>().text = table.Columns[j].ColumnName;
  693. headerText.GetComponent<TextMeshProUGUI>().tag="Cells";
  694. if(overflowMode){headerText.GetComponent<TextMeshProUGUI>().overflowMode=TextOverflowModes.Ellipsis;}
  695. if(j==0){
  696. headerText.GetComponent<RectTransform>().anchoredPosition=new Vector2(0f,0f);
  697. headerText.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
  698. headerText.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
  699. headerText.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
  700. float x = 表頭.GetComponent<RectTransform>().rect.width -275f;
  701. headerText.GetComponent<RectTransform>().sizeDelta = new Vector2(x, 表格高度);
  702. }else{
  703. headerText.GetComponent<RectTransform>().anchorMin = new Vector2(1f, 1f);
  704. headerText.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f);
  705. headerText.GetComponent<RectTransform>().pivot = new Vector2(1f, 1f);
  706. headerText.GetComponent<RectTransform>().sizeDelta = new Vector2(270f, 表格高度);
  707. headerText.GetComponent<RectTransform>().anchoredPosition=new Vector2(0f,0f);
  708. }
  709. }
  710. GameObject Separation = Instantiate(LinePrefab, 表頭.transform);
  711. Separation.GetComponent<RectTransform>().sizeDelta = new Vector2(5f,表頭.GetComponent<RectTransform>().sizeDelta.y-5f);
  712. Separation.GetComponent<RectTransform>().anchoredPosition = new Vector2(-275f,-3f);
  713. Separation.GetComponent<RectTransform>().anchorMin = new Vector2(1f, 1f);
  714. Separation.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f);
  715. Separation.GetComponent<RectTransform>().pivot = new Vector2(1f, 1f);
  716. Separation.GetComponent<Image>().color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  717. TextMeshProUGUI[] texts = 表頭.GetComponentsInChildren<TextMeshProUGUI>();
  718. foreach (TextMeshProUGUI text in texts){
  719. if(text.tag.Contains("Cells")){
  720. text.font = myFont;
  721. text.color = Global.系統主題 == 1 ? new Color(0, 0, 0, 1) : text.color;
  722. text.alignment = TextAlignmentOptions.Center;
  723. text.enableAutoSizing = true;
  724. text.margin = new Vector4(10, 0, 10, 0);
  725. }else{
  726. }
  727. }
  728. //==============================================
  729. Module.清除控件(ceneter);
  730. Image centerImage = ceneter.GetComponent<Image>();
  731. if(centerImage == null){
  732. centerImage = ceneter.AddComponent<Image>();
  733. centerImage.type = Image.Type.Sliced;
  734. }
  735. centerImage.sprite = UIsprite;
  736. centerImage.fillCenter = false;
  737. centerImage.color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  738. for (int i = 0; i < table.Rows.Count; i++){
  739. GameObject row = Instantiate(rowPrefab, tableParent);
  740. row.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, (-表格高度 * i)+(-5*i));
  741. for (int j = 0; j < table.Columns.Count; j++){
  742. string value = table.Rows[i][j].ToString();
  743. GameObject cellText = new(table_name+"_Cells_"+i.ToString()+"_"+j.ToString());
  744. cellText.transform.SetParent(row.transform, false);
  745. cellText.AddComponent<TextMeshProUGUI>().text = value;
  746. cellText.GetComponent<TextMeshProUGUI>().tag="Cells";
  747. if(overflowMode){cellText.GetComponent<TextMeshProUGUI>().overflowMode=TextOverflowModes.Ellipsis;}
  748. cellText.AddComponent<Button>();
  749. cellText.GetComponent<Button>().onClick.AddListener(() => { 按鈕事件(cellText); });
  750. if(j==0){
  751. cellText.GetComponent<RectTransform>().anchoredPosition=new Vector2(0f,0f);
  752. cellText.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
  753. cellText.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
  754. cellText.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
  755. float x = ceneter.GetComponent<RectTransform>().rect.width -275f;
  756. cellText.GetComponent<RectTransform>().sizeDelta = new Vector2(x, 表格高度);
  757. }else{
  758. cellText.GetComponent<RectTransform>().anchorMin = new Vector2(1f, 1f);
  759. cellText.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f);
  760. cellText.GetComponent<RectTransform>().pivot = new Vector2(1f, 1f);
  761. cellText.GetComponent<RectTransform>().sizeDelta = new Vector2(270f, 表格高度);
  762. cellText.GetComponent<RectTransform>().anchoredPosition=new Vector2(0f,0f);
  763. }
  764. }
  765. }
  766. texts = ceneter.GetComponentsInChildren<TextMeshProUGUI>();
  767. foreach (TextMeshProUGUI text in texts){
  768. if(text.tag.Contains("Cells")){
  769. text.font = myFont;
  770. text.color = Global.系統主題 == 1 ? new Color(0, 0, 0, 1) : text.color;
  771. text.alignment = TextAlignmentOptions.Center;
  772. text.enableAutoSizing = true;;
  773. text.margin = new Vector4(10, 0, 10, 0);
  774. }else{
  775. }
  776. }
  777. ceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(ceneter.GetComponent<RectTransform>().sizeDelta.x,table.Rows.Count*表格高度 +((table.Rows.Count-1)*5f));
  778. //========建立分隔線=============
  779. Separation = Instantiate(LinePrefab, tableParent);
  780. Separation.GetComponent<RectTransform>().sizeDelta = new Vector2(5f,ceneter.GetComponent<RectTransform>().sizeDelta.y-5f);
  781. Separation.GetComponent<RectTransform>().anchoredPosition = new Vector2(-275f,-3f);
  782. Separation.GetComponent<RectTransform>().anchorMin = new Vector2(1f, 1f);
  783. Separation.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f);
  784. Separation.GetComponent<RectTransform>().pivot = new Vector2(1f, 1f);
  785. Separation.GetComponent<Image>().color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  786. /*for(int i=1;i<=table.Rows.Count-1;i++){
  787. GameObject Separation2 = Instantiate(LinePrefab, tableParent);
  788. Separation2.GetComponent<RectTransform>().sizeDelta = new Vector2(ceneter.GetComponent<RectTransform>().rect.width-5f,5f);
  789. Separation2.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
  790. Separation2.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
  791. Separation2.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
  792. Separation2.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 5f * (1 - 19 * i));
  793. Separation2.GetComponent<Image>().color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  794. }*/
  795. for(int i = 1; i <= table.Rows.Count - 1; i++) {
  796. GameObject Separation2 = Instantiate(LinePrefab, tableParent);
  797. Separation2.GetComponent<RectTransform>().sizeDelta = new Vector2(ceneter.GetComponent<RectTransform>().rect.width - 5f, 5f);
  798. Separation2.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
  799. Separation2.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
  800. Separation2.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
  801. Separation2.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, - (表格高度 + 5f) * i + 5f);
  802. Separation2.GetComponent<Image>().color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  803. }
  804. }
  805. private void 載入報告書詳細資料(string 報告書流水號){
  806. 文件號_sv.GetComponent<RectTransform>().sizeDelta=new Vector2(報告書資料_pl.GetComponent<RectTransform>().rect.width/2-10f,文件號_sv.GetComponent<RectTransform>().sizeDelta.y);
  807. 項目清單_lb.GetComponent<RectTransform>().sizeDelta=new Vector2(報告書資料_pl.GetComponent<RectTransform>().rect.width/2-10f,項目清單_lb.GetComponent<RectTransform>().sizeDelta.y);
  808. 項目清單_sv.GetComponent<RectTransform>().sizeDelta=new Vector2(報告書資料_pl.GetComponent<RectTransform>().rect.width/2-10f,項目清單_sv.GetComponent<RectTransform>().sizeDelta.y);
  809. 扶手總長_lb.GetComponent<RectTransform>().sizeDelta=new Vector2(報告書資料_pl.GetComponent<RectTransform>().rect.width/2-200f,扶手總長_lb.GetComponent<RectTransform>().sizeDelta.y);
  810. 扶手總長_tb.GetComponent<RectTransform>().sizeDelta=new Vector2(報告書資料_pl.GetComponent<RectTransform>().rect.width/2-200f,扶手總長_tb.GetComponent<RectTransform>().sizeDelta.y);
  811. 報告書扶手總長_tb.text="";單項扶手長度_tb.text="";
  812. SQL_Comm.SQL_取得報告書資料(報告書流水號);
  813. if(SQL_Module.dr.Read()){
  814. 報告書申請人_tb.text = SQL_Module.dr["負責人"].ToString();
  815. 報告書開立人_tb.text = SQL_Module.dr["開立人"].ToString();
  816. Global.圖檔資料庫 = SQL_Module.dr["圖檔資料庫"].ToString();
  817. Debug.Log(Global.圖檔資料庫);
  818. SQL_CommString.SQL_連線字串_圖片_SQL(Global.圖檔資料庫,Global.資料庫IP);
  819. SQL_Comm.SQL_取得文件號清單(報告書流水號);
  820. DataSet ds1 = new();
  821. SQL_Module.da.Fill(ds1);
  822. Global.文件號清單_table=ds1.Tables[0];
  823. for(int i=0;i<=ds1.Tables[0].Rows.Count-1;i++){
  824. ds1.Tables[0].Rows[i][0]="第 "+(i+1)+" 頁";
  825. }
  826. string[] columnNames = new string[]{ds1.Tables[0].Columns[0].ColumnName};
  827. DataTable table1 = ds1.Tables[0].DefaultView.ToTable(false, columnNames);
  828. 載入文件號表格("文件號清單",table1,文件號清單_tp,文件號清單_rpf,文件號清單_ct,myFont,UIsprite,文件號清單_lpf,true);
  829. }
  830. }
  831. private void 載入文件號表格(string table_name,DataTable table,Transform tableParent,GameObject rowPrefab,GameObject ceneter,TMP_FontAsset myFont,Sprite UIsprite,
  832. GameObject LinePrefab,bool overflowMode){
  833. Module.清除控件(ceneter);
  834. Image centerImage = ceneter.GetComponent<Image>();
  835. if(centerImage == null){
  836. centerImage = ceneter.AddComponent<Image>();
  837. centerImage.type = Image.Type.Sliced;
  838. }
  839. centerImage.sprite = UIsprite;
  840. centerImage.fillCenter = false;
  841. centerImage.color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  842. for (int i = 0; i < table.Rows.Count; i++){
  843. GameObject row = Instantiate(rowPrefab, tableParent);
  844. row.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, (-90 * i)+(-5*i));
  845. string value = table.Rows[i][0].ToString();
  846. GameObject cellText = new(table_name+"_Cells_"+i.ToString()+"_0");
  847. cellText.transform.SetParent(row.transform, false);
  848. cellText.AddComponent<TextMeshProUGUI>().text = value;
  849. cellText.GetComponent<TextMeshProUGUI>().tag="Cells";
  850. if(overflowMode){cellText.GetComponent<TextMeshProUGUI>().overflowMode=TextOverflowModes.Ellipsis;}
  851. cellText.AddComponent<Button>();
  852. cellText.GetComponent<Button>().onClick.AddListener(() => { 按鈕事件(cellText); });
  853. cellText.GetComponent<RectTransform>().anchoredPosition=new Vector2(0f,0f);
  854. cellText.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
  855. cellText.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
  856. cellText.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
  857. cellText.GetComponent<RectTransform>().sizeDelta = new Vector2(ceneter.GetComponent<RectTransform>().rect.width, 90f);
  858. }
  859. TextMeshProUGUI[] texts = ceneter.GetComponentsInChildren<TextMeshProUGUI>();
  860. foreach (TextMeshProUGUI text in texts){
  861. if(text.tag.Contains("Cells")){
  862. text.font = myFont;
  863. text.color = Global.系統主題 == 1 ? new Color(0, 0, 0, 1) : text.color;
  864. text.alignment = TextAlignmentOptions.Center;
  865. text.fontStyle = FontStyles.Bold;
  866. text.fontSize=42;
  867. text.margin = new Vector4(10, 0, 10, 0);
  868. }else{
  869. }
  870. }
  871. ceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(ceneter.GetComponent<RectTransform>().sizeDelta.x,table.Rows.Count*90f+((table.Rows.Count-1)*5f));
  872. //========建立分隔線=============
  873. for(int i=1;i<=table.Rows.Count-1;i++){
  874. GameObject Separation2 = Instantiate(LinePrefab, tableParent);
  875. Separation2.GetComponent<RectTransform>().sizeDelta = new Vector2(ceneter.GetComponent<RectTransform>().rect.width-5f,5f);
  876. Separation2.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
  877. Separation2.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
  878. Separation2.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
  879. Separation2.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 5f * (1 - 19 * i));
  880. Separation2.GetComponent<Image>().color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  881. }
  882. }
  883. private void 載入報告書項目清單(string 文件號){
  884. SQL_Comm.SQL_取得報告書項目清單(報告書流水號_tb.text,文件號);
  885. DataSet ds1 = new();
  886. SQL_Module.da.Fill(ds1);
  887. Global.報告書項目清單_tabel = ds1.Tables[0];
  888. 載入報告書項目清單表格("報告書項目清單",ds1.Tables[0],報告書項目清單_tp,報告書項目清單_rpf,報告書項目清單_ct,myFont,UIsprite,報告書項目清單_lpf,true);
  889. }
  890. private void 載入報告書項目清單表格(string table_name,DataTable table,Transform tableParent,GameObject rowPrefab,GameObject ceneter,TMP_FontAsset myFont,Sprite UIsprite,
  891. GameObject LinePrefab,bool overflowMode){
  892. Module.清除控件(ceneter);
  893. Image centerImage = ceneter.GetComponent<Image>();
  894. if(centerImage == null){
  895. centerImage = ceneter.AddComponent<Image>();
  896. centerImage.type = Image.Type.Sliced;
  897. }
  898. centerImage.sprite = UIsprite;
  899. centerImage.fillCenter = false;
  900. centerImage.color = Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  901. for (int i = 0; i < table.Rows.Count; i++){
  902. GameObject row = Instantiate(rowPrefab, tableParent);
  903. row.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, (-90 * i)+(-5*i));
  904. string value = table.Rows[i][1].ToString();
  905. GameObject cellText = new(table_name+"_Cells_"+i.ToString()+"_1");
  906. cellText.transform.SetParent(row.transform, false);
  907. cellText.AddComponent<TextMeshProUGUI>().text = value;
  908. cellText.GetComponent<TextMeshProUGUI>().tag="Cells";
  909. if(overflowMode){cellText.GetComponent<TextMeshProUGUI>().overflowMode=TextOverflowModes.Ellipsis;}
  910. cellText.AddComponent<Button>();
  911. cellText.GetComponent<Button>().onClick.AddListener(() => { 按鈕事件(cellText); });
  912. cellText.GetComponent<RectTransform>().anchoredPosition=new Vector2(0f,0f);
  913. cellText.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
  914. cellText.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
  915. cellText.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
  916. cellText.GetComponent<RectTransform>().sizeDelta = new Vector2(ceneter.GetComponent<RectTransform>().rect.width, 90f);
  917. }
  918. TextMeshProUGUI[] texts = ceneter.GetComponentsInChildren<TextMeshProUGUI>();
  919. foreach (TextMeshProUGUI text in texts){
  920. if(text.tag.Contains("Cells")){
  921. text.font = myFont;
  922. text.color = Global.系統主題 == 1 ? new Color(0, 0, 0, 1) : text.color;
  923. text.alignment = TextAlignmentOptions.Center;
  924. text.fontStyle = FontStyles.Bold;
  925. text.fontSize=42;
  926. text.margin = new Vector4(10, 0, 10, 0);
  927. }else{
  928. }
  929. }
  930. ceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(ceneter.GetComponent<RectTransform>().sizeDelta.x,table.Rows.Count*90f +((table.Rows.Count-1)*5f));
  931. //========建立分隔線=============
  932. for(int i=1;i<=table.Rows.Count-1;i++){
  933. GameObject Separation2 = Instantiate(LinePrefab, tableParent);
  934. Separation2.GetComponent<RectTransform>().sizeDelta = new Vector2(ceneter.GetComponent<RectTransform>().rect.width-5f,5f);
  935. Separation2.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
  936. Separation2.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
  937. Separation2.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
  938. Separation2.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 5f * (1 - 19 * i));
  939. Separation2.GetComponent<Image>().color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  940. }
  941. }
  942. private void 載入報告書圖片(string table_name,DataTable table,Transform tableParent,GameObject rowPrefab,GameObject ceneter,TMP_FontAsset myFont,Sprite UIsprite,
  943. GameObject LinePrefab,bool overflowMode){
  944. Module.清除控件(ceneter);
  945. Image centerImage = ceneter.GetComponent<Image>();
  946. if(centerImage == null){
  947. centerImage = ceneter.AddComponent<Image>();
  948. centerImage.type = Image.Type.Sliced;
  949. }
  950. centerImage.sprite = UIsprite;
  951. centerImage.fillCenter = false;
  952. centerImage.color = Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  953. for (int i = 0; i < table.Rows.Count; i++){
  954. GameObject row = Instantiate(rowPrefab, tableParent);
  955. row.GetComponent<RectTransform>().anchoredPosition = new Vector2(rowPrefab.GetComponent<RectTransform>().rect.width*i ,0);
  956. GameObject Imagg = Instantiate(LinePrefab, row.GetComponent<Transform>());
  957. RawImage image = Imagg.AddComponent<RawImage>();
  958. byte[] imageData = (byte[])table.Rows[i][1];
  959. Texture2D texture = new(1, 1);
  960. texture.LoadImage(imageData);
  961. image.texture = texture;
  962. if (texture.width > texture.height){
  963. float scaleFactor = rowPrefab.GetComponent<RectTransform>().rect.width / texture.width;
  964. image.rectTransform.sizeDelta = new Vector2(row.GetComponent<RectTransform>().rect.width, texture.height * scaleFactor);
  965. }else{
  966. float scaleFactor = rowPrefab.GetComponent<RectTransform>().rect.width / texture.height;
  967. image.rectTransform.sizeDelta = new Vector2(texture.width * scaleFactor, row.GetComponent<RectTransform>().rect.width);
  968. }
  969. }
  970. int numm;
  971. if(table.Rows.Count>0){numm=table.Rows.Count;}else{numm=1;}
  972. ceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(rowPrefab.GetComponent<RectTransform>().rect.width*numm, rowPrefab.GetComponent<RectTransform>().sizeDelta.y);
  973. }
  974. private void Set_客戶清單(){
  975. SQL_Comm.SQL_報告書_客戶清單(Global.gUser區域);
  976. // 客戶編號, 來電日期, 申請人, 聯繫人, 聯繫電話, 地址, 需求, 特殊需求
  977. DataSet ds1 = new();
  978. SQL_Module.da.Fill(ds1);
  979. string[] columnNames = new string[]{ds1.Tables[0].Columns[0].ColumnName,ds1.Tables[0].Columns[2].ColumnName,ds1.Tables[0].Columns[3].ColumnName};
  980. DataTable table1 = ds1.Tables[0].DefaultView.ToTable(false, columnNames);Global.客戶清單_tabel=ds1.Tables[0];
  981. 載入客戶清單表格("客戶清單",table1,客戶清單_tp,客戶清單_rpf,客戶清單_ct,myFont,UIsprite,客戶清單_lpf,true);
  982. }
  983. private void 載入客戶清單表格(string table_name,DataTable table,Transform tableParent,GameObject rowPrefab,GameObject ceneter,TMP_FontAsset myFont,Sprite UIsprite,
  984. GameObject LinePrefab,bool overflowMode){
  985. Module.清除控件(客戶清單表頭_pl);
  986. for (int j = 0; j <= table.Columns.Count-1; j++){
  987. GameObject headerText = new(table_name+"_Headers (Clone)");
  988. headerText.transform.SetParent(客戶清單表頭_pl.transform, false);
  989. headerText.AddComponent<TextMeshProUGUI>().text = table.Columns[j].ColumnName;
  990. headerText.GetComponent<TextMeshProUGUI>().tag="Cells";
  991. if(overflowMode){headerText.GetComponent<TextMeshProUGUI>().overflowMode=TextOverflowModes.Ellipsis;}
  992. if(j==0){
  993. headerText.GetComponent<RectTransform>().anchoredPosition=new Vector2(0f,0f);
  994. headerText.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
  995. headerText.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
  996. headerText.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
  997. float x = 客戶清單表頭_pl.GetComponent<RectTransform>().rect.width -420f;
  998. headerText.GetComponent<RectTransform>().sizeDelta = new Vector2(x, 90f);
  999. }else if(j==1){
  1000. headerText.GetComponent<RectTransform>().anchorMin = new Vector2(1f, 1f);
  1001. headerText.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f);
  1002. headerText.GetComponent<RectTransform>().pivot = new Vector2(1f, 1f);
  1003. headerText.GetComponent<RectTransform>().sizeDelta = new Vector2(205f, 90f);
  1004. headerText.GetComponent<RectTransform>().anchoredPosition=new Vector2(-210f,0f);
  1005. }else{
  1006. headerText.GetComponent<RectTransform>().anchorMin = new Vector2(1f, 1f);
  1007. headerText.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f);
  1008. headerText.GetComponent<RectTransform>().pivot = new Vector2(1f, 1f);
  1009. headerText.GetComponent<RectTransform>().sizeDelta = new Vector2(205f, 90f);
  1010. headerText.GetComponent<RectTransform>().anchoredPosition=new Vector2(0f,0f);
  1011. }
  1012. }
  1013. for(int j = 0; j <= table.Columns.Count-2; j++){
  1014. GameObject Separation2 = Instantiate(LinePrefab, 客戶清單表頭_pl.transform);
  1015. Separation2.GetComponent<RectTransform>().sizeDelta = new Vector2(5f,客戶清單表頭_pl.GetComponent<RectTransform>().sizeDelta.y-5f);
  1016. Separation2.GetComponent<RectTransform>().anchorMin = new Vector2(1f, 1f);
  1017. Separation2.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f);
  1018. Separation2.GetComponent<RectTransform>().pivot = new Vector2(1f, 1f);
  1019. Separation2.GetComponent<Image>().color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  1020. if(j==0){
  1021. Separation2.GetComponent<RectTransform>().anchoredPosition = new Vector2(-205f,-3f);
  1022. }else{
  1023. Separation2.GetComponent<RectTransform>().anchoredPosition = new Vector2(-415f,-3f);
  1024. }
  1025. }
  1026. TextMeshProUGUI[] texts = 客戶清單表頭_pl.GetComponentsInChildren<TextMeshProUGUI>();
  1027. foreach (TextMeshProUGUI text in texts){
  1028. if(text.tag.Contains("Cells")){
  1029. text.font = myFont;
  1030. text.color = Global.系統主題 == 1 ? new Color(0, 0, 0, 1) : text.color;
  1031. text.alignment = TextAlignmentOptions.Center;
  1032. text.fontStyle = FontStyles.Bold;
  1033. text.fontSize=42;
  1034. text.margin = new Vector4(10, 0, 10, 0);
  1035. }else{
  1036. }
  1037. }
  1038. //==========================================
  1039. Module.清除控件(ceneter);
  1040. Image centerImage = ceneter.GetComponent<Image>();
  1041. if(centerImage == null){
  1042. centerImage = ceneter.AddComponent<Image>();
  1043. centerImage.type = Image.Type.Sliced;
  1044. }
  1045. centerImage.sprite = UIsprite;
  1046. centerImage.fillCenter = false;
  1047. centerImage.color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  1048. for (int i = 0; i < table.Rows.Count; i++){
  1049. GameObject row = Instantiate(rowPrefab, tableParent);
  1050. row.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, (-90 * i)+(-5*i));
  1051. for (int j = 0; j < table.Columns.Count; j++){
  1052. string value = table.Rows[i][j].ToString();
  1053. GameObject cellText = new(table_name+"_Cells_"+i.ToString()+"_"+j.ToString());
  1054. cellText.transform.SetParent(row.transform, false);
  1055. cellText.AddComponent<TextMeshProUGUI>().text = value;
  1056. cellText.GetComponent<TextMeshProUGUI>().tag="Cells";
  1057. if(overflowMode){cellText.GetComponent<TextMeshProUGUI>().overflowMode=TextOverflowModes.Ellipsis;}
  1058. cellText.AddComponent<Button>();
  1059. cellText.GetComponent<Button>().onClick.AddListener(() => { 按鈕事件(cellText); });
  1060. if(j==0){
  1061. cellText.GetComponent<RectTransform>().anchoredPosition=new Vector2(0f,0f);
  1062. cellText.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
  1063. cellText.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
  1064. cellText.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
  1065. float x = ceneter.GetComponent<RectTransform>().rect.width -420f;
  1066. cellText.GetComponent<RectTransform>().sizeDelta = new Vector2(x, 90f);
  1067. }else if(j==1){
  1068. cellText.GetComponent<RectTransform>().anchorMin = new Vector2(1f, 1f);
  1069. cellText.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f);
  1070. cellText.GetComponent<RectTransform>().pivot = new Vector2(1f, 1f);
  1071. cellText.GetComponent<RectTransform>().sizeDelta = new Vector2(205f, 90f);
  1072. cellText.GetComponent<RectTransform>().anchoredPosition=new Vector2(-210f,0f);
  1073. }else{
  1074. cellText.GetComponent<RectTransform>().anchorMin = new Vector2(1f, 1f);
  1075. cellText.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f);
  1076. cellText.GetComponent<RectTransform>().pivot = new Vector2(1f, 1f);
  1077. cellText.GetComponent<RectTransform>().sizeDelta = new Vector2(205, 90f);
  1078. cellText.GetComponent<RectTransform>().anchoredPosition=new Vector2(0f,0f);
  1079. }
  1080. }
  1081. }
  1082. texts = ceneter.GetComponentsInChildren<TextMeshProUGUI>();
  1083. foreach (TextMeshProUGUI text in texts){
  1084. if(text.tag.Contains("Cells")){
  1085. text.font = myFont;
  1086. text.color = Global.系統主題 == 1 ? new Color(0, 0, 0, 1) : text.color;
  1087. text.alignment = TextAlignmentOptions.Center;
  1088. //text.fontStyle = FontStyles.Bold;
  1089. text.fontSize=42;
  1090. //text.enableAutoSizing = true;
  1091. //text.autoSizeTextContainer = true;
  1092. text.margin = new Vector4(10, 0, 10, 0);
  1093. }else{
  1094. }
  1095. }
  1096. ceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(ceneter.GetComponent<RectTransform>().sizeDelta.x,table.Rows.Count*90f +((table.Rows.Count-1)*5f));
  1097. //========建立分隔線=============
  1098. for(int i=0;i<=table.Columns.Count-2;i++){
  1099. GameObject Separation = Instantiate(LinePrefab, tableParent);
  1100. Separation.GetComponent<RectTransform>().sizeDelta = new Vector2(5f,ceneter.GetComponent<RectTransform>().sizeDelta.y-5f);
  1101. Separation.GetComponent<RectTransform>().anchorMin = new Vector2(1f, 1f);
  1102. Separation.GetComponent<RectTransform>().anchorMax = new Vector2(1f, 1f);
  1103. Separation.GetComponent<RectTransform>().pivot = new Vector2(1f, 1f);
  1104. Separation.GetComponent<Image>().color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  1105. Separation.GetComponent<RectTransform>().anchoredPosition = new Vector2(-210f*i-205f,-3f);
  1106. }
  1107. for(int i=1;i<=table.Rows.Count-1;i++){
  1108. GameObject Separation2 = Instantiate(LinePrefab, tableParent);
  1109. Separation2.GetComponent<RectTransform>().sizeDelta = new Vector2(ceneter.GetComponent<RectTransform>().rect.width-5f,5f);
  1110. Separation2.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
  1111. Separation2.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
  1112. Separation2.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
  1113. Separation2.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 5f * (1 - 19 * i));
  1114. Separation2.GetComponent<Image>().color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  1115. }
  1116. }
  1117. private void Set_長照物料清單(string 類別,string 編號,Transform tableParent,GameObject rowPrefab,GameObject ceneter,GameObject LinePrefab,string 清單名稱){
  1118. SQL_Comm.SQL_報告書_項目物料清單(類別,編號);
  1119. // 客戶編號, 來電日期, 申請人, 聯繫人, 聯繫電話, 地址, 需求, 特殊需求
  1120. DataSet ds1 = new();
  1121. SQL_Module.da.Fill(ds1);
  1122. for(int i=0;i<=ds1.Tables[0].Rows.Count-1;i++){
  1123. ds1.Tables[0].Rows[i][0]=ds1.Tables[0].Rows[i][1].ToString()+"-"+ds1.Tables[0].Rows[i][2].ToString();
  1124. }
  1125. Global.長照物料清單_tabel = ds1.Tables[0];
  1126. string[] columnNames = new string[]{ds1.Tables[0].Columns[0].ColumnName};
  1127. DataTable table1 = ds1.Tables[0].DefaultView.ToTable(false, columnNames);
  1128. 載入長照物料清單表格(清單名稱,table1,tableParent,rowPrefab,ceneter,myFont,UIsprite,LinePrefab,true);
  1129. //載入長照物料清單表格("項目物料清單",table1,tableParent,rowPrefab,ceneter,myFont,UIsprite,LinePrefab,true);
  1130. }
  1131. private void 載入長照物料清單表格(string table_name,DataTable table,Transform tableParent,GameObject rowPrefab,GameObject ceneter,TMP_FontAsset myFont,Sprite UIsprite,
  1132. GameObject LinePrefab,bool overflowMode){
  1133. Module.清除控件(ceneter);
  1134. Image centerImage = ceneter.GetComponent<Image>();
  1135. if(centerImage == null){
  1136. centerImage = ceneter.AddComponent<Image>();
  1137. centerImage.type = Image.Type.Sliced;
  1138. }
  1139. centerImage.sprite = UIsprite;
  1140. centerImage.fillCenter = false;
  1141. centerImage.color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  1142. for (int i = 0; i < table.Rows.Count; i++){
  1143. GameObject row = Instantiate(rowPrefab, tableParent);
  1144. row.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, (-90 * i)+(-5*i));
  1145. string value = table.Rows[i][0].ToString();
  1146. GameObject cellText = new(table_name+"_Cells_"+i.ToString().PadLeft(2,'0'));
  1147. cellText.transform.SetParent(row.transform, false);
  1148. cellText.AddComponent<TextMeshProUGUI>().text = value;
  1149. cellText.GetComponent<TextMeshProUGUI>().tag="Cells";
  1150. if(overflowMode){cellText.GetComponent<TextMeshProUGUI>().overflowMode=TextOverflowModes.Ellipsis;}
  1151. cellText.AddComponent<Button>();
  1152. cellText.GetComponent<Button>().onClick.AddListener(() => { 按鈕事件(cellText); });
  1153. cellText.GetComponent<RectTransform>().anchoredPosition=new Vector2(0f,0f);
  1154. cellText.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
  1155. cellText.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
  1156. cellText.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
  1157. cellText.GetComponent<RectTransform>().sizeDelta = new Vector2(ceneter.GetComponent<RectTransform>().rect.width, 90f);
  1158. }
  1159. TextMeshProUGUI[] texts = ceneter.GetComponentsInChildren<TextMeshProUGUI>();
  1160. foreach (TextMeshProUGUI text in texts){
  1161. if(text.tag.Contains("Cells")){
  1162. text.font = myFont;
  1163. text.color = Global.系統主題 == 1 ? new Color(0, 0, 0, 1) : text.color;
  1164. text.alignment = TextAlignmentOptions.Left;
  1165. text.fontStyle = FontStyles.Bold;
  1166. text.fontSize = 30;
  1167. text.margin = new Vector4(10, 0, 10, 0);
  1168. }else{
  1169. }
  1170. }
  1171. ceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(ceneter.GetComponent<RectTransform>().sizeDelta.x,table.Rows.Count*90f+((table.Rows.Count-1)*5f));
  1172. //========建立分隔線=============
  1173. for(int i=1;i<=table.Rows.Count-1;i++){
  1174. GameObject Separation2 = Instantiate(LinePrefab, tableParent);
  1175. Separation2.GetComponent<RectTransform>().sizeDelta = new Vector2(ceneter.GetComponent<RectTransform>().rect.width-5f,5f);
  1176. Separation2.GetComponent<RectTransform>().anchorMin = new Vector2(0f, 1f);
  1177. Separation2.GetComponent<RectTransform>().anchorMax = new Vector2(0f, 1f);
  1178. Separation2.GetComponent<RectTransform>().pivot = new Vector2(0f, 1f);
  1179. Separation2.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 5f * (1 - 19 * i));
  1180. Separation2.GetComponent<Image>().color = Main.Global.系統主題 == 1 ? new Color(0f, 0f, 0f, 1f) : new Color(1f, 1f, 1f, 1f);
  1181. }
  1182. }
  1183. public void 按鈕事件(GameObject cell_text){
  1184. if(cell_text.name.Contains("報告書清單")){
  1185. string row=cell_text.name.Substring(cell_text.name.Length-3,1);
  1186. 返回2_bt.SetActive(false);返回3_bt.SetActive(true);
  1187. 報告書流水號_tb.text = Global.報告書清單_tabel.Rows[int.Parse(row)][0].ToString();
  1188. 報告書項目清單_報告書號_tb.text = Global.報告書清單_tabel.Rows[int.Parse(row)][0].ToString();
  1189. 報告書人員清單_pl.SetActive(false);報告書人員資料_pl.SetActive(false);報告書項目清單_pl.SetActive(true);
  1190. }else if(cell_text.name.Contains("報告書人員清單")){
  1191. //Set_報告書人員資料();
  1192. Debug.Log(cell_text.name);
  1193. Match match = Regex.Match(cell_text.name, @"_(\d+)_");
  1194. string row=match.Groups[1].Value;
  1195. Debug.Log(row);
  1196. string 客戶編號 = Global.報告書人員清單_tabel.Rows[int.Parse(row)]["客戶編號"].ToString();
  1197. string 申請人 = Global.報告書人員清單_tabel.Rows[int.Parse(row)]["申請人"].ToString();
  1198. string 聯繫人 = Global.報告書人員清單_tabel.Rows[int.Parse(row)]["聯繫人"].ToString();
  1199. string 聯繫人電話 = Global.報告書人員清單_tabel.Rows[int.Parse(row)]["聯繫電話"].ToString();
  1200. string 住址 = Global.報告書人員清單_tabel.Rows[int.Parse(row)]["地址"].ToString();
  1201. string 聯繫人2 = Global.報告書人員清單_tabel.Rows[int.Parse(row)]["聯繫人3"].ToString();
  1202. string 聯繫人2電話 = Global.報告書人員清單_tabel.Rows[int.Parse(row)]["聯繫人3電話"].ToString();
  1203. Set_報告書清單(客戶編號,申請人,聯繫人,聯繫人電話,住址,聯繫人2,聯繫人2電話);
  1204. }else if(cell_text.name.Contains("文件號清單")){
  1205. Module.清除底色(文件號清單_ct);Global.報告書物料明細流水號="";Global.報告書物料料號 ="";報告書扶手總長_tb.text="";單項扶手長度_tb.text="";
  1206. cell_text.GetComponentInParent<Image>().color = new Color(0.67f,1f,0.4f,1f);
  1207. string 文件號id = cell_text.GetComponent<TextMeshProUGUI>().text;
  1208. for(int i=0;i<=Global.文件號清單_table.Rows.Count-1;i++){
  1209. if(文件號id==Global.文件號清單_table.Rows[i][0].ToString()){
  1210. Global.報告書文件號 =Global.文件號清單_table.Rows[i][1].ToString();
  1211. }
  1212. }
  1213. if(Global.報告書施工狀態!="文件號"){
  1214. PhotoScroll.清除currentPage();
  1215. }else{
  1216. 載入施工圖片();
  1217. }
  1218. 載入報告書項目清單(Global.報告書文件號);
  1219. }else if(cell_text.name.Contains("報告書項目清單")){
  1220. Module.清除底色(報告書項目清單_ct);
  1221. cell_text.GetComponentInParent<Image>().color = new Color(0.67f,1f,0.4f,1f);
  1222. string row=cell_text.name.Substring(cell_text.name.Length-3,1);
  1223. Global.報告書物料料號 = cell_text.GetComponent<TextMeshProUGUI>().text;
  1224. Global.報告書物料明細流水號 = Global.報告書項目清單_tabel.Rows[int.Parse(row)][0].ToString();
  1225. if(cell_text.GetComponent<TextMeshProUGUI>().text=="FA01" || cell_text.GetComponent<TextMeshProUGUI>().text=="137" ||
  1226. cell_text.GetComponent<TextMeshProUGUI>().text=="FA09" || cell_text.GetComponent<TextMeshProUGUI>().text=="152"){
  1227. if(cell_text.GetComponent<TextMeshProUGUI>().text=="FA01" || cell_text.GetComponent<TextMeshProUGUI>().text=="137"){
  1228. 扶手總長2_lb.text="扶手總長";
  1229. 扶手長度_lb.text="扶手長度";
  1230. 請輸入扶手總長度_lb.text="請輸入扶手總長度";
  1231. 扶手總長度_lb.text="扶手總長度";
  1232. 已使用扶手長度_lb.text="已使用扶手長度";
  1233. 可使用扶手長度_lb.text="可使用扶手長度";
  1234. 扶手長度2_lb.text="扶手長度";
  1235. }else{
  1236. 扶手總長2_lb.text="總單位";
  1237. 扶手長度_lb.text="單位";
  1238. 請輸入扶手總長度_lb.text="請輸入總單位";
  1239. 扶手總長度_lb.text="總單位";
  1240. 已使用扶手長度_lb.text="已使用單位";
  1241. 可使用扶手長度_lb.text="可使用單位";
  1242. 扶手長度2_lb.text="單位";
  1243. }
  1244. 報告書扶手總長_tb.text = Global.報告書項目清單_tabel.Rows[int.Parse(row)][2].ToString();
  1245. }else{
  1246. 報告書扶手總長_tb.text = "不適用";
  1247. 單項扶手長度_tb.text = "不適用";
  1248. }
  1249. if(Global.報告書施工狀態!="文件號"){
  1250. 載入施工圖片();
  1251. PhotoScroll.清除currentPage();
  1252. }
  1253. }else if(cell_text.name.Contains("客戶清單")){
  1254. int NUM1;string dat1,報告書號;
  1255. Set_日期格式轉換();SQL_Comm.SQL_取得加盟商編號(Global.gUser區域);
  1256. if(SQL_Module.dr.Read()){
  1257. Global.gUser加盟商編號=SQL_Module.dr[0].ToString();
  1258. }else{
  1259. Global.gUser加盟商編號="未設定加盟商";
  1260. }
  1261. SQL_Comm.SQL_報告書_查詢流水號(Global.gUser區域);
  1262. if(SQL_Module.dr.Read()){
  1263. 報告書號 = SQL_Module.dr["流水號"].ToString();
  1264. }else{
  1265. 報告書號 = "RE" + Global.DTP1[2..] + "00-" + Global.gUser加盟商編號;
  1266. }
  1267. dat1 = 報告書號.Substring(2, 6);
  1268. if(dat1 != Global.DTP1[2..]){
  1269. NUM1 = 1;
  1270. }else{
  1271. NUM1 = int.Parse(報告書號.Substring(8, 2)) + 1;
  1272. }
  1273. 報告書號 = "RE" + Global.DTP1[2..] + NUM1.ToString().PadLeft(2, '0') + "-" + Global.gUser加盟商編號;
  1274. string 圖檔資料庫;
  1275. SQL_Comm.SQL_查詢圖檔資料庫();
  1276. if(SQL_Module.dr.Read()){
  1277. 圖檔資料庫 = SQL_Module.dr[0].ToString();
  1278. string 日期 = DateTime.Today.Year.ToString().PadLeft(4,'0')+"/"+DateTime.Today.Month.ToString().PadLeft(2,'0')+"/"+DateTime.Today.Day.ToString().PadLeft(2,'0');
  1279. SQL_Comm.SQL_報告書_新增(報告書號,cell_text.GetComponent<TextMeshProUGUI>().text, 日期, Global.使用者暱稱, Global.gUser區域, 圖檔資料庫);
  1280. 主頁面調整(false,true,false);
  1281. 回上頁_bt.SetActive(true);拍照_bt.SetActive(true);業務系統_bt.SetActive(false);系統設定_bt.SetActive(false);
  1282. 新增項目_bt.SetActive(true);刪除項目_bt.SetActive(true);
  1283. 選擇客戶_pl.SetActive(false);評估詳細_pl.SetActive(true);評估主頁_pl.SetActive(false);
  1284. 報告書流水號_tb.text=報告書號;
  1285. 載入報告書詳細資料(報告書號);
  1286. }else{
  1287. 彈跳_pl.SetActive(true);
  1288. 彈跳文字_tb.text="無可用資料庫,請通知系統商新增資料庫";
  1289. Global.彈跳判斷="新增報告書";
  1290. }
  1291. }else if(cell_text.name.Contains("項目物料清單")){
  1292. 報告書圖片_pl.SetActive(true);新增項目_pl.SetActive(false);
  1293. string 物料料號;
  1294. string row=cell_text.name.Substring(cell_text.name.Length-2,2);
  1295. 物料料號=Global.長照物料清單_tabel.Rows[int.Parse(row)][1].ToString();
  1296. if(物料料號=="FA01" || 物料料號=="137" || 物料料號=="FA09" || 物料料號=="152"){
  1297. if(物料料號=="FA01" || 物料料號=="137"){
  1298. 扶手總長2_lb.text="扶手總長";
  1299. 扶手長度_lb.text="扶手長度";
  1300. 請輸入扶手總長度_lb.text="請輸入扶手總長度";
  1301. 扶手總長度_lb.text="扶手總長度";
  1302. 已使用扶手長度_lb.text="已使用扶手長度";
  1303. 可使用扶手長度_lb.text="可使用扶手長度";
  1304. 扶手長度2_lb.text="扶手長度";
  1305. }else{
  1306. 扶手總長2_lb.text="總單位";
  1307. 扶手長度_lb.text="單位";
  1308. 請輸入扶手總長度_lb.text="請輸入總單位";
  1309. 扶手總長度_lb.text="總單位";
  1310. 已使用扶手長度_lb.text="已使用單位";
  1311. 可使用扶手長度_lb.text="可使用單位";
  1312. 扶手長度2_lb.text="單位";
  1313. }
  1314. Global.輸入物料料號=物料料號;
  1315. 輸入扶手長度_pl.SetActive(true);
  1316. }else{
  1317. SQL_Comm.SQL_報告書_讀取流水號();
  1318. string 明細流水號;double NUM;
  1319. if(SQL_Module.dr.Read()){明細流水號 = SQL_Module.dr["流水號"].ToString();}else{明細流水號 = "WS00000000";}
  1320. NUM = double.Parse(明細流水號.Substring(2, 8)) + 1;
  1321. 明細流水號 = "WS" + NUM.ToString().PadLeft(8, '0');
  1322. SQL_Comm.SQL_報告書_明細寫入(明細流水號, Global.報告書文件號, 物料料號, "", 報告書流水號_tb.text,"0");
  1323. 載入報告書項目清單(Global.報告書文件號);
  1324. }
  1325. }else if(cell_text.name.Contains("報告書評估報告書1清單")){
  1326. Module.清除底色(報告書施作項目清單_ct);
  1327. cell_text.GetComponentInParent<Image>().color = new Color(0.67f,1f,0.4f,1f);
  1328. string row=cell_text.name.Substring(cell_text.name.Length-3,1);
  1329. Global.報告書物料料號 = Global.報告書評估報告書1清單_tabel.Rows[int.Parse(row)][2].ToString();
  1330. Global.報告書物料明細流水號 = Global.報告書評估報告書1清單_tabel.Rows[int.Parse(row)][0].ToString();
  1331. 施工前_img.color = new Color(1f,1f,1f,1f);
  1332. 施工後_img.color = new Color(1f,1f,1f,1f);
  1333. 限制圖片不超過Panel範圍2();施作圖片_img.sprite =null;
  1334. PhotoScroll.清除currentPage();
  1335. }else if(cell_text.name.Contains("報告書評估報告書2清單")){
  1336. Module.清除底色(報告書施作項目清單_ct);
  1337. cell_text.GetComponentInParent<Image>().color = new Color(0.67f,1f,0.4f,1f);
  1338. string row=cell_text.name.Substring(cell_text.name.Length-3,1);
  1339. Global.報告書物料料號 = Global.報告書評估報告書2清單_tabel.Rows[int.Parse(row)][2].ToString();
  1340. Global.報告書物料明細流水號 = Global.報告書評估報告書2清單_tabel.Rows[int.Parse(row)][0].ToString();
  1341. 施工前_img.color = new Color(1f,1f,1f,1f);
  1342. 施工後_img.color = new Color(1f,1f,1f,1f);
  1343. 限制圖片不超過Panel範圍2();施作圖片_img.sprite =null;
  1344. PhotoScroll.清除currentPage();
  1345. }else if(cell_text.name.Contains("評估報告書1物料清單")){
  1346. 評估報告書1_物料清單_sv.SetActive(false);返回6_bt.SetActive(true);施作圖片_pl.SetActive(true);返回7_bt.SetActive(false);
  1347. string 物料料號;
  1348. string row=cell_text.name.Substring(cell_text.name.Length-2,2);
  1349. 物料料號=Global.長照物料清單_tabel.Rows[int.Parse(row)][1].ToString();
  1350. SQL_Comm.SQL_報告書_讀取流水號();
  1351. string 明細流水號;double NUM;
  1352. if(SQL_Module.dr.Read()){明細流水號 = SQL_Module.dr["流水號"].ToString();}else{明細流水號 = "WS00000000";}
  1353. NUM = double.Parse(明細流水號.Substring(2, 8)) + 1;
  1354. 明細流水號 = "WS" + NUM.ToString().PadLeft(8, '0');
  1355. SQL_Comm.SQL_報告書_明細寫入(明細流水號,"評估報告書1", 物料料號, "", 報告書流水號_tb.text,"0");
  1356. Set_評估報告書1清單("評估報告書1");
  1357. }else if(cell_text.name.Contains("評估報告書2物料清單")){
  1358. 評估報告書1_物料清單_sv.SetActive(false);返回6_bt.SetActive(true);施作圖片_pl.SetActive(true);返回7_bt.SetActive(false);
  1359. string 物料料號;
  1360. string row=cell_text.name.Substring(cell_text.name.Length-2,2);
  1361. 物料料號=Global.長照物料清單_tabel.Rows[int.Parse(row)][1].ToString();
  1362. SQL_Comm.SQL_報告書_讀取流水號();
  1363. string 明細流水號;double NUM;
  1364. if(SQL_Module.dr.Read()){明細流水號 = SQL_Module.dr["流水號"].ToString();}else{明細流水號 = "WS00000000";}
  1365. NUM = double.Parse(明細流水號.Substring(2, 8)) + 1;
  1366. 明細流水號 = "WS" + NUM.ToString().PadLeft(8, '0');
  1367. SQL_Comm.SQL_報告書_明細寫入(明細流水號,"評估報告書2", 物料料號, "", 報告書流水號_tb.text,"0");
  1368. Set_評估報告書1清單("評估報告書2");
  1369. }
  1370. }
  1371. private void 載入圖片清單2(string 階段,GameObject 圖片讀取){
  1372. 圖片讀取.SetActive(true);
  1373. SQL_Comm.SQL_取得報告書資料(報告書項目清單_報告書號_tb.text);
  1374. if(SQL_Module.dr.Read()){
  1375. 報告書申請人_tb.text = SQL_Module.dr["負責人"].ToString();
  1376. 報告書開立人_tb.text = SQL_Module.dr["開立人"].ToString();
  1377. Global.圖檔資料庫 = SQL_Module.dr["圖檔資料庫"].ToString();
  1378. Debug.Log(Global.圖檔資料庫);
  1379. SQL_CommString.SQL_連線字串_圖片_SQL(Global.圖檔資料庫,Global.資料庫IP);
  1380. SQL_Comm.SQL_報告書_施工圖片清單(報告書項目清單_報告書號_tb.text,階段,Global.報告書選項2,Global.報告書物料料號,Global.報告書物料明細流水號);
  1381. DataSet ds1 = new();
  1382. SQL_Module.da.Fill(ds1);
  1383. 目前階段2 = 階段;
  1384. if(ds1.Tables[0].Rows.Count>0){
  1385. 施作圖片相片目前_tb.text="1";施作圖片相片總數_tb.text=ds1.Tables[0].Rows.Count.ToString();
  1386. 施作圖片相片文件號_tb.text = ds1.Tables[0].Rows[0][0].ToString();
  1387. 圖片讀取.SetActive(true);
  1388. 載入報告書圖片3(階段);
  1389. 圖片讀取.SetActive(false);
  1390. }else{
  1391. 施作圖片相片目前_tb.text="-";施作圖片相片總數_tb.text="-";施作圖片相片文件號_tb.text ="文件號";
  1392. 施作圖片_img.sprite = null;圖片讀取.SetActive(false);
  1393. }
  1394. Global.報告書施作圖片_table = ds1.Tables[0];
  1395. }
  1396. }
  1397. private void 載入報告書圖片3(string 階段){
  1398. SQL_Comm.SQL_報告書_施作讀取圖片(報告書項目清單_報告書號_tb.text,階段,Global.報告書選項2,Global.報告書物料料號,Global.報告書物料明細流水號,施作圖片相片文件號_tb.text);
  1399. if (SQL_Module.dr.Read() && !SQL_Module.dr.IsDBNull(0)){
  1400. byte[] imageData = (byte[])SQL_Module.dr["圖片"];
  1401. Sprite sp = ByteArrayToSprite(imageData);
  1402. 施作圖片_img.sprite =sp;
  1403. 施作圖片_img.preserveAspect = true;
  1404. 施作圖片_img.SetNativeSize();
  1405. 限制圖片不超過Panel範圍2();
  1406. }
  1407. }
  1408. private void 限制圖片不超過Panel範圍2(){
  1409. RectTransform imageRT = 施作圖片_img.GetComponent<RectTransform>();
  1410. RectTransform panelRT = 施作圖片_img.transform.parent.GetComponent<RectTransform>();
  1411. float panelWidth = panelRT.rect.width;
  1412. float panelHeight = panelRT.rect.height;
  1413. float imageWidth = imageRT.rect.width;
  1414. float imageHeight = imageRT.rect.height;
  1415. float widthRatio = panelWidth / imageWidth;
  1416. float heightRatio = panelHeight / imageHeight;
  1417. float minRatio = Mathf.Min(widthRatio, heightRatio, 1f);
  1418. imageRT.sizeDelta = new Vector2(imageWidth * minRatio, imageHeight * minRatio);
  1419. imageRT.anchoredPosition = Vector2.zero;
  1420. }
  1421. public void 下一張圖片2(){
  1422. int currentIndex = int.Parse(施作圖片相片目前_tb.text);
  1423. int total = Global.報告書施作圖片_table.Rows.Count;
  1424. if (currentIndex < total){
  1425. currentIndex++;
  1426. 施作圖片相片目前_tb.text = currentIndex.ToString();
  1427. 施作圖片相片文件號_tb.text = Global.報告書施作圖片_table.Rows[currentIndex - 1][0].ToString();
  1428. 載入報告書圖片3(目前階段2);
  1429. }else{
  1430. }
  1431. }
  1432. public void 上一張圖片2(){
  1433. int currentIndex = int.Parse(施作圖片相片目前_tb.text);
  1434. if (currentIndex > 1){
  1435. currentIndex--;
  1436. 施作圖片相片目前_tb.text = currentIndex.ToString();
  1437. 施作圖片相片文件號_tb.text = Global.報告書施作圖片_table.Rows[currentIndex - 1][0].ToString();
  1438. 載入報告書圖片3(目前階段2);
  1439. }else{
  1440. }
  1441. }
  1442. public void 施工前2(){
  1443. 施工前_img.color = new Color(0.67f,1f,0.4f,1f);
  1444. 施工後_img.color = new Color(1f,1f,1f,1f);
  1445. 產品序號_img.color = new Color(1f,1f,1f,1f);
  1446. Global.報告書施工狀態="施工前";
  1447. 拍照1_bt.SetActive(true);刪除1_bt.SetActive(true);存檔1_bt.SetActive(true);
  1448. 載入圖片清單2(Global.報告書施工狀態,施作圖片圖片讀取_pl);
  1449. PhotoScroll.清除currentPage();
  1450. }
  1451. public void 施工後2(){
  1452. 施工前_img.color = new Color(1f,1f,1f,1f);
  1453. 施工後_img.color = new Color(0.67f,1f,0.4f,1f);
  1454. 產品序號_img.color = new Color(1f,1f,1f,1f);
  1455. 拍照1_bt.SetActive(true);刪除1_bt.SetActive(true);存檔1_bt.SetActive(true);
  1456. Global.報告書施工狀態="施工後";
  1457. 載入圖片清單2(Global.報告書施工狀態,施作圖片圖片讀取_pl);
  1458. PhotoScroll.清除currentPage();
  1459. }
  1460. public void 產品序號2(){
  1461. 施工前_img.color = new Color(1f,1f,1f,1f);
  1462. 施工後_img.color = new Color(1f,1f,1f,1f);
  1463. 產品序號_img.color = new Color(0.67f,1f,0.4f,1f);
  1464. 拍照1_bt.SetActive(true);刪除1_bt.SetActive(true);存檔1_bt.SetActive(true);
  1465. Global.報告書施工狀態="產品序號";
  1466. 載入圖片清單2(Global.報告書施工狀態,施作圖片圖片讀取_pl);
  1467. PhotoScroll.清除currentPage();
  1468. }
  1469. private void 載入施工圖片(){
  1470. 圖片讀取_pl.SetActive(true);
  1471. Module.清除控件(報告書施工圖片_ct);
  1472. if(Global.報告書施工狀態=="文件號"){
  1473. SQL_Comm.SQL_報告書_報告書圖片清單(報告書流水號_tb.text,"報告書",Global.報告書文件號);
  1474. }else{
  1475. SQL_Comm.SQL_報告書_施工圖片清單(報告書流水號_tb.text,Global.報告書施工狀態,Global.報告書文件號,Global.報告書物料料號,Global.報告書物料明細流水號);
  1476. }
  1477. DataSet ds1 = new();
  1478. SQL_Module.da.Fill(ds1);
  1479. if(ds1.Tables[0].Rows.Count>0){
  1480. 相片目前_tb.text="1";相片總數_tb.text=ds1.Tables[0].Rows.Count.ToString();更換照片_bt.SetActive(true);刪除照片_bt.SetActive(true);
  1481. }else{
  1482. 相片目前_tb.text="-";相片總數_tb.text="-";更換照片_bt.SetActive(false);刪除照片_bt.SetActive(false);
  1483. }
  1484. Global.報告書施工圖片_table = ds1.Tables[0];
  1485. 報告書施工圖片_ct.GetComponent<RectTransform>().sizeDelta=new Vector2(圖片寬度_pl.GetComponent<RectTransform>().rect .width,報告書施工圖片_ct.GetComponent<RectTransform>().sizeDelta.y);
  1486. 報告書施工圖片_rpf.GetComponent<RectTransform>().sizeDelta=new Vector2(圖片寬度_pl.GetComponent<RectTransform>().rect .width,報告書施工圖片_rpf.GetComponent<RectTransform>().sizeDelta.y);
  1487. 載入報告書圖片("報告書施工圖片",ds1.Tables[0],報告書施工圖片_tp,報告書施工圖片_rpf,報告書施工圖片_ct,myFont,UIsprite,報告書施工圖片_lpf,true);
  1488. if(Global.報告書施工狀態 == "施工前" && ds1.Tables[0].Rows.Count > 0 && (Global.報告書物料料號 == "FA01" || Global.報告書物料料號 == "137" || Global.報告書物料料號 == "FA09" || Global.報告書物料料號 == "152")){
  1489. if(Global.報告書物料料號=="FA01" || Global.報告書物料料號=="137"){
  1490. 扶手總長2_lb.text="扶手總長";
  1491. 扶手長度_lb.text="扶手長度";
  1492. 請輸入扶手總長度_lb.text="請輸入扶手總長度";
  1493. 扶手總長度_lb.text="扶手總長度";
  1494. 已使用扶手長度_lb.text="已使用扶手長度";
  1495. 可使用扶手長度_lb.text="可使用扶手長度";
  1496. 扶手長度2_lb.text="扶手長度";
  1497. }else{
  1498. 扶手總長2_lb.text="總單位";
  1499. 扶手長度_lb.text="單位";
  1500. 請輸入扶手總長度_lb.text="請輸入總單位";
  1501. 扶手總長度_lb.text="總單位";
  1502. 已使用扶手長度_lb.text="已使用單位";
  1503. 可使用扶手長度_lb.text="可使用單位";
  1504. 扶手長度2_lb.text="單位";
  1505. }
  1506. string 文件號 = Global.報告書施工圖片_table.Rows[0][0].ToString();
  1507. if(Global.報告書施工圖檔文件號==""){Global.報告書施工圖檔文件號 = 文件號;}
  1508. SQL_Comm.SQL_報告書_施工圖檔扶手長度(報告書流水號_tb.text,Global.報告書文件號,Global.報告書物料料號,Global.報告書物料明細流水號,文件號);
  1509. if(SQL_Module.dr.Read()){
  1510. 單項扶手長度_tb.text=SQL_Module.dr[0].ToString();
  1511. }else{
  1512. 單項扶手長度_tb.text="";
  1513. }
  1514. }
  1515. 圖片讀取_pl.SetActive(false);
  1516. }
  1517. private void 主頁面調整(bool 首頁,bool 評估,bool 新建){
  1518. 首頁_pl.SetActive(首頁);評估_pl.SetActive(評估);新建_pl.SetActive(新建);
  1519. }
  1520. public void 開啟系統設定(){
  1521. 主頁面調整(true,false,false);
  1522. 評估紀錄_pl.SetActive(false);
  1523. 系統設定_pl.SetActive(true);
  1524. }
  1525. public void 開啟首頁(){
  1526. 主頁面調整(true,false,false);
  1527. 評估紀錄_pl.SetActive(true);
  1528. 系統設定_pl.SetActive(false);
  1529. Module.清除底色(文件號清單_ct);
  1530. Module.清除底色(報告書項目清單_ct);
  1531. Module.清除控件(報告書施工圖片_ct);
  1532. Global.報告書文件號="";Global.報告書物料料號="";Global.報告書物料明細流水號="";
  1533. }
  1534. public void 開啟評估頁面(){
  1535. 主頁面調整(false,true,false);
  1536. 系統設定_pl.SetActive(false);
  1537. Set_報告書人員清單("");
  1538. }
  1539. public void 開啟新建報告書頁面(){
  1540. 主頁面調整(false,false,true);
  1541. 選擇客戶_pl.SetActive(true);
  1542. Set_客戶清單();
  1543. }
  1544. public void 輸入扶手長度完畢(){
  1545. if(Global.輸入物料料號=="" || 輸入扶手總長_tb.text==""){
  1546. 輸入扶手長度_pl.SetActive(false);
  1547. 彈跳_pl.SetActive(true);
  1548. 彈跳文字_tb.text="輸入資料有誤!";
  1549. Global.彈跳判斷="輸入扶手長度";
  1550. }else{
  1551. SQL_Comm.SQL_報告書_讀取流水號();
  1552. string 明細流水號;double NUM;
  1553. if(SQL_Module.dr.Read()){明細流水號 = SQL_Module.dr["流水號"].ToString();}else{明細流水號 = "WS00000000";}
  1554. NUM = double.Parse(明細流水號.Substring(2, 8)) + 1;
  1555. 明細流水號 = "WS" + NUM.ToString().PadLeft(8, '0');
  1556. SQL_Comm.SQL_報告書_明細寫入(明細流水號, Global.報告書文件號, Global.輸入物料料號, "", 報告書流水號_tb.text,輸入扶手總長_tb.text);
  1557. 載入報告書項目清單(Global.報告書文件號);
  1558. 輸入扶手長度_pl.SetActive(false);
  1559. }
  1560. }
  1561. public void 輸入單項扶手長度完畢(){
  1562. double 扶手可使用長度 = double.Parse(扶手可使用長度_tb.text);double 扶手長度;
  1563. if(扶手長度_tb.text==""){扶手長度=0;}else{扶手長度=double.Parse(扶手長度_tb.text);}
  1564. if(扶手長度 > 扶手可使用長度){
  1565. 彈跳_pl.SetActive(true);
  1566. 彈跳文字_tb.text = "超出扶手可使用長度 !";
  1567. Global.彈跳判斷 = "長度透支";
  1568. }else{
  1569. 輸入單項扶手長度_pl.SetActive(false);
  1570. Texture2D texture2D = new((放圖用.texture as Texture2D).width, (放圖用.texture as Texture2D).height);
  1571. Graphics.CopyTexture(放圖用.texture, texture2D);
  1572. byte[] imageBytes = texture2D.EncodeToPNG();
  1573. SQL_Comm.SQL_讀取施工圖檔流水號(報告書流水號_tb.text,Global.報告書施工狀態,Global.報告書文件號,Global.報告書物料料號,Global.報告書物料明細流水號);
  1574. int 流水號;if(SQL_Module.dr.Read()){流水號=int.Parse(SQL_Module.dr[0].ToString()[2..]);}else{流水號 = 0;}流水號+=1;
  1575. SQL_Comm.SQL_上傳施工圖檔(報告書流水號_tb.text,Global.報告書施工狀態,Global.報告書文件號,Global.報告書物料料號,imageBytes,"JPG","IM"+流水號.ToString().PadLeft(3,'0'),扶手長度.ToString(),Global.報告書物料明細流水號);
  1576. 拍照結束();
  1577. }
  1578. }
  1579. public void 回上頁(string 介面){
  1580. if(介面=="評估"){
  1581. 評估詳細_pl.SetActive(false);評估主頁_pl.SetActive(true);
  1582. 回上頁_bt.SetActive(false);拍照_bt.SetActive(false);業務系統_bt.SetActive(true);系統設定_bt.SetActive(true);
  1583. 新增項目_bt.SetActive(false);刪除項目_bt.SetActive(false);
  1584. Module.清除控件(報告書項目清單_ct);Module.清除控件(報告書施工圖片_ct);
  1585. 報告書流水號_tb.text="";報告書申請人_tb.text="";報告書開立人_tb.text="";Global.報告書物料明細流水號="";
  1586. Set_報告書人員清單("");
  1587. }
  1588. }
  1589. public void 新增相片(){
  1590. if(Global.報告書施工狀態=="文件號"){
  1591. if(報告書流水號_tb.text==""){
  1592. 彈跳_pl.SetActive(true);
  1593. 彈跳文字_tb.text = "看到這則訊息請聯絡系統開發商!";
  1594. Global.彈跳判斷="報告書資料不齊全";
  1595. }else{
  1596. if (!拍照頁面_pl.activeSelf){
  1597. 拍照頁面_pl.SetActive(true);
  1598. StartCoroutine(open_Camera(60));
  1599. 提示_tb.text ="拍照中";
  1600. 拍照用.gameObject.SetActive(true);
  1601. 放圖用.gameObject.SetActive(false);
  1602. }
  1603. }
  1604. }else{
  1605. if(Global.報告書物料料號=="" || Global.報告書文件號==""){
  1606. 彈跳_pl.SetActive(true);
  1607. 彈跳文字_tb.text = "請先選擇文件以及項目!";
  1608. Global.彈跳判斷="報告書資料不齊全";
  1609. }else{
  1610. if (!拍照頁面_pl.activeSelf){
  1611. 拍照頁面_pl.SetActive(true);
  1612. StartCoroutine(open_Camera(60));
  1613. 提示_tb.text ="拍照中";
  1614. 拍照用.gameObject.SetActive(true);
  1615. 放圖用.gameObject.SetActive(false);
  1616. }
  1617. }
  1618. }
  1619. }
  1620. public void 拍照(){
  1621. if (拍照用.gameObject.activeSelf && !放圖用.gameObject.activeSelf){
  1622. Texture2D photoTexture = CapturePhoto();
  1623. if (photoTexture != null){
  1624. 放圖用.rectTransform.sizeDelta = new Vector2(720f, 1280f);
  1625. 放圖用.texture = photoTexture;
  1626. Texture2D texture2D = new((放圖用.texture as Texture2D).width, (放圖用.texture as Texture2D).height);
  1627. Graphics.CopyTexture(放圖用.texture, texture2D);
  1628. byte[] imageBytes = texture2D.EncodeToPNG();
  1629. SQL_CommString.SQL_連線字串_圖片_SQL(Global.圖檔資料庫,Global.資料庫IP);
  1630. if(Global.報告書施工狀態=="文件號"){
  1631. SQL_Comm.SQL_讀取報告書檔案流水號(報告書流水號_tb.text);
  1632. int 流水號;if(SQL_Module.dr.Read()){流水號=int.Parse(SQL_Module.dr[0].ToString()[2..]);}else{流水號 = 0;}流水號+=1;
  1633. SQL_Comm.SQL_上傳報告書圖檔(報告書流水號_tb.text,"報告書","IM"+流水號.ToString().PadLeft(3,'0'),imageBytes,"JPG");
  1634. 拍照結束();
  1635. }else{
  1636. if(Global.報告書施工狀態=="施工前" && (Global.報告書物料料號=="FA01" || Global.報告書物料料號=="137" || Global.報告書物料料號=="FA09" || Global.報告書物料料號=="152")){
  1637. if(Global.報告書物料料號=="FA01" || Global.報告書物料料號=="137"){
  1638. 扶手總長2_lb.text="扶手總長";
  1639. 扶手長度_lb.text="扶手長度";
  1640. 請輸入扶手總長度_lb.text="請輸入扶手總長度";
  1641. 扶手總長度_lb.text="扶手總長度";
  1642. 已使用扶手長度_lb.text="已使用扶手長度";
  1643. 可使用扶手長度_lb.text="可使用扶手長度";
  1644. 扶手長度2_lb.text="扶手長度";
  1645. }else{
  1646. 扶手總長2_lb.text="總單位";
  1647. 扶手長度_lb.text="單位";
  1648. 請輸入扶手總長度_lb.text="請輸入總單位";
  1649. 扶手總長度_lb.text="總單位";
  1650. 已使用扶手長度_lb.text="已使用單位";
  1651. 可使用扶手長度_lb.text="可使用單位";
  1652. 扶手長度2_lb.text="單位";
  1653. }
  1654. 輸入單項扶手總長度_tb.text = 報告書扶手總長_tb.text;
  1655. SQL_Comm.SQL_報告書_施工圖檔扶手長度清單(報告書流水號_tb.text,Global.報告書文件號,Global.報告書物料料號,Global.報告書物料明細流水號);
  1656. DataSet ds1 = new();
  1657. SQL_Module.da.Fill(ds1);
  1658. double 扶手累積長度=0;
  1659. double 扶手總長度 = double.Parse(輸入單項扶手總長度_tb.text);
  1660. for(int i =0;i<=ds1.Tables[0].Rows.Count-1;i++){
  1661. 扶手累積長度 += double.Parse(ds1.Tables[0].Rows[i][0].ToString());
  1662. }
  1663. 扶手已使用長度_tb.text = 扶手累積長度.ToString();
  1664. double 扶手可使用長度 = 扶手總長度 - 扶手累積長度;
  1665. 扶手可使用長度_tb.text = 扶手可使用長度.ToString();
  1666. 扶手長度_tb.text = "";
  1667. 輸入單項扶手長度_pl.SetActive(true);
  1668. }else{
  1669. SQL_Comm.SQL_讀取施工圖檔流水號(報告書流水號_tb.text,Global.報告書施工狀態,Global.報告書文件號,Global.報告書物料料號,Global.報告書物料明細流水號);
  1670. int 流水號;if(SQL_Module.dr.Read()){流水號=int.Parse(SQL_Module.dr[0].ToString()[2..]);}else{流水號 = 0;}流水號+=1;
  1671. SQL_Comm.SQL_上傳施工圖檔(報告書流水號_tb.text,Global.報告書施工狀態,Global.報告書文件號,Global.報告書物料料號,imageBytes,"JPG","IM"+流水號.ToString().PadLeft(3,'0'),"0",Global.報告書物料明細流水號);
  1672. 拍照結束();
  1673. }
  1674. }
  1675. }
  1676. myCam.Stop();
  1677. myCam = null;
  1678. 提示_tb.text ="";
  1679. }
  1680. }
  1681. private void 拍照結束(){
  1682. 拍照頁面_pl.SetActive(false);
  1683. PhotoScroll.清除currentPage();
  1684. 扶手長度_tb.text="";
  1685. if(Global.報告書施工狀態=="文件號"){
  1686. 載入報告書詳細資料(報告書流水號_tb.text);
  1687. }else{
  1688. 載入施工圖片();
  1689. }
  1690. }
  1691. private Texture2D CapturePhoto(){
  1692. if (myCam != null){
  1693. int width = myCam.width;
  1694. int height = myCam.height;
  1695. Texture2D photoTexture = new Texture2D(width, height);
  1696. photoTexture.SetPixels(myCam.GetPixels());
  1697. photoTexture.Apply();
  1698. Texture2D rotatedTexture = RotateTexture(photoTexture, true);
  1699. return rotatedTexture;
  1700. }
  1701. return null;
  1702. }
  1703. private IEnumerator open_Camera(int fps){
  1704. yield return Application.RequestUserAuthorization(UserAuthorization.WebCam); //授權開啟鏡頭
  1705. if (Application.HasUserAuthorization(UserAuthorization.WebCam)){
  1706. myCam = new WebCamTexture(WebCamTexture.devices[0].name, 720, 1280, fps);
  1707. 拍照用.texture = myCam;
  1708. myCam.Play();
  1709. }
  1710. }
  1711. private IEnumerator open_Camera2(int fps){
  1712. yield return Application.RequestUserAuthorization(UserAuthorization.WebCam); //授權開啟鏡頭
  1713. if (Application.HasUserAuthorization(UserAuthorization.WebCam)){
  1714. myCam = new WebCamTexture(WebCamTexture.devices[0].name, 720, 1280, fps);
  1715. 更換照片拍照用.texture = myCam;
  1716. myCam.Play();
  1717. }
  1718. }
  1719. private Texture2D RotateTexture(Texture2D originalTexture, bool clockwise){
  1720. int width = originalTexture.width;
  1721. int height = originalTexture.height;
  1722. Texture2D rotatedTexture = new Texture2D(height, width);
  1723. Color32[] originalPixels = originalTexture.GetPixels32();
  1724. Color32[] rotatedPixels = new Color32[width * height];
  1725. for (int y = 0; y < height; y++){
  1726. for (int x = 0; x < width; x++){
  1727. int newX = clockwise ? y : height - y - 1;
  1728. int newY = clockwise ? width - x - 1 : x;
  1729. rotatedPixels[newY * height + newX] = originalPixels[y * width + x];
  1730. }
  1731. }
  1732. rotatedTexture.SetPixels32(rotatedPixels);
  1733. rotatedTexture.Apply();
  1734. return rotatedTexture;
  1735. }
  1736. public void 施工前(){
  1737. Global.報告書施工狀態="施工前";發送通知_bt.SetActive(false);
  1738. 施工前_bt.GetComponentInParent<Image>().color = new Color(0.67f,1f,0.4f,1f);
  1739. 施工後_bt.GetComponentInParent<Image>().color = new Color(1f,1f,1f,1f);
  1740. 文件號_bt.GetComponentInParent<Image>().color = new Color(1f,1f,1f,1f);
  1741. 核銷文件_bt.GetComponentInParent<Image>().color = new Color(1f,1f,1f,1f);
  1742. 載入施工圖片();
  1743. PhotoScroll.清除currentPage();
  1744. }
  1745. public void 施工後(){
  1746. Global.報告書施工狀態="施工後";單項扶手長度_tb.text="";發送通知_bt.SetActive(true);
  1747. 施工前_bt.GetComponentInParent<Image>().color = new Color(1f,1f,1f,1f);
  1748. 施工後_bt.GetComponentInParent<Image>().color = new Color(0.67f,1f,0.4f,1f);
  1749. 文件號_bt.GetComponentInParent<Image>().color = new Color(1f,1f,1f,1f);
  1750. 核銷文件_bt.GetComponentInParent<Image>().color = new Color(1f,1f,1f,1f);
  1751. 載入施工圖片();
  1752. PhotoScroll.清除currentPage();
  1753. }
  1754. public void 核銷文件按鈕(){
  1755. Global.報告書施工狀態="核銷文件";單項扶手長度_tb.text="";發送通知_bt.SetActive(false);
  1756. 施工前_bt.GetComponentInParent<Image>().color = new Color(1f,1f,1f,1f);
  1757. 施工後_bt.GetComponentInParent<Image>().color = new Color(1f,1f,1f,1f);
  1758. 文件號_bt.GetComponentInParent<Image>().color = new Color(1f,1f,1f,1f);
  1759. 核銷文件_bt.GetComponentInParent<Image>().color = new Color(0.67f,1f,0.4f,1f);
  1760. 載入施工圖片();
  1761. PhotoScroll.清除currentPage();
  1762. }
  1763. public void 更換照片_開啟(){
  1764. if(!更換照片_pl.activeInHierarchy){
  1765. 更換照片資料夾_bt.SetActive(true);更換照片文件號_bt.SetActive(true);更換照片確認_bt.SetActive(true);
  1766. 更換照片取消_bt.SetActive(true);更換照片拍照確認_bt.SetActive(false);
  1767. 更換照片_pl.SetActive(true);
  1768. Transform 子1=報告書施工圖片_ct.transform.GetChild(1);
  1769. Transform 子2 = 子1.transform.GetChild(1);
  1770. 更換照片放圖用.texture=子2.gameObject.GetComponent<RawImage>().texture;
  1771. 更換照片提示_tb.text="編輯中";
  1772. }
  1773. }
  1774. public void 更換照片_取消(){
  1775. if(更換照片_pl.activeInHierarchy){
  1776. 更換照片放圖用.texture =null;更換照片拍照用.texture =null;更換照片_pl.SetActive(false);
  1777. }
  1778. }
  1779. public void 更換照片_確認(){
  1780. if(更換照片放圖用.texture != null){
  1781. Texture2D originalTexture = 更換照片放圖用.texture as Texture2D;
  1782. Texture2D texture2D = new(originalTexture.width, originalTexture.height, TextureFormat.RGBA32, false);
  1783. Color[] pixels = originalTexture.GetPixels();
  1784. texture2D.SetPixels(pixels);
  1785. texture2D.Apply();
  1786. byte[] imageBytes = texture2D.EncodeToPNG();
  1787. SQL_CommString.SQL_連線字串_圖片_SQL(Global.圖檔資料庫,Global.資料庫IP);
  1788. if(Global.報告書施工狀態=="文件號"){
  1789. SQL_Comm.SQL_更新報告書圖檔(報告書流水號_tb.text,"報告書",Global.報告書文件號,imageBytes);
  1790. 更換照片結束();
  1791. }else{
  1792. SQL_Comm.SQL_更新施工圖檔(報告書流水號_tb.text,Global.報告書施工狀態,Global.報告書文件號,Global.報告書物料料號,imageBytes,Global.報告書施工圖檔文件號,Global.報告書物料明細流水號);
  1793. 更換照片結束();
  1794. }
  1795. }
  1796. }
  1797. public void 更換照片_拍照(){
  1798. StartCoroutine(open_Camera2(60));
  1799. 更換照片提示_tb.text ="拍照中";
  1800. 更換照片資料夾_bt.SetActive(false);更換照片文件號_bt.SetActive(false);更換照片確認_bt.SetActive(false);
  1801. 更換照片取消_bt.SetActive(false);更換照片拍照確認_bt.SetActive(true);
  1802. 更換照片拍照用.gameObject.SetActive(true);
  1803. 更換照片放圖用.gameObject.SetActive(false);
  1804. }
  1805. public void 更換照片_拍照確認(){
  1806. 更換照片資料夾_bt.SetActive(true);更換照片文件號_bt.SetActive(true);更換照片確認_bt.SetActive(true);
  1807. 更換照片取消_bt.SetActive(true);更換照片拍照確認_bt.SetActive(false);
  1808. if (更換照片拍照用.gameObject.activeSelf && !更換照片放圖用.gameObject.activeSelf){
  1809. Texture2D photoTexture = CapturePhoto();
  1810. if (photoTexture != null){
  1811. 更換照片放圖用.rectTransform.sizeDelta = new Vector2(720f, 1280f);
  1812. 更換照片放圖用.texture = photoTexture;
  1813. }
  1814. myCam.Stop();
  1815. myCam = null;
  1816. 更換照片提示_tb.text ="編輯中";
  1817. 更換照片拍照用.gameObject.SetActive(false);
  1818. 更換照片放圖用.gameObject.SetActive(true);
  1819. }
  1820. }
  1821. private void 更換照片結束(){
  1822. 更換照片_pl.SetActive(false);
  1823. PhotoScroll.清除currentPage();
  1824. 扶手長度_tb.text="";
  1825. if(Global.報告書施工狀態=="文件號"){
  1826. 載入報告書詳細資料(報告書流水號_tb.text);
  1827. Module.清除控件(報告書施工圖片_ct);
  1828. }else{
  1829. 載入施工圖片();
  1830. }
  1831. }
  1832. public void 文件號(){
  1833. Global.報告書施工狀態="文件號";單項扶手長度_tb.text="";發送通知_bt.SetActive(false);
  1834. 施工前_bt.GetComponentInParent<Image>().color = new Color(1f,1f,1f,1f);
  1835. 施工後_bt.GetComponentInParent<Image>().color = new Color(1f,1f,1f,1f);
  1836. 文件號_bt.GetComponentInParent<Image>().color = new Color(0.67f,1f,0.4f,1f);
  1837. 核銷文件_bt .GetComponentInParent<Image>().color = new Color(1f,1f,1f,1f);
  1838. 載入施工圖片();
  1839. PhotoScroll.清除currentPage();
  1840. }
  1841. public void 刪除照片(){
  1842. if(相片總數_tb.text=="-"){
  1843. 彈跳_pl.SetActive(true);
  1844. 彈跳文字_tb.text="請先選擇要刪除的照片";
  1845. }else{
  1846. if(Global.報告書施工狀態=="文件號"){
  1847. 彈跳_pl.SetActive(true);
  1848. 彈跳文字_tb.text="確定要刪除此照片?";
  1849. Global.彈跳判斷="文件號刪除照片";
  1850. }else{
  1851. 彈跳_pl.SetActive(true);
  1852. 彈跳文字_tb.text="確定要刪除此照片?";
  1853. Global.彈跳判斷="施工刪除照片";
  1854. }
  1855. }
  1856. }
  1857. public void 備註_返回(){
  1858. 備註_pl.SetActive(false);備註_tb.text="";
  1859. }
  1860. public void 開啟備註(){
  1861. 備註_pl.SetActive(true);string 備註="";
  1862. SQL_Comm.SQL_報告書_讀取施工備註2(報告書流水號_tb.text,Global.報告書選項2,Global.報告書物料明細流水號,Global.報告書物料料號);
  1863. //SQL_Comm.SQL_報告書_讀取施工備註(報告書流水號_tb.text,Global.報告書選項2,Global.報告書施工狀態,Global.報告書物料明細流水號,Global.報告書物料料號,文件號);
  1864. if(SQL_Module.dr.Read()){
  1865. 備註=SQL_Module.dr[0].ToString();
  1866. }
  1867. 備註_tb.text=備註;
  1868. }
  1869. public void 備註存檔(){
  1870. //string 文件號 = 施作圖片相片文件號_tb.text;
  1871. SQL_Comm.SQL_報告書_寫入施工備註2(報告書流水號_tb.text,Global.報告書選項2,Global.報告書物料明細流水號,Global.報告書物料料號,備註_tb.text);
  1872. //SQL_Comm.SQL_報告書_寫入施工備註(報告書流水號_tb.text,Global.報告書選項2,Global.報告書施工狀態,Global.報告書物料明細流水號,Global.報告書物料料號,文件號,備註_tb.text);
  1873. 備註_pl.SetActive (false);
  1874. }
  1875. public void 發送通知(){
  1876. sql_line.LIN訊息通知("CC215","WS-系統通知(主管)",報告書流水號_tb.text,"");
  1877. //sql_line.LIN訊息通知("CC215","王詩文",報告書流水號_tb.text,"");
  1878. 彈跳_pl.SetActive(true);彈跳文字_tb.text="已發送通知!";Global.彈跳判斷="發送通知";
  1879. }
  1880. public void 新增項目(){
  1881. if(新增項目_pl.activeInHierarchy ){
  1882. 新增項目_pl.SetActive(false);報告書圖片_pl.SetActive(true);
  1883. }else{
  1884. if(報告書流水號_tb.text==""||Global.報告書文件號==""){
  1885. 彈跳_pl.SetActive(true);
  1886. 彈跳文字_tb.text = "請先選擇文件!";
  1887. Global.彈跳判斷="報告書資料不齊全";
  1888. }else{
  1889. 報告書圖片_pl.SetActive(false);新增項目_pl.SetActive(true);
  1890. 長照類_bt.SetActive(true);身障類_bt.SetActive(true);自費類_bt.SetActive(true);長照類_sv.SetActive(false);回選單_bt.SetActive(false);項目清單2_lb.gameObject.SetActive(false);
  1891. }
  1892. }
  1893. }
  1894. /*public void 長照類_bt_click(){
  1895. 長照類_bt.SetActive(false);身障類_bt.SetActive(false);自費類_bt.SetActive(false);長照類_sv.SetActive(true);項目清單2_lb.gameObject.SetActive(true);回選單_bt.SetActive(true);
  1896. 項目清單2_lb.text="長期照顧類";Set_長照物料清單("長期照顧類","C");
  1897. }
  1898. public void 身障類_bt_click(){
  1899. 長照類_bt.SetActive(false);身障類_bt.SetActive(false);自費類_bt.SetActive(false);長照類_sv.SetActive(true);項目清單2_lb.gameObject.SetActive(true);回選單_bt.SetActive(true);
  1900. 項目清單2_lb.text="身心障礙類";Set_長照物料清單("身心障礙類","D");
  1901. }
  1902. public void 自費類_bt_click(){
  1903. 長照類_bt.SetActive(false);身障類_bt.SetActive(false);自費類_bt.SetActive(false);長照類_sv.SetActive(true);項目清單2_lb.gameObject.SetActive(true);回選單_bt.SetActive(true);
  1904. 項目清單2_lb.text="自費類";Set_長照物料清單("自費類","B");
  1905. }*/
  1906. public void 長照類_bt_click(){
  1907. 長照類_bt.SetActive(false);身障類_bt.SetActive(false);自費類_bt.SetActive(false);返回3_bt.SetActive(false);
  1908. 長照類_核定通知書_bt.SetActive(true);長照類_相關文件_bt.SetActive(true);長照類_評估報告書1_bt.SetActive(true);
  1909. 長照類_評估報告書2_bt.SetActive(true); 返回4_bt.SetActive(true);
  1910. Global.報告書選項1="長照類";
  1911. }
  1912. public void 身障類_bt_click(){
  1913. 長照類_bt.SetActive(false);身障類_bt.SetActive(false);自費類_bt.SetActive(false);返回3_bt.SetActive(false);
  1914. 長照類_核定通知書_bt.SetActive(true);長照類_相關文件_bt.SetActive(true);長照類_評估報告書1_bt.SetActive(true);
  1915. 長照類_評估報告書2_bt.SetActive(true); 返回4_bt.SetActive(true);
  1916. Global.報告書選項1="身障類";
  1917. }
  1918. public void 自費類_bt_click(){
  1919. 長照類_bt.SetActive(false);身障類_bt.SetActive(false);自費類_bt.SetActive(false);返回3_bt.SetActive(false);
  1920. 長照類_案場1_bt.SetActive(true);長照類_案場2_bt.SetActive(true);長照類_案場3_bt.SetActive(true);
  1921. 返回8_bt.SetActive(true);
  1922. Global.報告書選項1="自費類";
  1923. }
  1924. public void 回選單_bt_click(){
  1925. 長照類_bt.SetActive(true);身障類_bt.SetActive(true);自費類_bt.SetActive(true);長照類_sv.SetActive(false);項目清單2_lb.gameObject.SetActive(false);回選單_bt.SetActive(false);
  1926. }
  1927. public void 長照類_相關文件_bt_click(){
  1928. 長照類_核定通知書_bt.SetActive(false);長照類_相關文件_bt.SetActive(false);長照類_評估報告書1_bt.SetActive(false);
  1929. 長照類_評估報告書2_bt.SetActive(false);返回4_bt.SetActive(false);
  1930. 長照類_申請人身分證反面_bt.SetActive(true);長照類_受託人身分證反面_bt.SetActive(true);長照類_所有權人身分證反面_bt.SetActive(true);
  1931. 長照類_房屋所有權狀_bt.SetActive(true);長照類_土地所有權狀_bt.SetActive(true);長照類_房屋稅籍證明_bt.SetActive(true);長照類_土地稅籍證明_bt.SetActive(true);
  1932. 長照類_房屋稅單_bt.SetActive(true);長照類_土地稅單_bt.SetActive(true);返回5_bt.SetActive(true);拍照1_bt.SetActive(true);刪除1_bt.SetActive(true);
  1933. 存檔1_bt.SetActive(true);報告書文件圖片_pl.SetActive(true);長照類_申請人身心障礙證明_bt.SetActive(true);
  1934. Global.報告書選項2="相關文件";
  1935. 限制圖片不超過Panel範圍();
  1936. }
  1937. public void 倍瑞菲_bt_click(){
  1938. string url ="";
  1939. #if UNITY_ANDROID
  1940. url = "https://lin.ee/rSFZlqK";
  1941. #elif UNITY_IPHONE
  1942. url = "https://lin.ee/rSFZlqK";
  1943. #else
  1944. url = "https://lin.ee/rSFZlqK";
  1945. #endif
  1946. Application.OpenURL(url);
  1947. }
  1948. public void 地圖_bt_Click(){
  1949. if(報告書人員資料_地址_tb.text!=""){
  1950. string address = 報告書人員資料_地址_tb.text;
  1951. string url = "https://www.google.com/maps/search/?api=1&query=" + UnityEngine.Networking.UnityWebRequest.EscapeURL(address);
  1952. Application.OpenURL(url);
  1953. }else{
  1954. 彈跳_pl.SetActive(true);
  1955. 彈跳文字_tb.text = "地址沒有資料不能跳轉!!";
  1956. Global.彈跳判斷 = "地址";
  1957. }
  1958. }
  1959. public void 小工具_bt_Click(){
  1960. Main.change_Secen(3);
  1961. }
  1962. public void 照片存檔_bt_Click(){
  1963. RawImage rawImage ;
  1964. if (施作圖片_pl.activeInHierarchy)
  1965. {
  1966. rawImage = GetCloneRawImage(施作圖片_pl,"施作文件");
  1967. }
  1968. else
  1969. {
  1970. rawImage = GetCloneRawImage(報告書文件圖片_pl,"相關文件");
  1971. }
  1972. if (rawImage.texture == null){
  1973. Debug.LogWarning("RawImage 尚未載入任何圖片,無法儲存");
  1974. return;
  1975. }
  1976. Texture2D tex = null;
  1977. RenderTexture rt = null;
  1978. try
  1979. {
  1980. tex = new Texture2D((int)rawImage.texture.width, (int)rawImage.texture.height, TextureFormat.RGB24, false);
  1981. rt = RenderTexture.GetTemporary(tex.width, tex.height, 0);
  1982. Graphics.Blit(rawImage.texture, rt);
  1983. RenderTexture.active = rt;
  1984. tex.ReadPixels(new Rect(0, 0, tex.width, tex.height), 0, 0);
  1985. tex.Apply();
  1986. }
  1987. finally
  1988. {
  1989. RenderTexture.active = null;
  1990. if (rt != null) RenderTexture.ReleaseTemporary(rt);
  1991. }
  1992. string filename = "RawImage_" + System.DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".png";
  1993. NativeGallery.SaveImageToGallery(tex, Application.productName, filename, (success, path) =>
  1994. {
  1995. if (success)
  1996. {
  1997. 彈跳_pl.SetActive(true);
  1998. 彈跳文字_tb.text = "圖片儲存完成!";
  1999. Global.彈跳判斷 = "圖片儲存";
  2000. 彈跳否_bt.SetActive(false);
  2001. }
  2002. else
  2003. {
  2004. 彈跳_pl.SetActive(true);
  2005. 彈跳文字_tb.text = "圖片未儲存,請檢查權限是否異常!";
  2006. Global.彈跳判斷 = "圖片儲存";
  2007. 彈跳否_bt.SetActive(false);
  2008. }
  2009. });
  2010. }
  2011. RawImage GetCloneRawImage(GameObject 圖片_panel,string 圖片panel){
  2012. TextMeshProUGUI 相片目前_tb = 圖片panel switch{
  2013. "施作文件" => 施作圖片相片目前_tb,
  2014. _ => 相關文件相片目前_tb
  2015. };
  2016. // 轉換 index 數值
  2017. if (!int.TryParse(相片目前_tb.text, out int index) || index <= 0){
  2018. Debug.LogWarning($"{圖片panel} 相片目前_tb 不是有效數字");
  2019. return null;
  2020. }
  2021. // 過濾所有符合的 RawImage
  2022. var images = 圖片_panel.GetComponentsInChildren<RawImage>(true)
  2023. .Where(r => r.name.Contains("Image(Clone)"))
  2024. .ToList();
  2025. if (index > images.Count){
  2026. Debug.LogWarning($"要求第 {index} 張,但只有 {images.Count} 張可選({圖片panel})");
  2027. return null;
  2028. }
  2029. return images[index - 1];
  2030. }
  2031. public void 刪除項目()
  2032. {
  2033. if (Global.報告書物料明細流水號 == "")
  2034. {
  2035. 彈跳_pl.SetActive(true);
  2036. 彈跳文字_tb.text = "請先選擇刪除項目!";
  2037. Global.彈跳判斷 = "報告書資料不齊全";
  2038. }
  2039. else
  2040. {
  2041. SQL_Comm.SQL_報告書_明細刪除(Global.報告書物料明細流水號); Global.報告書物料明細流水號 = "";
  2042. SQL_Comm.SQL_報告書_施工圖檔刪除(報告書流水號_tb.text, Global.報告書文件號, Global.報告書物料料號);
  2043. 載入報告書項目清單(Global.報告書文件號);
  2044. Module.清除控件(報告書施工圖片_ct);
  2045. PhotoScroll.清除currentPage();
  2046. }
  2047. }
  2048. public void 登出(){
  2049. 彈跳_pl.SetActive(true);
  2050. 彈跳文字_tb.text = "確認登出?";
  2051. Global.彈跳判斷="登出";
  2052. }
  2053. public void 彈跳是(){
  2054. if (Global.彈跳判斷 == "登出")
  2055. {
  2056. 彈跳文字_tb.text = "";
  2057. 彈跳_pl.SetActive(false);
  2058. if (PlayerPrefs.HasKey("帳號"))
  2059. {
  2060. PlayerPrefs.DeleteKey("帳號");
  2061. }
  2062. if (PlayerPrefs.HasKey("密碼"))
  2063. {
  2064. PlayerPrefs.DeleteKey("密碼");
  2065. }
  2066. change_Secen(0);
  2067. }
  2068. else if (Global.彈跳判斷 == "新增報告書")
  2069. {
  2070. 彈跳文字_tb.text = "";
  2071. 彈跳_pl.SetActive(false);
  2072. }
  2073. else if (Global.彈跳判斷 == "文件號刪除照片")
  2074. {
  2075. SQL_Comm.SQL_報告書_刪除報告書圖檔(報告書流水號_tb.text, Global.報告書文件號);
  2076. SQL_Comm.SQL_報告書_刪除報告書明細(報告書流水號_tb.text, Global.報告書文件號, Global.報告書物料料號);
  2077. SQL_Comm.SQL_報告書_刪除報告書施工圖檔(報告書流水號_tb.text, Global.報告書文件號, Global.報告書物料料號);
  2078. 彈跳文字_tb.text = "刪除完畢";
  2079. Global.彈跳判斷 = "文件號照片刪除完成";
  2080. }
  2081. else if (Global.彈跳判斷 == "文件號照片刪除完成")
  2082. {
  2083. Module.清除控件(報告書施工圖片_ct);
  2084. 載入報告書詳細資料(報告書流水號_tb.text);
  2085. 彈跳文字_tb.text = "";
  2086. 彈跳_pl.SetActive(false);
  2087. }
  2088. else if (Global.彈跳判斷 == "施工刪除照片")
  2089. {
  2090. SQL_Comm.SQL_報告書_刪除報告書施工圖檔照片(報告書流水號_tb.text, Global.報告書文件號, Global.報告書施工狀態, Global.報告書物料明細流水號, Global.報告書物料料號, Global.報告書施工圖檔文件號);
  2091. 彈跳文字_tb.text = "刪除完畢";
  2092. Global.彈跳判斷 = "施工照片刪除完成";
  2093. }
  2094. else if (Global.彈跳判斷 == "施工照片刪除完成")
  2095. {
  2096. 載入施工圖片();
  2097. 彈跳文字_tb.text = "";
  2098. 彈跳_pl.SetActive(false);
  2099. }
  2100. else
  2101. {
  2102. 彈跳文字_tb.text = "";
  2103. 彈跳_pl.SetActive(false);
  2104. 彈跳否_bt.SetActive(true);
  2105. }
  2106. }
  2107. public void 彈跳否(){
  2108. 彈跳文字_tb.text ="";
  2109. 彈跳否_bt.SetActive(true);
  2110. 彈跳_pl.SetActive(false);
  2111. }
  2112. IEnumerator AnimateText(){
  2113. string qqq = 圖片讀取_tb.text.ToString();
  2114. while (true){
  2115. yield return new WaitForSeconds(0.5f);
  2116. if (dotCount < 3){
  2117. loadingText += ".";
  2118. dotCount++;
  2119. }else{
  2120. loadingText = "";
  2121. dotCount = 0;
  2122. }
  2123. 圖片讀取_tb.text = qqq+loadingText;
  2124. }
  2125. }
  2126. string GetChineseDayOfWeek(DayOfWeek dayOfWeek){
  2127. return dayOfWeek switch{
  2128. DayOfWeek.Sunday => "星期日",
  2129. DayOfWeek.Monday => "星期一",
  2130. DayOfWeek.Tuesday => "星期二",
  2131. DayOfWeek.Wednesday => "星期三",
  2132. DayOfWeek.Thursday => "星期四",
  2133. DayOfWeek.Friday => "星期五",
  2134. DayOfWeek.Saturday => "星期六",
  2135. _ => "",
  2136. };
  2137. }
  2138. public static class Global{
  2139. public static string 版本號 ="1.0.16",版本號比對,gUser區域,gUserName,gUser加盟商編號,DTP1,資料庫IP;
  2140. public static string 使用者UID, 使用者暱稱, 使用者ID,螢幕格式,螢幕方向,彈跳判斷,圖檔資料庫,報告書文件號="",報告書物料料號="",輸入物料料號="",報告書物料明細流水號="",
  2141. 報告書施工狀態="文件號",報告書施工圖檔文件號="",報告書選項1="",報告書選項2="",報告書選項3="";
  2142. public static bool 鏡頭啟動,主頁新增;
  2143. public static int camfps,系統主題=1;
  2144. public static float rate , rate_ ,登入條件, 固高, 固寬, 固比, 固比1;
  2145. public static string PA, PB, PC, PD, PE, PF, PG, PH, PI, PJ, PK, PA1, PA2, PA3, PA4, PA5, PA6, PA7, PA8, PA9, PA10;
  2146. public static string[,] PHP = new string[5,2];
  2147. public static GameObject 複製體1,複製體2,複製體3,複製體4;
  2148. public static DataTable 報告書清單_tabel,報告書項目清單_tabel,客戶清單_tabel,長照物料清單_tabel,報告書施工圖片_table,文件號清單_table,報告書人員清單_tabel,
  2149. 報告書相關文件_table,報告書評估報告書1清單_tabel,報告書評估報告書2清單_tabel,報告書施作圖片_table,報告書案場1清單_tabel,報告書案場2清單_tabel,報告書案場3清單_tabel;
  2150. }
  2151. public static void change_Secen(int _screenNum){
  2152. SceneManager.LoadScene(_screenNum);
  2153. }
  2154. }