Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

加班紀錄表.cs 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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.Runtime.InteropServices;
  18. using System.Globalization;
  19. public class 加班紀錄表 : MonoBehaviour
  20. {
  21. public CanvasScaler canvasScaler;
  22. private string loadingText = "";
  23. private int dotCount = 0;
  24. [SerializeField] GameObject 讀取面板;
  25. [SerializeField] TextMeshProUGUI 讀取;
  26. [SerializeField] GameObject 彈跳面板;
  27. [SerializeField] TextMeshProUGUI 彈跳文字;
  28. [SerializeField] TextMeshProUGUI 日期;
  29. public GameObject buttonPrefab;
  30. public ScrollRect buttonscroll;
  31. private List<GameObject> copy = new List<GameObject>();
  32. private DateTime currentDate;
  33. // Start is called before the first frame update
  34. void Start()
  35. {
  36. Screen.autorotateToPortrait = false;
  37. Screen.orientation = ScreenOrientation.LandscapeLeft;
  38. float rate = 900.0f / 1900.0f;
  39. if (Main.Global.rate < rate)
  40. {
  41. canvasScaler.matchWidthOrHeight = 1f;
  42. }
  43. else
  44. {
  45. canvasScaler.matchWidthOrHeight = 0f;
  46. }
  47. //Main.Global.阿帕契路徑 = "http://106.1.48.106:8080/wp-content/themes/event-star/shto_main.php?";
  48. //Main.Global.預設伺服器路徑 = "official";
  49. currentDate = DateTime.Now;
  50. UpdateDateDisplay();
  51. StartCoroutine(AnimateText());
  52. }
  53. IEnumerator 生產排程明細表()
  54. {
  55. 讀取面板.SetActive(true);
  56. if (copy != null)
  57. {
  58. DeleteCopies(copy);
  59. }
  60. string strcon = "考勤日期查詢清單";
  61. string se = Main.Global.預設伺服器路徑;
  62. string pa = currentDate.ToString("yyyy/MM/dd");
  63. string strUrl = string.Format(Main.Global.阿帕契路徑 + "comm={0}&se={1}&PA={2}&PA1={3}", strcon, se, pa, "");
  64. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  65. yield return request.SendWebRequest();
  66. if (request.result == UnityWebRequest.Result.ConnectionError)
  67. {
  68. Debug.Log(request.error);
  69. yield break;
  70. }
  71. JSONNode json = JSON.Parse(request.downloadHandler.text);
  72. int sum = 3;
  73. for (int i = 0; i < json.Count; i++)
  74. {
  75. GameObject buttonObj = Instantiate(buttonPrefab) as GameObject;
  76. buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(3, -sum);
  77. Transform tran = buttonscroll.content;
  78. buttonObj.transform.SetParent(tran, false);
  79. TextMeshProUGUI[] texts = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
  80. if (json[i][0] != null)
  81. {
  82. texts[0].text = json[i][0].ToString().Trim('"');
  83. }
  84. if (json[i][5] != null)
  85. {
  86. texts[1].text = json[i][5].ToString().Trim('"');
  87. }
  88. if (json[i][14] != null)
  89. {
  90. texts[2].text = json[i][14].ToString().Trim('"');
  91. }
  92. if (json[i][15] != null)
  93. {
  94. texts[3].text = json[i][15].ToString().Trim('"');
  95. }
  96. if (json[i][16] != null)
  97. {
  98. texts[4].text = json[i][16].ToString().Trim('"');
  99. }
  100. if (json[i][17] != null)
  101. {
  102. texts[5].text = json[i][17].ToString().Trim('"');
  103. }
  104. sum += 80;
  105. copy.Add(buttonObj);
  106. }
  107. RectTransform contentTransform = buttonscroll.content;
  108. contentTransform.anchoredPosition = new Vector2(contentTransform.anchoredPosition.x, 0);
  109. contentTransform.sizeDelta = new Vector2(contentTransform.sizeDelta.x, sum);
  110. if (sum > 703)
  111. {
  112. buttonscroll.vertical = true;
  113. }
  114. else
  115. {
  116. buttonscroll.vertical = false;
  117. }
  118. 讀取面板.SetActive(false);
  119. }
  120. void UpdateDateDisplay()
  121. {
  122. CultureInfo chineseCulture = new CultureInfo("zh-CN");
  123. // 更新日期和星期顯示
  124. 日期.text = currentDate.ToString("yyyy/MM/dd-dddd", chineseCulture);
  125. StartCoroutine(生產排程明細表());
  126. }
  127. public void 上一天()
  128. {
  129. // 減少一天
  130. currentDate = currentDate.AddDays(-1);
  131. UpdateDateDisplay();
  132. }
  133. public void 下一天()
  134. {
  135. // 增加一天
  136. currentDate = currentDate.AddDays(1);
  137. UpdateDateDisplay();
  138. }
  139. IEnumerator AnimateText()
  140. {
  141. string qqq = 讀取.text.ToString();
  142. while (true)
  143. {
  144. yield return new WaitForSeconds(0.5f);
  145. if (dotCount < 3)
  146. {
  147. loadingText += ".";
  148. dotCount++;
  149. }
  150. else
  151. {
  152. loadingText = "";
  153. dotCount = 0;
  154. }
  155. 讀取.text = qqq + loadingText;
  156. }
  157. }
  158. public void 彈跳面板關閉()
  159. {
  160. 彈跳面板.SetActive(false);
  161. 彈跳文字.text = "";
  162. }
  163. private void DeleteCopies(List<GameObject> copyList)
  164. {
  165. foreach (GameObject copy in copyList)
  166. {
  167. Destroy(copy);
  168. }
  169. copyList.Clear();
  170. }
  171. public void back()
  172. {
  173. change_Secen(12);
  174. }
  175. public void change_Secen(int _screenNum)
  176. {
  177. SceneManager.LoadScene(_screenNum);
  178. }
  179. }