Açıklama Yok
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.

個人班表.cs 33KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. using UnityEngine.UI;
  6. using UnityEngine.Networking;
  7. using System.Text.RegularExpressions;
  8. using System.Data.SqlClient;
  9. using TMPro;
  10. using System;
  11. using System.IO;
  12. using ZXing;
  13. using ZXing.QrCode;
  14. using System.Net;
  15. using SimpleJSON;
  16. using System.ComponentModel;
  17. using System.Data;
  18. using System.Linq;
  19. using System.Runtime.InteropServices;
  20. using System.Globalization;
  21. public class 個人班表 : MonoBehaviour
  22. {
  23. public GameObject buttonPrefab;
  24. public Transform buttonParent;
  25. public GameObject buttonceneter;
  26. private List<GameObject> copy = new List<GameObject>();
  27. public GameObject buttonPrefab1;
  28. public Transform buttonParent1;
  29. public GameObject buttonceneter1;
  30. private List<GameObject> copy1 = new List<GameObject>();
  31. public GameObject buttonPrefab2;
  32. [SerializeField] GameObject 左鈕;
  33. [SerializeField] GameObject 右鈕;
  34. [SerializeField] TextMeshProUGUI 人員;
  35. [SerializeField] TextMeshProUGUI 年;
  36. [SerializeField] TextMeshProUGUI 月;
  37. public CanvasScaler canvasScaler;
  38. private string loadingText = "";
  39. private int dotCount = 0;
  40. [SerializeField] GameObject 讀取面板;
  41. [SerializeField] TextMeshProUGUI 讀取;
  42. [SerializeField] GameObject 彈跳面板;
  43. [SerializeField] TextMeshProUGUI 彈跳文字;
  44. JSONNode 人員清單;
  45. JSONArray 班表;
  46. int nd;
  47. int 人員總數;
  48. void Start()
  49. {
  50. Screen.autorotateToPortrait = false;
  51. Screen.orientation = ScreenOrientation.LandscapeLeft;
  52. //Main.Global.固高=1900f;
  53. //Main.Global.固寬=900f;
  54. //Main.Global.固比1=1f;
  55. //Main.Global.螢幕格式="瘦";
  56. canvasScaler.referenceResolution = new Vector2(Main.Global.固高,Main.Global.固寬);
  57. canvasScaler.matchWidthOrHeight=Main.Global.固比1;
  58. //Main.Global.阿帕契路徑="http://106.1.48.106:8080/wp-content/themes/event-star/hskin_login.php?";
  59. //Main.Global.預設伺服器路徑="test";
  60. //Main.Global.排班主管權限=true;
  61. //Main.Global.PA="張綝欐";
  62. Main.Global.螢幕方向="橫";
  63. DateTime currentDate = DateTime.Now;
  64. 年.text = currentDate.Year.ToString();
  65. 月.text = currentDate.Month.ToString("D2");
  66. StartCoroutine(AnimateText());
  67. nd=0;
  68. if (Main.Global.排班主管權限==true)
  69. {
  70. 左鈕.SetActive(true);
  71. 右鈕.SetActive(true);
  72. StartCoroutine(人員排班清單());
  73. }
  74. else
  75. {
  76. 左鈕.SetActive(false);
  77. 右鈕.SetActive(false);
  78. 人員.text=Main.Global.PA;
  79. StartCoroutine(個人月班表());
  80. }
  81. }
  82. IEnumerator AnimateText()
  83. {
  84. string qqq = 讀取.text.ToString();
  85. while (true)
  86. {
  87. yield return new WaitForSeconds(0.5f);
  88. if (dotCount < 3)
  89. {
  90. loadingText += ".";
  91. dotCount++;
  92. }
  93. else
  94. {
  95. loadingText = "";
  96. dotCount = 0;
  97. }
  98. 讀取.text = qqq+loadingText;
  99. }
  100. }
  101. IEnumerator 人員排班清單()
  102. {
  103. 讀取面板.SetActive(true);
  104. string strcon = "人員排班清單";
  105. string se = Main.Global.預設伺服器路徑;
  106. string pa = 年.text +"/" + 月.text;
  107. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA={2}", strcon, se, pa);
  108. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  109. yield return request.SendWebRequest();
  110. if (request.result == UnityWebRequest.Result.ConnectionError)
  111. {
  112. Debug.Log(request.error);
  113. yield break;
  114. }
  115. 人員清單 = JSON.Parse(request.downloadHandler.text);
  116. 人員總數=人員清單.Count;
  117. if (Main.Global.排班主管權限==true)
  118. {
  119. string str = 人員.text;
  120. for (int i = 0; i < 人員清單.Count; i++)
  121. {
  122. if (人員清單[i][0].ToString().Trim('"') == str)
  123. {
  124. nd = i;
  125. }
  126. }
  127. }
  128. yield return StartCoroutine(個人月班表());
  129. }
  130. IEnumerator 個人月班表()
  131. {
  132. 讀取面板.SetActive(true);
  133. string pa1 = "";
  134. if (Main.Global.排班主管權限==true)
  135. {
  136. if (人員清單.Count<1)
  137. {
  138. 人員.text="";
  139. }
  140. else
  141. {
  142. 人員.text =人員清單[nd][0].ToString().Trim('"');
  143. }
  144. pa1 = 人員清單[nd][0].ToString().Trim('"');
  145. }
  146. else
  147. {
  148. pa1 = 人員.text;
  149. }
  150. string strcon = "個人月班表";
  151. string se = Main.Global.預設伺服器路徑;
  152. string pa = 年.text +"/" + 月.text;
  153. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA={2}&PA1={3}", strcon, se, pa,pa1);
  154. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  155. yield return request.SendWebRequest();
  156. if (request.result == UnityWebRequest.Result.ConnectionError)
  157. {
  158. Debug.Log(request.error);
  159. yield break;
  160. }
  161. JSONNode json = JSON.Parse(request.downloadHandler.text);
  162. 班表 = new JSONArray();
  163. for (int i = 1; i < 32; i++)
  164. {
  165. JSONNode newValue = new JSONObject();
  166. string str = "";
  167. if (i<10)
  168. {
  169. str ="0"+i.ToString();
  170. }
  171. else
  172. {
  173. str = i.ToString();
  174. }
  175. newValue["日期"]= str;
  176. newValue["姓名"]= "";
  177. newValue["班別"]= "";
  178. newValue["上班時段"]= "";
  179. newValue["時數"]= "";
  180. newValue["半天"]= "";
  181. newValue["休息"]= "";
  182. newValue["一段"]= "";
  183. newValue["二段"]= "";
  184. newValue["顏色1"]= "";
  185. newValue["顏色2"]= "";
  186. newValue["星期"]= "";
  187. newValue["鎖定"]= "";
  188. newValue["後段"]= "";
  189. for (int j = 0; j < json.Count; j++)
  190. {
  191. string str1 = json[j][0].ToString().Trim('"');
  192. if (str == str1)
  193. {
  194. newValue["姓名"]= json[j][1].ToString().Trim('"');
  195. newValue["班別"]= json[j][2].ToString().Trim('"');
  196. newValue["上班時段"]= json[j][3].ToString().Trim('"');
  197. newValue["時數"]= json[j][4].ToString().Trim('"');
  198. newValue["半天"]= json[j][5].ToString().Trim('"');
  199. newValue["休息"]= json[j][6].ToString().Trim('"');
  200. newValue["一段"]= json[j][7].ToString().Trim('"');
  201. newValue["二段"]= json[j][8].ToString().Trim('"');
  202. newValue["顏色1"]= json[j][9].ToString().Trim('"');
  203. newValue["顏色2"]= json[j][10].ToString().Trim('"');
  204. newValue["後段"]= json[j][11].ToString().Trim('"');
  205. }
  206. }
  207. 班表.Add(newValue);
  208. }
  209. yield return StartCoroutine(整月星期讀取());
  210. }
  211. IEnumerator 整月星期讀取()
  212. {
  213. string strcon = "整月星期讀取";
  214. string se = Main.Global.預設伺服器路徑;
  215. string pa = 年.text +"/" + 月.text;
  216. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA={2}", strcon, se, pa);
  217. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  218. yield return request.SendWebRequest();
  219. if (request.result == UnityWebRequest.Result.ConnectionError)
  220. {
  221. Debug.Log(request.error);
  222. yield break;
  223. }
  224. JSONNode json = JSON.Parse(request.downloadHandler.text);
  225. for (int i = 0; i < json.Count; i++)
  226. {
  227. 班表[i][11]= json[i][0].ToString().Trim('"');
  228. 班表[i][12]= json[i][1].ToString().Trim('"');
  229. }
  230. int sum = 3;
  231. if (copy!= null)
  232. {
  233. DeleteCopies(copy);
  234. }
  235. if (copy1!= null)
  236. {
  237. DeleteCopies(copy1);
  238. }
  239. for (int i = 0; i < 班表.Count; i++)
  240. {
  241. GameObject buttonObj = Instantiate(buttonPrefab) as GameObject;
  242. buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(3, -sum);
  243. buttonObj.transform.SetParent(buttonParent, false);
  244. TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
  245. text[0].text = 班表[i][0].ToString().Trim('"');
  246. text[1].text = 班表[i][11].ToString().Trim('"');
  247. if (班表[i][2].ToString().Trim('"') == "")
  248. {
  249. text[2].text = "休";
  250. }
  251. else
  252. {
  253. text[2].text = 班表[i][2].ToString().Trim('"');
  254. }
  255. GameObject buttonObj1 = Instantiate(buttonPrefab1) as GameObject;
  256. float 初始 = 0;
  257. if (Main.Global.螢幕格式=="胖")
  258. {
  259. 初始 = 242.75f;
  260. }
  261. else
  262. {
  263. 初始 = 281.5f;
  264. }
  265. buttonObj1.GetComponent<RectTransform>().anchoredPosition = new Vector2(初始, -sum);
  266. buttonObj1.transform.SetParent(buttonParent1, false);
  267. if (Main.Global.排班主管權限==true)
  268. {
  269. if (班表[i][2].ToString().Trim('"')!= "" && 班表[i][2].ToString().Trim('"') != "休")
  270. {
  271. string 開始時段 = 班表[i][3].ToString().Trim('"');
  272. DateTime time1 = DateTime.ParseExact("08:00:00", "HH:mm:ss", CultureInfo.InvariantCulture);
  273. DateTime time2 = DateTime.ParseExact(開始時段, "HH:mm:ss", CultureInfo.InvariantCulture);
  274. int hoursDiff = (int)time2.Subtract(time1).TotalMinutes;
  275. int 商 = hoursDiff / 30; // 整數除法,得到商
  276. int 餘 = hoursDiff % 30; // 餘數運算,得到餘數
  277. float 商f = (float)商;
  278. float 餘f = (float)餘;
  279. float 總 = 0;
  280. if (Main.Global.螢幕格式=="胖")
  281. {
  282. 總 = 1+(商f*41.5f) +(餘*40.5f/30);
  283. }
  284. else
  285. {
  286. 總 = 1+(商f*48) +(餘*47/30);
  287. }
  288. double 時數 = double.Parse(班表[i][4].ToString().Trim('"'));
  289. float 時數f = (float)時數;
  290. double 後段 = double.Parse(班表[i][13].ToString().Trim('"'));
  291. 後段 = 4 -後段;
  292. float 時數1f = (float)(8-時數-後段);
  293. float 總時 = 0;
  294. float 總時1 = 0;
  295. if (Main.Global.螢幕格式=="胖")
  296. {
  297. 總時 = (時數f*83) -1;
  298. 總時1 = (時數1f*83) -1;
  299. }
  300. else
  301. {
  302. 總時 = (時數f*96) -1;
  303. 總時1 = (時數1f*96) -1;
  304. }
  305. double 休息 = double.Parse(班表[i][6].ToString().Trim('"'));
  306. 休息 = 休息*60;
  307. int 休息1 = (int)休息;
  308. int 商2 = 休息1 / 30; // 整數除法,得到商
  309. int 餘2 = 休息1 % 30;
  310. float 商1f = (float)商2;
  311. float 餘1f = (float)餘2;
  312. float 總2 = 0;
  313. if (Main.Global.螢幕格式=="胖")
  314. {
  315. 總2 = 1+總+總時+(商1f*41.5f) +(餘1f*40.5f/30);
  316. }
  317. else
  318. {
  319. 總2 = 1+總+總時+(商1f*48) +(餘1f*47/30);
  320. }
  321. float 長 = 0;
  322. float 長B = 0;
  323. if (Main.Global.螢幕格式=="胖")
  324. {
  325. 長 = 25f;
  326. 長B = -2f;
  327. }
  328. else
  329. {
  330. 長 = 40f;
  331. 長B = -4.5f;
  332. }
  333. if (班表[i][5]=="1")
  334. {
  335. GameObject buttonObj2 = Instantiate(buttonPrefab2) as GameObject;
  336. buttonObj2.GetComponent<RectTransform>().sizeDelta = new Vector2(總時, 長);// 修改大小
  337. buttonObj2.GetComponent<RectTransform>().anchoredPosition = new Vector2(總, 長B); // 修改初始位置
  338. buttonObj2.transform.SetParent(buttonObj1.transform, false);
  339. TextMeshProUGUI texts = buttonObj2.GetComponentInChildren<TextMeshProUGUI>();
  340. texts.text =班表[i][7].ToString().Trim('"');
  341. Image im = buttonObj2.GetComponentInChildren<Image>();
  342. string col = 班表[i][9].ToString().Trim('"');
  343. switch (col)
  344. {
  345. case "0":
  346. im.color = new Color32(128, 128, 128, 255);
  347. break;
  348. case "1":
  349. im.color = new Color32(124, 252, 0, 255);
  350. break;
  351. case "2":
  352. im.color = new Color32(173, 216, 230, 255);
  353. break;
  354. case "3":
  355. im.color = new Color32(240, 128, 128, 255);
  356. break;
  357. case "4":
  358. im.color = new Color32(224, 255, 255, 255);
  359. break;
  360. case "5":
  361. im.color = new Color32(250, 250, 210, 255);
  362. break;
  363. case "6":
  364. im.color = new Color32(211, 211, 211, 255);
  365. break;
  366. case "7":
  367. im.color = new Color32(144, 238, 144, 255);
  368. break;
  369. case "8":
  370. im.color = new Color32(255, 182, 193, 255);
  371. break;
  372. case "9":
  373. im.color = new Color32(255, 160, 122, 255);
  374. break;
  375. default:
  376. im.color = new Color32(255, 255, 255, 255); // 預設白色
  377. break;
  378. }
  379. }
  380. else
  381. {
  382. GameObject buttonObj2 = Instantiate(buttonPrefab2) as GameObject;
  383. buttonObj2.GetComponent<RectTransform>().sizeDelta = new Vector2(總時, 長);// 修改大小
  384. buttonObj2.GetComponent<RectTransform>().anchoredPosition = new Vector2(總, 長B); // 修改初始位置
  385. buttonObj2.transform.SetParent(buttonObj1.transform, false);
  386. TextMeshProUGUI texts = buttonObj2.GetComponentInChildren<TextMeshProUGUI>();
  387. texts.text =班表[i][7].ToString().Trim('"');
  388. Image im = buttonObj2.GetComponentInChildren<Image>();
  389. string col = 班表[i][9].ToString().Trim('"');
  390. switch (col)
  391. {
  392. case "0":
  393. im.color = new Color32(128, 128, 128, 255);
  394. break;
  395. case "1":
  396. im.color = new Color32(124, 252, 0, 255);
  397. break;
  398. case "2":
  399. im.color = new Color32(173, 216, 230, 255);
  400. break;
  401. case "3":
  402. im.color = new Color32(240, 128, 128, 255);
  403. break;
  404. case "4":
  405. im.color = new Color32(224, 255, 255, 255);
  406. break;
  407. case "5":
  408. im.color = new Color32(250, 250, 210, 255);
  409. break;
  410. case "6":
  411. im.color = new Color32(211, 211, 211, 255);
  412. break;
  413. case "7":
  414. im.color = new Color32(144, 238, 144, 255);
  415. break;
  416. case "8":
  417. im.color = new Color32(255, 182, 193, 255);
  418. break;
  419. case "9":
  420. im.color = new Color32(255, 160, 122, 255);
  421. break;
  422. default:
  423. im.color = new Color32(255, 255, 255, 255); // 預設白色
  424. break;
  425. }
  426. GameObject buttonObj3 = Instantiate(buttonPrefab2) as GameObject;
  427. buttonObj3.GetComponent<RectTransform>().sizeDelta = new Vector2(總時1, 長);// 修改大小
  428. buttonObj3.GetComponent<RectTransform>().anchoredPosition = new Vector2(總2, 長B); // 修改初始位置
  429. buttonObj3.transform.SetParent(buttonObj1.transform, false);
  430. TextMeshProUGUI texts1 = buttonObj3.GetComponentInChildren<TextMeshProUGUI>();
  431. texts1.text =班表[i][8].ToString().Trim('"');
  432. Image im1 = buttonObj3.GetComponentInChildren<Image>();
  433. string col1 = 班表[i][10].ToString().Trim('"');
  434. switch (col1)
  435. {
  436. case "0":
  437. im1.color = new Color32(128, 128, 128, 255);
  438. break;
  439. case "1":
  440. im1.color = new Color32(124, 252, 0, 255);
  441. break;
  442. case "2":
  443. im1.color = new Color32(173, 216, 230, 255);
  444. break;
  445. case "3":
  446. im1.color = new Color32(240, 128, 128, 255);
  447. break;
  448. case "4":
  449. im1.color = new Color32(224, 255, 255, 255);
  450. break;
  451. case "5":
  452. im1.color = new Color32(250, 250, 210, 255);
  453. break;
  454. case "6":
  455. im1.color = new Color32(211, 211, 211, 255);
  456. break;
  457. case "7":
  458. im1.color = new Color32(144, 238, 144, 255);
  459. break;
  460. case "8":
  461. im1.color = new Color32(255, 182, 193, 255);
  462. break;
  463. case "9":
  464. im1.color = new Color32(255, 160, 122, 255);
  465. break;
  466. default:
  467. im1.color = new Color32(255, 255, 255, 255); // 預設白色
  468. break;
  469. }
  470. }
  471. }
  472. }
  473. else
  474. {
  475. if (班表[i][2].ToString().Trim('"')!= "" && 班表[i][2].ToString().Trim('"') != "休" && 班表[i][12].ToString().Trim('"') == "Y")
  476. {
  477. string 開始時段 = 班表[i][3].ToString().Trim('"');
  478. DateTime time1 = DateTime.ParseExact("08:00:00", "HH:mm:ss", CultureInfo.InvariantCulture);
  479. DateTime time2 = DateTime.ParseExact(開始時段, "HH:mm:ss", CultureInfo.InvariantCulture);
  480. int hoursDiff = (int)time2.Subtract(time1).TotalMinutes;
  481. int 商 = hoursDiff / 30; // 整數除法,得到商
  482. int 餘 = hoursDiff % 30; // 餘數運算,得到餘數
  483. float 商f = (float)商;
  484. float 餘f = (float)餘;
  485. float 總 = 0;
  486. if (Main.Global.螢幕格式=="胖")
  487. {
  488. 總 = 1+(商f*41.5f) +(餘*40.5f/30);
  489. }
  490. else
  491. {
  492. 總 = 1+(商f*48) +(餘*47/30);
  493. }
  494. double 時數 = double.Parse(班表[i][4].ToString().Trim('"'));
  495. float 時數f = (float)時數;
  496. double 後段 = double.Parse(班表[i][13].ToString().Trim('"'));
  497. 後段 = 4 -後段;
  498. float 時數1f = (float)(8-時數-後段);
  499. float 總時 = 0;
  500. float 總時1 = 0;
  501. if (Main.Global.螢幕格式=="胖")
  502. {
  503. 總時 = (時數f*83) -1;
  504. 總時1 = (時數1f*83) -1;
  505. }
  506. else
  507. {
  508. 總時 = (時數f*96) -1;
  509. 總時1 = (時數1f*96) -1;
  510. }
  511. double 休息 = double.Parse(班表[i][6].ToString().Trim('"'));
  512. 休息 = 休息*60;
  513. int 休息1 = (int)休息;
  514. int 商2 = 休息1 / 30; // 整數除法,得到商
  515. int 餘2 = 休息1 % 30;
  516. float 商1f = (float)商2;
  517. float 餘1f = (float)餘2;
  518. float 總2 = 0;
  519. if (Main.Global.螢幕格式=="胖")
  520. {
  521. 總2 = 1+總+總時+(商1f*41.5f) +(餘1f*40.5f/30);
  522. }
  523. else
  524. {
  525. 總2 = 1+總+總時+(商1f*48) +(餘1f*47/30);
  526. }
  527. float 長 = 0;
  528. float 長B = 0;
  529. if (Main.Global.螢幕格式=="胖")
  530. {
  531. 長 = 25f;
  532. 長B = -2f;
  533. }
  534. else
  535. {
  536. 長 = 40f;
  537. 長B = -4.5f;
  538. }
  539. if (班表[i][5]=="1")
  540. {
  541. GameObject buttonObj2 = Instantiate(buttonPrefab2) as GameObject;
  542. buttonObj2.GetComponent<RectTransform>().sizeDelta = new Vector2(總時, 長);// 修改大小
  543. buttonObj2.GetComponent<RectTransform>().anchoredPosition = new Vector2(總, 長B); // 修改初始位置
  544. buttonObj2.transform.SetParent(buttonObj1.transform, false);
  545. TextMeshProUGUI texts = buttonObj2.GetComponentInChildren<TextMeshProUGUI>();
  546. texts.text =班表[i][7].ToString().Trim('"');
  547. Image im = buttonObj2.GetComponentInChildren<Image>();
  548. string col = 班表[i][9].ToString().Trim('"');
  549. switch (col)
  550. {
  551. case "0":
  552. im.color = new Color32(128, 128, 128, 255);
  553. break;
  554. case "1":
  555. im.color = new Color32(124, 252, 0, 255);
  556. break;
  557. case "2":
  558. im.color = new Color32(173, 216, 230, 255);
  559. break;
  560. case "3":
  561. im.color = new Color32(240, 128, 128, 255);
  562. break;
  563. case "4":
  564. im.color = new Color32(224, 255, 255, 255);
  565. break;
  566. case "5":
  567. im.color = new Color32(250, 250, 210, 255);
  568. break;
  569. case "6":
  570. im.color = new Color32(211, 211, 211, 255);
  571. break;
  572. case "7":
  573. im.color = new Color32(144, 238, 144, 255);
  574. break;
  575. case "8":
  576. im.color = new Color32(255, 182, 193, 255);
  577. break;
  578. case "9":
  579. im.color = new Color32(255, 160, 122, 255);
  580. break;
  581. default:
  582. im.color = new Color32(255, 255, 255, 255); // 預設白色
  583. break;
  584. }
  585. }
  586. else
  587. {
  588. GameObject buttonObj2 = Instantiate(buttonPrefab2) as GameObject;
  589. buttonObj2.GetComponent<RectTransform>().sizeDelta = new Vector2(總時, 長);// 修改大小
  590. buttonObj2.GetComponent<RectTransform>().anchoredPosition = new Vector2(總, 長B); // 修改初始位置
  591. buttonObj2.transform.SetParent(buttonObj1.transform, false);
  592. TextMeshProUGUI texts = buttonObj2.GetComponentInChildren<TextMeshProUGUI>();
  593. texts.text =班表[i][7].ToString().Trim('"');
  594. Image im = buttonObj2.GetComponentInChildren<Image>();
  595. string col = 班表[i][9].ToString().Trim('"');
  596. switch (col)
  597. {
  598. case "0":
  599. im.color = new Color32(128, 128, 128, 255);
  600. break;
  601. case "1":
  602. im.color = new Color32(124, 252, 0, 255);
  603. break;
  604. case "2":
  605. im.color = new Color32(173, 216, 230, 255);
  606. break;
  607. case "3":
  608. im.color = new Color32(240, 128, 128, 255);
  609. break;
  610. case "4":
  611. im.color = new Color32(224, 255, 255, 255);
  612. break;
  613. case "5":
  614. im.color = new Color32(250, 250, 210, 255);
  615. break;
  616. case "6":
  617. im.color = new Color32(211, 211, 211, 255);
  618. break;
  619. case "7":
  620. im.color = new Color32(144, 238, 144, 255);
  621. break;
  622. case "8":
  623. im.color = new Color32(255, 182, 193, 255);
  624. break;
  625. case "9":
  626. im.color = new Color32(255, 160, 122, 255);
  627. break;
  628. default:
  629. im.color = new Color32(255, 255, 255, 255); // 預設白色
  630. break;
  631. }
  632. GameObject buttonObj3 = Instantiate(buttonPrefab2) as GameObject;
  633. buttonObj3.GetComponent<RectTransform>().sizeDelta = new Vector2(總時1, 長);// 修改大小
  634. buttonObj3.GetComponent<RectTransform>().anchoredPosition = new Vector2(總2, 長B); // 修改初始位置
  635. buttonObj3.transform.SetParent(buttonObj1.transform, false);
  636. TextMeshProUGUI texts1 = buttonObj3.GetComponentInChildren<TextMeshProUGUI>();
  637. texts1.text =班表[i][8].ToString().Trim('"');
  638. Image im1 = buttonObj3.GetComponentInChildren<Image>();
  639. string col1 = 班表[i][10].ToString().Trim('"');
  640. switch (col1)
  641. {
  642. case "0":
  643. im1.color = new Color32(128, 128, 128, 255);
  644. break;
  645. case "1":
  646. im1.color = new Color32(124, 252, 0, 255);
  647. break;
  648. case "2":
  649. im1.color = new Color32(173, 216, 230, 255);
  650. break;
  651. case "3":
  652. im1.color = new Color32(240, 128, 128, 255);
  653. break;
  654. case "4":
  655. im1.color = new Color32(224, 255, 255, 255);
  656. break;
  657. case "5":
  658. im1.color = new Color32(250, 250, 210, 255);
  659. break;
  660. case "6":
  661. im1.color = new Color32(211, 211, 211, 255);
  662. break;
  663. case "7":
  664. im1.color = new Color32(144, 238, 144, 255);
  665. break;
  666. case "8":
  667. im1.color = new Color32(255, 182, 193, 255);
  668. break;
  669. case "9":
  670. im1.color = new Color32(255, 160, 122, 255);
  671. break;
  672. default:
  673. im1.color = new Color32(255, 255, 255, 255); // 預設白色
  674. break;
  675. }
  676. }
  677. }
  678. }
  679. if (Main.Global.螢幕格式=="胖")
  680. {
  681. sum+=30;
  682. }
  683. else
  684. {
  685. sum+=50;
  686. }
  687. copy.Add(buttonObj);
  688. copy1.Add(buttonObj1);
  689. }
  690. buttonceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter.GetComponent<RectTransform>().sizeDelta.x, sum);
  691. 讀取面板.SetActive(false);
  692. }
  693. public void 上頁()
  694. {
  695. if (nd < 1)
  696. {
  697. 彈跳面板.SetActive(true);
  698. 彈跳文字.text = "已經是第一筆人員資料!!";
  699. }
  700. else
  701. {
  702. nd = Mathf.Max(0, nd - 1); // 確保不會小於 1
  703. StartCoroutine(個人月班表());
  704. }
  705. }
  706. public void 下頁()
  707. {
  708. if (nd > 人員總數-2)
  709. {
  710. 彈跳面板.SetActive(true);
  711. 彈跳文字.text = "已經是最後一筆人員資料!!";
  712. }
  713. else
  714. {
  715. nd = Mathf.Min(人員總數-1, nd+1);
  716. StartCoroutine(個人月班表());
  717. }
  718. }
  719. public void 上月 ()
  720. {
  721. int y = int.Parse(年.text);
  722. int m = int.Parse(月.text);
  723. if (m != 1)
  724. {
  725. m -=1;
  726. if (m<10)
  727. {
  728. 月.text = "0"+m.ToString();
  729. }
  730. else
  731. {
  732. 月.text = m.ToString();
  733. }
  734. }
  735. else
  736. {
  737. y -=1;
  738. 年.text=y.ToString();
  739. 月.text="12";
  740. }
  741. nd=0;
  742. StartCoroutine(人員排班清單());
  743. }
  744. public void 下月()
  745. {
  746. int y = int.Parse(年.text);
  747. int m = int.Parse(月.text);
  748. if (m != 12)
  749. {
  750. m +=1;
  751. if (m<10)
  752. {
  753. 月.text = "0"+m.ToString();
  754. }
  755. else
  756. {
  757. 月.text = m.ToString();
  758. }
  759. }
  760. else
  761. {
  762. y +=1;
  763. 年.text=y.ToString();
  764. 月.text="01";
  765. }
  766. nd=0;
  767. StartCoroutine(人員排班清單());
  768. }
  769. public void 彈跳面板關閉()
  770. {
  771. 彈跳面板.SetActive(false);
  772. 彈跳文字.text = "";
  773. }
  774. private void DeleteCopies(List<GameObject> copyList)
  775. {
  776. foreach (GameObject copy in copyList)
  777. {
  778. Destroy(copy);
  779. }
  780. copyList.Clear();
  781. }
  782. public void back()
  783. {
  784. change_Secen(3);
  785. }
  786. public void change_Secen(int _screenNum)
  787. {
  788. SceneManager.LoadScene(_screenNum);
  789. }
  790. }