Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

生產排程表.cs 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. public class 生產排程表 : MonoBehaviour
  19. {
  20. public CanvasScaler canvasScaler;
  21. float screenWidth;
  22. float screenHeight;
  23. private string loadingText = "";
  24. private int dotCount = 0;
  25. public GameObject buttonPrefab;
  26. public Transform buttonParent;
  27. public GameObject buttonceneter;
  28. private List<GameObject> copy = new List<GameObject>();
  29. [SerializeField] GameObject 讀取面板;
  30. [SerializeField] TextMeshProUGUI 讀取;
  31. [SerializeField] GameObject 彈跳面板;
  32. [SerializeField] TextMeshProUGUI 彈跳文字;
  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. StartCoroutine(AnimateText());
  50. 讀取面板.SetActive(true);
  51. StartCoroutine(生產排程明細表());
  52. }
  53. IEnumerator AnimateText()
  54. {
  55. string qqq = 讀取.text.ToString();
  56. while (true)
  57. {
  58. yield return new WaitForSeconds(0.5f);
  59. if (dotCount < 3)
  60. {
  61. loadingText += ".";
  62. dotCount++;
  63. }
  64. else
  65. {
  66. loadingText = "";
  67. dotCount = 0;
  68. }
  69. 讀取.text = qqq+loadingText;
  70. }
  71. }
  72. IEnumerator 生產排程明細表()
  73. {
  74. if (copy != null)
  75. {
  76. DeletetextCopies();
  77. }
  78. string strcon = "生產排程明細表";
  79. string se = Main.Global.預設伺服器路徑;
  80. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
  81. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  82. yield return request.SendWebRequest();
  83. if (request.result == UnityWebRequest.Result.ConnectionError)
  84. {
  85. Debug.Log(request.error);
  86. yield break;
  87. }
  88. JSONNode json = JSON.Parse(request.downloadHandler.text);
  89. int sum = 3;
  90. for (int i = 0; i < json.Count; i++)
  91. {
  92. GameObject buttonObj = Instantiate(buttonPrefab) as GameObject;
  93. buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(3, -sum);
  94. buttonObj.transform.SetParent(buttonParent, false);
  95. TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
  96. Button bt = buttonObj.GetComponentInChildren<Button>();
  97. TMP_InputField tif = buttonObj.GetComponentInChildren<TMP_InputField>();
  98. int index = i;
  99. bt.onClick.AddListener(() =>
  100. {
  101. string str= json[index][0].ToString().Trim('"');
  102. string str1 = json[index][5].ToString().Trim('"');
  103. if (Main.Global.部門 == "3.廠務部" || Main.Global.部門 == "0.NA")
  104. {
  105. 讀取面板.SetActive(true);
  106. StartCoroutine(生產排程表修改(str, str1));
  107. }
  108. else
  109. {
  110. 彈跳面板.SetActive(true);
  111. 彈跳文字.text = "登入權限不足!!";
  112. }
  113. });
  114. tif.onValueChanged.AddListener((value) =>
  115. {
  116. json[index][5] = value;
  117. });
  118. text[0].text = json[i][2].ToString().Trim('"');
  119. text[1].text = json[i][3].ToString().Trim('"');
  120. text[2].text = json[i][4].ToString().Trim('"');
  121. text[4].text = json[i][10].ToString().Trim('"');
  122. tif.text = json[i][5].ToString().Trim('"');
  123. sum+=80;
  124. copy.Add(buttonObj);
  125. }
  126. buttonceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter.GetComponent<RectTransform>().sizeDelta.x, sum);
  127. 讀取面板.SetActive(false);
  128. }
  129. IEnumerator 生產排程表修改(string 流水 ,string 產量)
  130. {
  131. DateTime currentDate = DateTime.Now;
  132. string pa= currentDate.ToString("yyyy/MM/dd");
  133. string strcon = "生產排程表修改";
  134. string se = Main.Global.預設伺服器路徑;
  135. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}", strcon, se, pa, 產量, 流水);
  136. Debug.Log(strUrl);
  137. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  138. yield return request.SendWebRequest();
  139. if (request.result == UnityWebRequest.Result.ConnectionError)
  140. {
  141. Debug.Log(request.error);
  142. yield break;
  143. }
  144. StartCoroutine(生產排程明細表());
  145. }
  146. public void 彈跳面板關閉()
  147. {
  148. 彈跳面板.SetActive(false);
  149. 彈跳文字.text = "";
  150. }
  151. public void DeletetextCopies()
  152. {
  153. // 刪除複製出來的物件
  154. foreach (GameObject copy in copy)
  155. {
  156. Destroy(copy);
  157. }
  158. copy.Clear();
  159. }
  160. public void back()
  161. {
  162. change_Secen(12);
  163. }
  164. public void change_Secen(int _screenNum)
  165. {
  166. SceneManager.LoadScene(_screenNum);
  167. }
  168. }