Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

盤點查看審核.cs 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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. [SerializeField] GameObject 初始頁;
  21. [SerializeField] GameObject 選擇頁;
  22. [SerializeField] GameObject 主頁;
  23. [SerializeField] GameObject 明細頁;
  24. [SerializeField] GameObject 審查按鈕;
  25. [SerializeField] TextMeshProUGUI 單號;
  26. [SerializeField] TextMeshProUGUI 日期;
  27. [SerializeField] TextMeshProUGUI 人員;
  28. [SerializeField] TextMeshProUGUI 類型;
  29. [SerializeField] TextMeshProUGUI 狀態;
  30. [SerializeField] TextMeshProUGUI 備註;
  31. [SerializeField] TMP_InputField 關鍵字;
  32. public CanvasScaler canvasScaler;
  33. float screenWidth;
  34. float screenHeight;
  35. [SerializeField] GameObject 彈跳面板叉叉;
  36. [SerializeField] GameObject 彈跳面板;
  37. [SerializeField] TextMeshProUGUI 彈跳文字;
  38. [SerializeField] Button 彈跳是;
  39. [SerializeField] Button 彈跳否;
  40. [SerializeField] GameObject 讀取面板;
  41. [SerializeField] TextMeshProUGUI 讀取;
  42. public GameObject buttonPrefab;
  43. public Transform buttonParent;
  44. public GameObject buttonceneter;
  45. private List<GameObject> copy = new List<GameObject>();
  46. public GameObject buttonPrefab1;
  47. public Transform buttonParent1;
  48. public GameObject buttonceneter1;
  49. private List<GameObject> copy1 = new List<GameObject>();
  50. private string loadingText = "";
  51. private int dotCount = 0;
  52. string 模式 = "";
  53. JSONNode 簽名檔;
  54. JSONNode 計算;
  55. // Start is called before the first frame update
  56. void Start()
  57. {
  58. Screen.autorotateToPortrait = false;
  59. Screen.orientation = ScreenOrientation.Portrait;
  60. float rate = 900.0f / 1900.0f;
  61. if (Main.Global.rate>rate)
  62. {
  63. canvasScaler.matchWidthOrHeight = 1f;
  64. }
  65. else
  66. {
  67. canvasScaler.matchWidthOrHeight = 0f;
  68. }
  69. //Main.Global.阿帕契路徑="http://106.1.48.106:8080/wp-content/themes/event-star/shto_main.php?";
  70. //Main.Global.預設伺服器路徑="official";
  71. //Main.Global.人員="李卓叡";
  72. StartCoroutine(AnimateText());
  73. 初始頁.SetActive(true);
  74. 選擇頁.SetActive(false);
  75. 主頁.SetActive(false);
  76. 明細頁.SetActive(false);
  77. 審查按鈕.SetActive(false);
  78. StartCoroutine(主管簽名檔清單());
  79. }
  80. IEnumerator 主管簽名檔清單()
  81. {
  82. string strcon = "主管簽名檔清單";
  83. string se = Main.Global.預設伺服器路徑;
  84. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
  85. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  86. yield return request.SendWebRequest();
  87. if (request.result == UnityWebRequest.Result.ConnectionError)
  88. {
  89. Debug.Log(request.error);
  90. yield break;
  91. }
  92. 簽名檔 = JSON.Parse(request.downloadHandler.text);
  93. Debug.Log(簽名檔);
  94. }
  95. IEnumerator AnimateText()
  96. {
  97. string qqq = 讀取.text.ToString();
  98. while (true)
  99. {
  100. yield return new WaitForSeconds(0.5f);
  101. if (dotCount < 3)
  102. {
  103. loadingText += ".";
  104. dotCount++;
  105. }
  106. else
  107. {
  108. loadingText = "";
  109. dotCount = 0;
  110. }
  111. 讀取.text = qqq+loadingText;
  112. }
  113. }
  114. public void 審查()
  115. {
  116. if (Main.Global.級別 == "00" && Main.Global.職稱 == "00000.NA")
  117. {
  118. 模式 = "審查";
  119. 選擇頁.SetActive(true);
  120. StartCoroutine(盤營盤損歷表());
  121. }
  122. else if (Main.Global.級別 == "03" && Main.Global.職稱 == "31001.廠務部廠長")
  123. {
  124. 模式 = "審查";
  125. 選擇頁.SetActive(true);
  126. StartCoroutine(盤營盤損歷表());
  127. }
  128. else
  129. {
  130. 彈跳面板.SetActive(true);
  131. 彈跳文字.text = "簽核權限錯誤!!";
  132. }
  133. }
  134. public void 未審()
  135. {
  136. 模式 = "未審";
  137. 選擇頁.SetActive(true);
  138. StartCoroutine(盤營盤損歷表());
  139. }
  140. public void 已審()
  141. {
  142. 模式 = "已審";
  143. 選擇頁.SetActive(true);
  144. StartCoroutine(盤營盤損歷表());
  145. }
  146. public void 關()
  147. {
  148. 模式 = "";
  149. 選擇頁.SetActive(false);
  150. }
  151. IEnumerator 盤營盤損歷表()
  152. {
  153. 讀取面板.SetActive(true);
  154. if (copy != null)
  155. {
  156. DeletetextCopies();
  157. }
  158. string strcon = "";
  159. if (模式 == "已審")
  160. {
  161. strcon = "盤營盤損已審";
  162. }
  163. else if(模式 == "未審")
  164. {
  165. strcon = "盤營盤損未審";
  166. }
  167. else
  168. {
  169. strcon = "盤營盤損審核";
  170. }
  171. string se = Main.Global.預設伺服器路徑;
  172. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
  173. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  174. yield return request.SendWebRequest();
  175. if (request.result == UnityWebRequest.Result.ConnectionError)
  176. {
  177. Debug.Log(request.error);
  178. yield break;
  179. }
  180. JSONNode json = JSON.Parse(request.downloadHandler.text);
  181. int sum = 2;
  182. for (int i = 0; i < json.Count; i++)
  183. {
  184. GameObject buttonObj = Instantiate(buttonPrefab) as GameObject;
  185. buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
  186. buttonObj.transform.SetParent(buttonParent, false);
  187. TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
  188. Button bt = buttonObj.GetComponentInChildren<Button>();
  189. int index = i;
  190. bt.onClick.AddListener(() =>
  191. {
  192. 初始頁.SetActive(false);
  193. 選擇頁.SetActive(false);
  194. 主頁.SetActive(true);
  195. 單號.text=json[index][0].ToString().Trim('"');
  196. 日期.text=json[index][3].ToString().Trim('"');
  197. 備註.text=json[index][5].ToString().Trim('"');
  198. 人員.text=json[index][2].ToString().Trim('"');
  199. 類型.text=json[index][4].ToString().Trim('"');
  200. Debug.Log(json[index][8]);
  201. if(json[index][8] == null || json[index][8].ToString().Trim('"')=="")
  202. {
  203. 狀態.text="盤點未完成";
  204. }
  205. else
  206. {
  207. 狀態.text=json[index][8].ToString().Trim('"');
  208. }
  209. StartCoroutine(庫存盤點申請明細表讀取());
  210. });
  211. text[0].text = json[i][0].ToString().Trim('"');
  212. text[1].text = json[i][3].ToString().Trim('"');
  213. sum+=100;
  214. copy.Add(buttonObj);
  215. }
  216. buttonceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter.GetComponent<RectTransform>().sizeDelta.x, sum);
  217. 讀取面板.SetActive(false);
  218. }
  219. public void 關鍵字搜尋()
  220. {
  221. StartCoroutine(庫存盤點申請明細表讀取());
  222. }
  223. IEnumerator 庫存盤點申請明細表讀取()
  224. {
  225. 讀取面板.SetActive(true);
  226. if (copy1 != null)
  227. {
  228. DeletetextCopies1();
  229. }
  230. string pa = 單號.text;
  231. string pa1 = 關鍵字.text;
  232. string strcon = "庫存盤點申請明細表讀取";
  233. string se = Main.Global.預設伺服器路徑;
  234. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}", strcon, se, pa, pa1);
  235. Debug.Log(strUrl);
  236. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  237. yield return request.SendWebRequest();
  238. if (request.result == UnityWebRequest.Result.ConnectionError)
  239. {
  240. Debug.Log(request.error);
  241. yield break;
  242. }
  243. 計算 = JSON.Parse(request.downloadHandler.text);
  244. int sum = 2;
  245. for (int i = 0; i < 計算.Count; i++)
  246. {
  247. GameObject buttonObj = Instantiate(buttonPrefab1) as GameObject;
  248. buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
  249. buttonObj.transform.SetParent(buttonParent1, false);
  250. TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
  251. text[0].text = (i+1).ToString();
  252. text[1].text = 計算[i][4].ToString().Trim('"');
  253. text[2].text = 計算[i][6].ToString().Trim('"');
  254. text[3].text = 計算[i][7].ToString().Trim('"');
  255. sum+=100;
  256. copy1.Add(buttonObj);
  257. }
  258. buttonceneter1.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter1.GetComponent<RectTransform>().sizeDelta.x, sum);
  259. 讀取面板.SetActive(false);
  260. }
  261. public void 審核()
  262. {
  263. for (int i = 0; i < 簽名檔.Count; i++)
  264. {
  265. if (Main.Global.人員 == 簽名檔[i][1].ToString().Trim('"'))
  266. {
  267. string str = 簽名檔[i][0].ToString().Trim('"');
  268. StartCoroutine(修改盤營盤損控制表簽名(str));
  269. }
  270. }
  271. }
  272. IEnumerator 修改盤營盤損控制表簽名(string str)
  273. {
  274. string strcon = "修改盤營盤損控制表簽名";
  275. string se = Main.Global.預設伺服器路徑;
  276. string pa2 = DateTime.Now.ToString("yyyy/MM/dd");
  277. string pa3 = 單號.text;
  278. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}"
  279. , strcon, se, str, pa2, pa3);
  280. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  281. Debug.Log(strUrl);
  282. yield return request.SendWebRequest();
  283. if (request.result == UnityWebRequest.Result.ConnectionError)
  284. {
  285. Debug.Log(request.error);
  286. yield break;
  287. }
  288. for (int i = 0; i < 計算.Count; i++)
  289. {
  290. if (計算[i][2].ToString().Trim('"') != "")
  291. {
  292. int 庫存 = 計算[i][6];
  293. int 盤點 = 計算[i][7];
  294. int 總和 = 盤點-庫存;
  295. string 流水 = 計算[i][2].ToString().Trim('"');
  296. if (總和 > 0)
  297. {
  298. yield return StartCoroutine(盤點審核排程明細表修改(流水,"盤盈核准"));
  299. }
  300. else if (總和 < 0)
  301. {
  302. yield return StartCoroutine(盤點審核排程明細表修改(流水,"盤損核准"));
  303. }
  304. }
  305. }
  306. 彈跳面板.SetActive(true);
  307. 彈跳文字.text = "審核成功!!";
  308. 模式 = "";
  309. 單號.text="";
  310. 日期.text="";
  311. 備註.text="";
  312. 人員.text="";
  313. 類型.text="";
  314. 狀態.text="";
  315. 初始頁.SetActive(true);
  316. 選擇頁.SetActive(false);
  317. 主頁.SetActive(false);
  318. 明細頁.SetActive(false);
  319. }
  320. IEnumerator 盤點審核排程明細表修改(string 流水號, string 狀態)
  321. {
  322. string strcon = "盤點審核排程明細表修改";
  323. string se = Main.Global.預設伺服器路徑;
  324. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}", strcon, se, 流水號, 狀態);
  325. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  326. Debug.Log(strUrl);
  327. yield return request.SendWebRequest();
  328. if (request.result == UnityWebRequest.Result.ConnectionError)
  329. {
  330. Debug.Log(request.error);
  331. yield break;
  332. }
  333. }
  334. public void 上一頁21()
  335. {
  336. 模式 = "";
  337. 單號.text="";
  338. 日期.text="";
  339. 備註.text="";
  340. 人員.text="";
  341. 類型.text="";
  342. 狀態.text="";
  343. 初始頁.SetActive(true);
  344. 選擇頁.SetActive(false);
  345. 主頁.SetActive(false);
  346. }
  347. public void 上一頁32()
  348. {
  349. 主頁.SetActive(true);
  350. 明細頁.SetActive(false);
  351. }
  352. public void 下一頁23()
  353. {
  354. 主頁.SetActive(false);
  355. 明細頁.SetActive(true);
  356. if (模式 == "審查")
  357. {
  358. 審查按鈕.SetActive(true);
  359. }
  360. else
  361. {
  362. 審查按鈕.SetActive(false);
  363. }
  364. }
  365. public void 彈跳關閉()
  366. {
  367. 彈跳面板.SetActive(false);
  368. 彈跳文字.text = "";
  369. }
  370. public void home()
  371. {
  372. change_Secen(1);
  373. }
  374. public void change_Secen(int _screenNum)
  375. {
  376. SceneManager.LoadScene(_screenNum);
  377. }
  378. public void DeletetextCopies1()
  379. {
  380. // 刪除複製出來的物件
  381. foreach (GameObject copy in copy1)
  382. {
  383. Destroy(copy);
  384. }
  385. copy1.Clear();
  386. }
  387. public void DeletetextCopies()
  388. {
  389. // 刪除複製出來的物件
  390. foreach (GameObject copy in copy)
  391. {
  392. Destroy(copy);
  393. }
  394. copy.Clear();
  395. }
  396. }