暫無描述
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 41KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195
  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 儲存1;
  23. [SerializeField] GameObject 儲存2;
  24. [SerializeField] GameObject 選擇畫面;
  25. [SerializeField] GameObject 選擇單號;
  26. [SerializeField] GameObject 查找紐;
  27. [SerializeField] GameObject 選擇;
  28. [SerializeField] GameObject 選擇1;
  29. [SerializeField] GameObject 選擇2;
  30. [SerializeField] GameObject 選擇3;
  31. [SerializeField] GameObject 初始畫面;
  32. [SerializeField] GameObject 主畫面;
  33. [SerializeField] TextMeshProUGUI 單號;
  34. [SerializeField] TextMeshProUGUI 日期;
  35. [SerializeField] TextMeshProUGUI 人員s;
  36. public TMP_Dropdown 盤點類型;
  37. [SerializeField] TMP_InputField 備註;
  38. [SerializeField] TMP_InputField 關鍵字;
  39. public CanvasScaler canvasScaler;
  40. float screenWidth;
  41. float screenHeight;
  42. [SerializeField] GameObject 彈跳面板叉叉;
  43. [SerializeField] GameObject 彈跳面板;
  44. [SerializeField] GameObject 彈跳面板的按鈕;
  45. [SerializeField] TextMeshProUGUI 彈跳文字;
  46. [SerializeField] Button 彈跳是;
  47. [SerializeField] Button 彈跳否;
  48. [SerializeField] GameObject 讀取面板;
  49. [SerializeField] TextMeshProUGUI 讀取;
  50. JSONNode 清單;
  51. JSONNode 清單1;
  52. public GameObject buttonPrefab;
  53. public Transform buttonParent;
  54. public GameObject buttonceneter;
  55. private List<GameObject> copy = new List<GameObject>();
  56. public GameObject buttonPrefab1;
  57. public Transform buttonParent1;
  58. public GameObject buttonceneter1;
  59. private List<GameObject> copy1 = new List<GameObject>();
  60. public GameObject buttonPrefab2;
  61. public Transform buttonParent2;
  62. public GameObject buttonceneter2;
  63. private List<GameObject> copy2 = new List<GameObject>();
  64. public GameObject buttonPrefab3;
  65. public Transform buttonParent3;
  66. public GameObject buttonceneter3;
  67. private List<GameObject> copy3 = new List<GameObject>();
  68. public GameObject buttonPrefab4;
  69. public Transform buttonParent4;
  70. public GameObject buttonceneter4;
  71. private List<GameObject> copy4 = new List<GameObject>();
  72. public GameObject buttonPrefab5;
  73. public Transform buttonParent5;
  74. public GameObject buttonceneter5;
  75. private List<GameObject> copy5 = new List<GameObject>();
  76. private string loadingText = "";
  77. private int dotCount = 0;
  78. bool ttt = false;
  79. string ddd;
  80. bool ttt1 = false;
  81. string 模式 = "";
  82. // Start is called before the first frame update
  83. void Start()
  84. {
  85. Screen.autorotateToPortrait = false;
  86. Screen.orientation = ScreenOrientation.Portrait;
  87. float rate = 900.0f / 1900.0f;
  88. if (Main.Global.rate>rate)
  89. {
  90. canvasScaler.matchWidthOrHeight = 1f;
  91. }
  92. else
  93. {
  94. canvasScaler.matchWidthOrHeight = 0f;
  95. }
  96. //Main.Global.阿帕契路徑="http://106.1.48.106:8080/wp-content/themes/event-star/shto_main.php?";
  97. //Main.Global.預設伺服器路徑="official";
  98. //Main.Global.人員="李卓叡";
  99. StartCoroutine(AnimateText());
  100. StartCoroutine(群組碼清單());
  101. 查找紐.SetActive(false);
  102. 選擇.SetActive(false);
  103. 選擇1.SetActive(true);
  104. 選擇2.SetActive(false);
  105. 選擇3.SetActive(false);
  106. 初始畫面.SetActive(false);
  107. 主畫面.SetActive(false);
  108. 選擇單號.SetActive(false);
  109. 選擇畫面.SetActive(true);
  110. }
  111. IEnumerator AnimateText()
  112. {
  113. string qqq = 讀取.text.ToString();
  114. while (true)
  115. {
  116. yield return new WaitForSeconds(0.5f);
  117. if (dotCount < 3)
  118. {
  119. loadingText += ".";
  120. dotCount++;
  121. }
  122. else
  123. {
  124. loadingText = "";
  125. dotCount = 0;
  126. }
  127. 讀取.text = qqq+loadingText;
  128. }
  129. }
  130. IEnumerator 盤營盤損歷表()
  131. {
  132. 讀取面板.SetActive(true);
  133. if (copy4 != null)
  134. {
  135. DeletetextCopies4();
  136. }
  137. string strcon = "";
  138. if (模式 == "續點")
  139. {
  140. strcon = "盤營盤損歷表本";
  141. }
  142. else
  143. {
  144. strcon = "盤營盤損歷表非本";
  145. }
  146. string pa = Main.Global.人員;
  147. string se = Main.Global.預設伺服器路徑;
  148. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}", strcon, se,pa);
  149. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  150. yield return request.SendWebRequest();
  151. if (request.result == UnityWebRequest.Result.ConnectionError)
  152. {
  153. Debug.Log(request.error);
  154. yield break;
  155. }
  156. JSONNode json = JSON.Parse(request.downloadHandler.text);
  157. int sum = 2;
  158. for (int i = 0; i < json.Count; i++)
  159. {
  160. GameObject buttonObj = Instantiate(buttonPrefab4) as GameObject;
  161. buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
  162. buttonObj.transform.SetParent(buttonParent4, false);
  163. TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
  164. Button bt = buttonObj.GetComponentInChildren<Button>();
  165. int index = i;
  166. bt.onClick.AddListener(() =>
  167. {
  168. 初始畫面.SetActive(true);
  169. 選擇畫面.SetActive(false);
  170. 選擇單號.SetActive(false);
  171. 單號.text=json[index][0].ToString().Trim('"');
  172. 日期.text=json[index][3].ToString().Trim('"');
  173. 備註.text=json[index][5].ToString().Trim('"');
  174. 人員s.text=json[index][2].ToString().Trim('"');
  175. int index2 = 盤點類型.options.FindIndex(option => option.text == json[index][4].ToString().Trim('"'));
  176. 盤點類型.value = index2;
  177. });
  178. text[0].text = json[i][0].ToString().Trim('"');
  179. text[1].text = json[i][3].ToString().Trim('"');
  180. sum+=100;
  181. copy4.Add(buttonObj);
  182. }
  183. buttonceneter4.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter4.GetComponent<RectTransform>().sizeDelta.x, sum);
  184. 讀取面板.SetActive(false);
  185. }
  186. IEnumerator 群組碼清單()
  187. {
  188. string strcon = "群組碼清單";
  189. string se = Main.Global.預設伺服器路徑;
  190. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
  191. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  192. yield return request.SendWebRequest();
  193. if (request.result == UnityWebRequest.Result.ConnectionError)
  194. {
  195. Debug.Log(request.error);
  196. yield break;
  197. }
  198. JSONNode json = JSON.Parse(request.downloadHandler.text);
  199. Debug.Log(json);
  200. int sum = 2;
  201. for (int i = 0; i < json.Count; i++)
  202. {
  203. GameObject buttonObj = Instantiate(buttonPrefab) as GameObject;
  204. buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
  205. buttonObj.transform.SetParent(buttonParent, false);
  206. TextMeshProUGUI text = buttonObj.GetComponentInChildren<TextMeshProUGUI>();
  207. Button bt = buttonObj.GetComponentInChildren<Button>();
  208. int index = i;
  209. bt.onClick.AddListener(() =>
  210. {
  211. string str = json[index].ToString().Trim('"');
  212. StartCoroutine(物料清單(str));
  213. 選擇1.SetActive(false);
  214. 選擇2.SetActive(true);
  215. });
  216. text.text = json[i].ToString().Trim('"');
  217. sum+=200;
  218. copy.Add(buttonObj);
  219. }
  220. buttonceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter.GetComponent<RectTransform>().sizeDelta.x, sum);
  221. yield return StartCoroutine(起始刪除());
  222. }
  223. IEnumerator 物料清單(string pa)
  224. {
  225. if (copy1 != null)
  226. {
  227. DeletetextCopies1();
  228. }
  229. string strcon = "物料清單";
  230. string se = Main.Global.預設伺服器路徑;
  231. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}", strcon, se, pa );
  232. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  233. yield return request.SendWebRequest();
  234. if (request.result == UnityWebRequest.Result.ConnectionError)
  235. {
  236. Debug.Log(request.error);
  237. yield break;
  238. }
  239. JSONNode json = JSON.Parse(request.downloadHandler.text);
  240. int sum = 2;
  241. for (int i = 0; i < json.Count; i++)
  242. {
  243. GameObject buttonObj = Instantiate(buttonPrefab1) as GameObject;
  244. buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
  245. buttonObj.transform.SetParent(buttonParent1, false);
  246. TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
  247. Button bt = buttonObj.GetComponentInChildren<Button>();
  248. int index = i;
  249. bt.onClick.AddListener(() =>
  250. {
  251. string str = json[index][0].ToString().Trim('"');
  252. string str1 = json[index][1].ToString().Trim('"');
  253. StartCoroutine(物料明細清單(str,str1));
  254. 選擇2.SetActive(false);
  255. 選擇3.SetActive(true);
  256. });
  257. text[0].text = (i+1).ToString();
  258. text[1].text = json[i][2].ToString().Trim('"');
  259. sum+=100;
  260. copy1.Add(buttonObj);
  261. }
  262. buttonceneter1.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter1.GetComponent<RectTransform>().sizeDelta.x, sum);
  263. }
  264. IEnumerator 物料明細清單(string pa, string pa1)
  265. {
  266. if (copy2 != null)
  267. {
  268. DeletetextCopies2();
  269. }
  270. string strcon = "物料明細清單";
  271. string se = Main.Global.預設伺服器路徑;
  272. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}", strcon, se, pa, pa1);
  273. Debug.Log(strUrl);
  274. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  275. yield return request.SendWebRequest();
  276. if (request.result == UnityWebRequest.Result.ConnectionError)
  277. {
  278. Debug.Log(request.error);
  279. yield break;
  280. }
  281. JSONNode json = JSON.Parse(request.downloadHandler.text);
  282. Debug.Log(json);
  283. int sum = 2;
  284. int j = 1;
  285. for (int i = 0; i < json.Count; i++)
  286. {
  287. if (json[i][9].ToString().Trim('"') != "是")
  288. {
  289. GameObject buttonObj = Instantiate(buttonPrefab2) as GameObject;
  290. buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
  291. buttonObj.transform.SetParent(buttonParent2, false);
  292. TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
  293. Button bt = buttonObj.GetComponentInChildren<Button>();
  294. int index = i;
  295. bt.onClick.AddListener(() =>
  296. {
  297. 讀取面板.SetActive(true);
  298. string str = json[index][2].ToString().Trim('"');
  299. string str1 = json[index][5].ToString().Trim('"');
  300. StartCoroutine(選定物料庫存量讀取(str,str1));
  301. });
  302. text[0].text = j.ToString();
  303. text[1].text = json[i][5].ToString().Trim('"');
  304. text[2].text = json[i][6].ToString().Trim('"');
  305. j+=1;
  306. sum+=150;
  307. copy2.Add(buttonObj);
  308. }
  309. }
  310. buttonceneter2.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter2.GetComponent<RectTransform>().sizeDelta.x, sum);
  311. }
  312. IEnumerator 選定物料庫存量讀取(string 料號,string 品名)
  313. {
  314. string strcon = "選定物料庫存量讀取";
  315. string se = Main.Global.預設伺服器路徑;
  316. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}", strcon, se, 料號);
  317. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  318. yield return request.SendWebRequest();
  319. if (request.result == UnityWebRequest.Result.ConnectionError)
  320. {
  321. Debug.Log(request.error);
  322. yield break;
  323. }
  324. string str = request.downloadHandler.text.ToString();
  325. string 庫存 = "";
  326. if (str == "n")
  327. {
  328. 庫存="0";
  329. }
  330. else
  331. {
  332. 庫存 = str;
  333. }
  334. Debug.Log(庫存);
  335. yield return StartCoroutine(物料明細讀取(料號, 品名, 庫存));
  336. }
  337. IEnumerator 物料明細讀取(string 料號, string 品名, string 庫存)
  338. {
  339. string pa = 單號.text;
  340. string strcon = "物料明細讀取";
  341. string se = Main.Global.預設伺服器路徑;
  342. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}", strcon, se, pa, 料號);
  343. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  344. yield return request.SendWebRequest();
  345. if (request.result == UnityWebRequest.Result.ConnectionError)
  346. {
  347. Debug.Log(request.error);
  348. yield break;
  349. }
  350. string str = request.downloadHandler.text.ToString();
  351. if (str == "n")
  352. {
  353. Debug.Log("t");
  354. yield return StartCoroutine(盤營盤損明細流水號最後一比(料號, 品名, 庫存));
  355. }
  356. else
  357. {
  358. 讀取面板.SetActive(false);
  359. 彈跳面板.SetActive(true);
  360. 彈跳文字.text = "此單已有此料號";
  361. }
  362. }
  363. IEnumerator 盤營盤損明細流水號最後一比(string 料號, string 品名, string 庫存)
  364. {
  365. string strcon = "盤營盤損明細流水號最後一比";
  366. string se = Main.Global.預設伺服器路徑;
  367. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
  368. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  369. yield return request.SendWebRequest();
  370. if (request.result == UnityWebRequest.Result.ConnectionError)
  371. {
  372. Debug.Log(request.error);
  373. yield break;
  374. }
  375. string str = request.downloadHandler.text.ToString();
  376. string 流水 = "";
  377. if (str == "n")
  378. {
  379. 流水="ID00000000";
  380. }
  381. else
  382. {
  383. int NUM1 = int.Parse(str.Substring(2)) + 1;
  384. 流水 = "ID" + NUM1.ToString().PadLeft(8, '0');
  385. }
  386. yield return StartCoroutine(盤點申請明細表新增(流水, 品名, 料號, 庫存));
  387. }
  388. IEnumerator 盤點申請明細表新增(string 流水 ,string 品名 , string 料號 , string 庫存)
  389. {
  390. string strcon = "盤點申請明細表新增";
  391. string se = Main.Global.預設伺服器路徑;
  392. string pa1 = 單號.text;
  393. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}&PA5={6}"
  394. , strcon, se, 流水, pa1, 品名, 料號, 庫存);
  395. Debug.Log(strUrl);
  396. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  397. yield return request.SendWebRequest();
  398. if (request.result == UnityWebRequest.Result.ConnectionError)
  399. {
  400. Debug.Log(request.error);
  401. yield break;
  402. }
  403. 讀取面板.SetActive(false);
  404. 彈跳面板.SetActive(true);
  405. 彈跳文字.text="新增物料成功";
  406. 彈跳面板的按鈕.SetActive(true);
  407. }
  408. IEnumerator 起始刪除()
  409. {
  410. string strcon = "起始刪除";
  411. string se = Main.Global.預設伺服器路徑;
  412. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
  413. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  414. yield return request.SendWebRequest();
  415. if (request.result == UnityWebRequest.Result.ConnectionError)
  416. {
  417. Debug.Log(request.error);
  418. yield break;
  419. }
  420. }
  421. public void 儲存單號()
  422. {
  423. 初始畫面.SetActive(false);
  424. 主畫面.SetActive(true);
  425. 讀取面板.SetActive(true);
  426. if (模式 == "複點")
  427. {
  428. 查找紐.SetActive(false);
  429. 盤點頁.SetActive(false);
  430. 複點頁.SetActive(true);
  431. StartCoroutine(庫存盤點申請明細表讀取1());
  432. }
  433. else
  434. {
  435. 查找紐.SetActive(true);
  436. 盤點頁.SetActive(true);
  437. 複點頁.SetActive(false);
  438. StartCoroutine(盤點申請控制表修改());
  439. }
  440. }
  441. public void 新增()
  442. {
  443. 模式 = "新增";
  444. 初始畫面.SetActive(true);
  445. 選擇畫面.SetActive(false);
  446. 人員s.text=Main.Global.人員;
  447. DateTime currentDate = DateTime.Now;
  448. 日期.text = currentDate.ToString("yyyy/MM/dd");
  449. StartCoroutine(盤營盤損流水號最後一比());
  450. }
  451. public void 續點()
  452. {
  453. 模式 = "續點";
  454. 選擇單號.SetActive(true);
  455. StartCoroutine(盤營盤損歷表());
  456. }
  457. public void 複點()
  458. {
  459. 模式 = "複點";
  460. 選擇單號.SetActive(true);
  461. StartCoroutine(盤營盤損歷表());
  462. }
  463. public void 關()
  464. {
  465. 模式 = "";
  466. 選擇單號.SetActive(false);
  467. }
  468. IEnumerator 盤營盤損流水號最後一比()
  469. {
  470. 讀取面板.SetActive(true);
  471. string strcon = "盤營盤損流水號最後一比";
  472. string se = Main.Global.預設伺服器路徑;
  473. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
  474. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  475. yield return request.SendWebRequest();
  476. if (request.result == UnityWebRequest.Result.ConnectionError)
  477. {
  478. Debug.Log(request.error);
  479. yield break;
  480. }
  481. string str = request.downloadHandler.text.ToString();
  482. if (str == "n")
  483. {
  484. 單號.text="IN00000000";
  485. }
  486. else
  487. {
  488. int NUM1 = int.Parse(str.Substring(2)) + 1;
  489. 單號.text = "IN" + NUM1.ToString().PadLeft(8, '0');
  490. }
  491. yield return StartCoroutine(盤點申請控制表新增());
  492. }
  493. IEnumerator 盤點申請控制表新增()
  494. {
  495. string strcon = "盤點申請控制表新增";
  496. string se = Main.Global.預設伺服器路徑;
  497. string pa1 = 單號.text;
  498. string pa2 = 人員s.text;
  499. string pa3 = 日期.text;
  500. string pa4 = 盤點類型.options[盤點類型.value].text;
  501. string pa5 = 備註.text;
  502. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}&PA5={6}"
  503. , strcon, se, pa1, pa2, pa3, pa4, pa5);
  504. Debug.Log(strUrl);
  505. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  506. yield return request.SendWebRequest();
  507. if (request.result == UnityWebRequest.Result.ConnectionError)
  508. {
  509. Debug.Log(request.error);
  510. yield break;
  511. }
  512. 讀取面板.SetActive(false);
  513. 彈跳面板.SetActive(true);
  514. 彈跳文字.text="新增單號成功";
  515. }
  516. IEnumerator 盤點申請控制表修改()
  517. {
  518. string strcon = "盤點申請控制表修改";
  519. string se = Main.Global.預設伺服器路徑;
  520. string pa1 = 單號.text;
  521. string pa2 = 人員s.text;
  522. string pa3 = 日期.text;
  523. string pa4 = 盤點類型.options[盤點類型.value].text;
  524. string pa5 = 備註.text;
  525. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}&PA5={6}"
  526. , strcon, se, pa1, pa2, pa3, pa4, pa5);
  527. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  528. yield return request.SendWebRequest();
  529. if (request.result == UnityWebRequest.Result.ConnectionError)
  530. {
  531. Debug.Log(request.error);
  532. yield break;
  533. }
  534. yield return StartCoroutine(庫存盤點申請明細表讀取());
  535. }
  536. IEnumerator 庫存盤點申請明細表讀取()
  537. {
  538. 讀取面板.SetActive(true);
  539. if (copy3 != null)
  540. {
  541. DeletetextCopies3();
  542. }
  543. string pa = 單號.text;
  544. string pa1 = 關鍵字.text;
  545. string strcon = "庫存盤點申請明細表讀取";
  546. string se = Main.Global.預設伺服器路徑;
  547. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}", strcon, se, pa, pa1);
  548. Debug.Log(strUrl);
  549. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  550. yield return request.SendWebRequest();
  551. if (request.result == UnityWebRequest.Result.ConnectionError)
  552. {
  553. Debug.Log(request.error);
  554. yield break;
  555. }
  556. 清單 = JSON.Parse(request.downloadHandler.text);
  557. int sum = 2;
  558. for (int i = 0; i < 清單.Count; i++)
  559. {
  560. GameObject buttonObj = Instantiate(buttonPrefab3) as GameObject;
  561. buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
  562. buttonObj.transform.SetParent(buttonParent3, false);
  563. TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
  564. TMP_InputField texti = buttonObj.GetComponentInChildren<TMP_InputField>();
  565. Button[] bt = buttonObj.GetComponentsInChildren<Button>();
  566. Image[] im = buttonObj.GetComponentsInChildren<Image>();
  567. int index = i;
  568. bt[0].onClick.AddListener(() =>
  569. {
  570. if (清單[index][10]==1)
  571. {
  572. 清單[index][10]=0;
  573. im[2].color = new Color32(255, 255, 255, 255);
  574. }
  575. else
  576. {
  577. 清單[index][10]=1;
  578. im[2].color = new Color32(160, 255, 160, 255);
  579. }
  580. });
  581. bt[1].onClick.AddListener(() =>
  582. {
  583. 彈跳面板.SetActive(true);
  584. 彈跳文字.text = "是否刪除物料";
  585. 彈跳是.gameObject.SetActive(true);
  586. 彈跳否.gameObject.SetActive(true);
  587. 彈跳是.onClick.AddListener(() =>
  588. {
  589. ttt = true;
  590. ddd = 清單[index][0].ToString().Trim('"');
  591. StartCoroutine(明細表儲存());
  592. });
  593. 彈跳否.onClick.AddListener(() =>
  594. {
  595. 彈跳面板關閉();
  596. });
  597. });
  598. text[0].text = (i+1).ToString();
  599. text[1].text = 清單[i][4].ToString().Trim('"');
  600. text[2].text = 清單[i][6].ToString().Trim('"');
  601. texti.text = 清單[i][7].ToString().Trim('"');
  602. if(清單[i][10]==1)
  603. {
  604. im[2].color = new Color32(160, 255, 160, 255);
  605. }
  606. texti.onValueChanged.AddListener((string newText) =>
  607. {
  608. if (int.TryParse(newText, out int currentValue))
  609. {
  610. if (currentValue< 0)
  611. {
  612. texti.text = "0";
  613. }
  614. else
  615. {
  616. 清單[index][7]=newText;
  617. Debug.Log(清單);
  618. }
  619. }
  620. });
  621. sum+=100;
  622. copy3.Add(buttonObj);
  623. }
  624. buttonceneter3.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter3.GetComponent<RectTransform>().sizeDelta.x, sum);
  625. 讀取面板.SetActive(false);
  626. if (ttt1==true)
  627. {
  628. yield return StartCoroutine(最後儲存());
  629. }
  630. }
  631. IEnumerator 庫存盤點申請明細表讀取1()
  632. {
  633. 讀取面板.SetActive(true);
  634. if (copy5 != null)
  635. {
  636. DeletetextCopies5();
  637. }
  638. string pa = 單號.text;
  639. string pa1 = 關鍵字.text;
  640. string strcon = "庫存盤點申請明細表讀取1";
  641. string se = Main.Global.預設伺服器路徑;
  642. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}", strcon, se, pa, pa1);
  643. Debug.Log(strUrl);
  644. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  645. yield return request.SendWebRequest();
  646. if (request.result == UnityWebRequest.Result.ConnectionError)
  647. {
  648. Debug.Log(request.error);
  649. yield break;
  650. }
  651. 清單1 = JSON.Parse(request.downloadHandler.text);
  652. Debug.Log(清單1);
  653. int sum = 2;
  654. for (int i = 0; i < 清單1.Count; i++)
  655. {
  656. GameObject buttonObj = Instantiate(buttonPrefab5) as GameObject;
  657. buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
  658. buttonObj.transform.SetParent(buttonParent5, false);
  659. TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
  660. Toggle tg = buttonObj.GetComponentInChildren<Toggle>();
  661. Button bt = buttonObj.GetComponentInChildren<Button>();
  662. int index = i;
  663. bt.onClick.AddListener(() =>
  664. {
  665. if (tg.isOn)
  666. {
  667. tg.isOn = false;
  668. 清單1[index][12] = 0;
  669. }
  670. else
  671. {
  672. tg.isOn = true;
  673. 清單1[index][12] = 1;
  674. }
  675. Debug.Log(清單1);
  676. });
  677. text[0].text = (i+1).ToString();
  678. text[1].text = 清單1[i][4].ToString().Trim('"');
  679. text[2].text = 清單1[i][6].ToString().Trim('"');
  680. text[3].text = 清單1[i][7].ToString().Trim('"');
  681. if (清單1[i][12] == 1)
  682. {
  683. tg.isOn = true;
  684. }
  685. sum+=100;
  686. copy5.Add(buttonObj);
  687. }
  688. buttonceneter5.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter5.GetComponent<RectTransform>().sizeDelta.x, sum);
  689. 讀取面板.SetActive(false);
  690. }
  691. IEnumerator 庫存盤點申請明細表刪除()
  692. {
  693. string strcon = "庫存盤點申請明細表刪除";
  694. string se = Main.Global.預設伺服器路徑;
  695. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}", strcon, se, ddd);
  696. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  697. yield return request.SendWebRequest();
  698. if (request.result == UnityWebRequest.Result.ConnectionError)
  699. {
  700. Debug.Log(request.error);
  701. yield break;
  702. }
  703. int index = 0;
  704. for (int i = 0; i < 清單.Count; i++)
  705. {
  706. if (清單[i][0]== ddd)
  707. {
  708. index = i;
  709. break;
  710. }
  711. }
  712. yield return StartCoroutine(盤營盤損排程流水號刪除(index));
  713. }
  714. public void 複點存檔()
  715. {
  716. 彈跳面板.SetActive(true);
  717. 彈跳文字.text = "複點儲存成功";
  718. StartCoroutine(明細表複點());
  719. }
  720. public IEnumerator 明細表複點()
  721. {
  722. 讀取面板.SetActive(true);
  723. 讀取面板.SetActive(true);
  724. for (int i = 0; i < 清單1.Count; i++)
  725. {
  726. yield return StartCoroutine(盤營盤損明細表複點修改(i));
  727. }
  728. 讀取面板.SetActive(false);
  729. yield return StartCoroutine(庫存盤點申請明細表讀取1());
  730. 讀取面板.SetActive(false);
  731. }
  732. IEnumerator 盤營盤損明細表複點修改(int i)
  733. {
  734. string strcon = "盤營盤損明細表複點修改";
  735. string se = Main.Global.預設伺服器路徑;
  736. string pa1 = 清單1[i][0];
  737. string pa2 = 清單1[i][12];
  738. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}"
  739. , strcon, se, pa1, pa2);
  740. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  741. Debug.Log(strUrl);
  742. yield return request.SendWebRequest();
  743. if (request.result == UnityWebRequest.Result.ConnectionError)
  744. {
  745. Debug.Log(request.error);
  746. yield break;
  747. }
  748. }
  749. public IEnumerator 明細表儲存()
  750. {
  751. 讀取面板.SetActive(true);
  752. for (int i = 0; i < 清單.Count; i++)
  753. {
  754. int 庫存 = 清單[i][6];
  755. int 盤點 = 清單[i][7];
  756. int 總和 = 盤點-庫存;
  757. if (總和 > 0)
  758. {
  759. 清單[i][8]=總和.ToString();
  760. 清單[i][9]="0";
  761. }
  762. else
  763. {
  764. 清單[i][8]="0";
  765. 清單[i][9]=(-總和).ToString();
  766. }
  767. yield return StartCoroutine(盤點申請明細表儲存(i));
  768. }
  769. if (ttt==true)
  770. {
  771. ttt=false;
  772. yield return StartCoroutine(庫存盤點申請明細表刪除());
  773. }
  774. else
  775. {
  776. if (ttt1==true)
  777. {
  778. yield return StartCoroutine(庫存盤點申請明細表讀取());
  779. }
  780. else
  781. {
  782. yield return StartCoroutine(庫存盤點申請明細表讀取());
  783. }
  784. }
  785. }
  786. IEnumerator 盤點申請明細表儲存(int i)
  787. {
  788. string strcon = "盤點申請明細表儲存";
  789. string se = Main.Global.預設伺服器路徑;
  790. string pa1 = 清單[i][0];
  791. string pa2 = 清單[i][2];
  792. string pa3 = 清單[i][7];
  793. string pa4 = 清單[i][8];
  794. string pa5 = 清單[i][9];
  795. string pa6 = 清單[i][10];
  796. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}&PA5={6}&PA6={7}"
  797. , strcon, se, pa1, pa2, pa3, pa4, pa5, pa6);
  798. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  799. yield return request.SendWebRequest();
  800. if (request.result == UnityWebRequest.Result.ConnectionError)
  801. {
  802. Debug.Log(request.error);
  803. yield break;
  804. }
  805. }
  806. public void 關鍵字搜索()
  807. {
  808. if (模式 == "複點")
  809. {
  810. StartCoroutine(明細表複點());
  811. }
  812. else
  813. {
  814. StartCoroutine(明細表儲存());
  815. }
  816. }
  817. public void 儲存()
  818. {
  819. if (清單.Count > 0)
  820. {
  821. 彈跳面板.SetActive(true);
  822. 彈跳文字.text = "儲存成功";
  823. StartCoroutine(明細表儲存());
  824. }
  825. }
  826. public void 最終確認()
  827. {
  828. if (清單.Count > 0)
  829. {
  830. if (關鍵字.text == "")
  831. {
  832. 彈跳面板.SetActive(true);
  833. 彈跳文字.text = "最終確認,確認後將會離開此頁面";
  834. 彈跳是.gameObject.SetActive(true);
  835. 彈跳否.gameObject.SetActive(true);
  836. }
  837. else
  838. {
  839. 彈跳面板.SetActive(true);
  840. 彈跳文字.text = "刪除關鍵字,才能最終確認";
  841. 關鍵字.text="";
  842. 關鍵字搜索();
  843. }
  844. }
  845. 彈跳是.onClick.AddListener(() =>
  846. {
  847. ttt1 = true;
  848. 讀取面板.SetActive(true);
  849. 彈跳是.gameObject.SetActive(false);
  850. 彈跳否.gameObject.SetActive(false);
  851. StartCoroutine(明細表儲存());
  852. });
  853. 彈跳否.onClick.AddListener(() =>
  854. {
  855. 彈跳面板關閉();
  856. });
  857. }
  858. public IEnumerator 最後儲存()
  859. {
  860. 讀取面板.SetActive(true);
  861. for (int i = 0; i < 清單.Count; i++)
  862. {
  863. if (清單[i][2] != "")
  864. {
  865. yield return StartCoroutine(盤營盤損明細表排程流水號修改(i));
  866. }
  867. }
  868. for (int i = 0; i < 清單.Count; i++)
  869. {
  870. int 庫存 = 清單[i][6];
  871. int 盤點 = 清單[i][7];
  872. int 總和 = 盤點-庫存;
  873. if (總和 > 0)
  874. {
  875. 清單[i][8]=總和.ToString();
  876. 清單[i][9]="0";
  877. yield return StartCoroutine(盤營盤損排程流水號最後一比(總和, i));
  878. }
  879. else if (總和 < 0)
  880. {
  881. 清單[i][8]="0";
  882. 清單[i][9]=(-總和).ToString();
  883. yield return StartCoroutine(盤營盤損排程流水號最後一比(總和, i));
  884. }
  885. }
  886. 讀取面板.SetActive(false);
  887. 彈跳面板叉叉.SetActive(false);
  888. 彈跳文字.text = "即將離開";
  889. yield return StartCoroutine(盤營盤損控制表狀況修改());
  890. yield return new WaitForSeconds(1f);
  891. change_Secen(1);
  892. }
  893. IEnumerator 盤營盤損控制表狀況修改()
  894. {
  895. string pa1 = 單號.text;
  896. string pa2 = "盤點完畢";
  897. string strcon = "盤營盤損控制表狀況修改";
  898. string se = Main.Global.預設伺服器路徑;
  899. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}", strcon, se,pa1,pa2);
  900. Debug.Log(strUrl);
  901. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  902. yield return request.SendWebRequest();
  903. if (request.result == UnityWebRequest.Result.ConnectionError)
  904. {
  905. Debug.Log(request.error);
  906. yield break;
  907. }
  908. }
  909. IEnumerator 盤營盤損排程流水號最後一比(int 總和, int i)
  910. {
  911. 讀取面板.SetActive(true);
  912. string strcon = "盤營盤損排程流水號最後一比";
  913. string se = Main.Global.預設伺服器路徑;
  914. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
  915. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  916. yield return request.SendWebRequest();
  917. if (request.result == UnityWebRequest.Result.ConnectionError)
  918. {
  919. Debug.Log(request.error);
  920. yield break;
  921. }
  922. string str = request.downloadHandler.text.ToString();
  923. string 流水 = "";
  924. if (str == "n")
  925. {
  926. 流水="PS00000000";
  927. }
  928. else
  929. {
  930. int NUM1 = int.Parse(str.Substring(2)) + 1;
  931. 流水 = "PS" + NUM1.ToString().PadLeft(8, '0');
  932. }
  933. yield return StartCoroutine(盤點申請排程明細表新增(流水, 總和,i));
  934. }
  935. IEnumerator 盤點申請排程明細表新增(string 流水 , int 總和, int i)
  936. {
  937. string strcon = "盤點申請排程明細表新增";
  938. string se = Main.Global.預設伺服器路徑;
  939. string pa1 = 流水;
  940. string pa2 = 清單[i][5];
  941. string pa3 = "";
  942. string pa4 = "";
  943. string pa5 = "";
  944. string pa6 = "";
  945. string pa8 = "";
  946. string pa7 = 人員s.text;
  947. string pa9 = 清單[i][4];
  948. if (總和 > 0)
  949. {
  950. pa3 = 總和.ToString();
  951. pa4 = "0";
  952. pa5 = 日期.text;
  953. pa8 = "盤盈待核";
  954. }
  955. else
  956. {
  957. pa3 = "0";
  958. pa4 = (-總和).ToString();
  959. pa6 = 日期.text;
  960. pa8 = "盤損待核";
  961. }
  962. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}&PA5={6}&PA6={7}&PA7={8}&PA8={9}&PA9={10}"
  963. , strcon, se, pa1, pa2, pa3, pa4, pa5, pa6, pa7, pa8, pa9);
  964. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  965. yield return request.SendWebRequest();
  966. if (request.result == UnityWebRequest.Result.ConnectionError)
  967. {
  968. Debug.Log(request.error);
  969. yield break;
  970. }
  971. 清單[i][2] = 流水;
  972. yield return StartCoroutine(盤點申請明細表儲存(i));
  973. }
  974. IEnumerator 盤營盤損排程流水號刪除(int i)
  975. {
  976. string strcon = "盤營盤損排程流水號刪除";
  977. string se = Main.Global.預設伺服器路徑;
  978. string pa = 清單[i][2];
  979. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}", strcon, se, pa);
  980. Debug.Log(strUrl);
  981. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  982. yield return request.SendWebRequest();
  983. if (request.result == UnityWebRequest.Result.ConnectionError)
  984. {
  985. Debug.Log(request.error);
  986. yield break;
  987. }
  988. if (ddd != "")
  989. {
  990. yield return StartCoroutine(庫存盤點申請明細表讀取());
  991. ddd="";
  992. 彈跳面板關閉();
  993. }
  994. else
  995. {
  996. 清單[i][2]="";
  997. }
  998. }
  999. IEnumerator 盤營盤損明細表排程流水號修改(int i)
  1000. {
  1001. string strcon = "盤營盤損明細表排程流水號修改";
  1002. string se = Main.Global.預設伺服器路徑;
  1003. string pa = 清單[i][0];
  1004. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}", strcon, se, pa);
  1005. Debug.Log(strUrl);
  1006. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  1007. yield return request.SendWebRequest();
  1008. if (request.result == UnityWebRequest.Result.ConnectionError)
  1009. {
  1010. Debug.Log(request.error);
  1011. yield break;
  1012. }
  1013. yield return StartCoroutine(盤營盤損排程流水號刪除(i));
  1014. }
  1015. public void 彈跳面板關閉()
  1016. {
  1017. 彈跳面板.SetActive(false);
  1018. 彈跳文字.text = "";
  1019. 彈跳是.gameObject.SetActive(false);
  1020. 彈跳否.gameObject.SetActive(false);
  1021. 彈跳面板的按鈕.SetActive(false);
  1022. 彈跳是.onClick.RemoveAllListeners();
  1023. 彈跳否.onClick.RemoveAllListeners();
  1024. }
  1025. public void 上一頁0()
  1026. {
  1027. 初始畫面.SetActive(false);
  1028. 選擇畫面.SetActive(true);
  1029. }
  1030. public void 上一頁()
  1031. {
  1032. 選擇2.SetActive(false);
  1033. 選擇1.SetActive(true);
  1034. }
  1035. public void 上一頁1()
  1036. {
  1037. 選擇3.SetActive(false);
  1038. 選擇2.SetActive(true);
  1039. }
  1040. public void 上一頁2()
  1041. {
  1042. if (模式 == "複點")
  1043. {
  1044. if (清單 != null)
  1045. {
  1046. StartCoroutine(明細表儲存());
  1047. }
  1048. }
  1049. else
  1050. {
  1051. if (清單1 != null)
  1052. {
  1053. StartCoroutine(明細表複點());
  1054. }
  1055. }
  1056. 主畫面.SetActive(false);
  1057. 查找紐.SetActive(false);
  1058. 初始畫面.SetActive(true);
  1059. }
  1060. public void back()
  1061. {
  1062. change_Secen(1);
  1063. }
  1064. public void 查找按鈕()
  1065. {
  1066. 彈跳面板關閉();
  1067. if (選擇.activeSelf)
  1068. {
  1069. StartCoroutine(庫存盤點申請明細表讀取());
  1070. }
  1071. else
  1072. {
  1073. if (清單.Count > 0)
  1074. {
  1075. StartCoroutine(明細表儲存());
  1076. }
  1077. }
  1078. 選擇.SetActive(!選擇.activeSelf);
  1079. 主畫面.SetActive(!主畫面.activeSelf);
  1080. }
  1081. public void change_Secen(int _screenNum)
  1082. {
  1083. SceneManager.LoadScene(_screenNum);
  1084. }
  1085. public void DeletetextCopies1()
  1086. {
  1087. // 刪除複製出來的物件
  1088. foreach (GameObject copy in copy1)
  1089. {
  1090. Destroy(copy);
  1091. }
  1092. copy1.Clear();
  1093. }
  1094. public void DeletetextCopies2()
  1095. {
  1096. // 刪除複製出來的物件
  1097. foreach (GameObject copy in copy2)
  1098. {
  1099. Destroy(copy);
  1100. }
  1101. copy2.Clear();
  1102. }
  1103. public void DeletetextCopies3()
  1104. {
  1105. // 刪除複製出來的物件
  1106. foreach (GameObject copy in copy3)
  1107. {
  1108. Destroy(copy);
  1109. }
  1110. copy3.Clear();
  1111. }
  1112. public void DeletetextCopies4()
  1113. {
  1114. // 刪除複製出來的物件
  1115. foreach (GameObject copy in copy4)
  1116. {
  1117. Destroy(copy);
  1118. }
  1119. copy4.Clear();
  1120. }
  1121. public void DeletetextCopies5()
  1122. {
  1123. // 刪除複製出來的物件
  1124. foreach (GameObject copy in copy5)
  1125. {
  1126. Destroy(copy);
  1127. }
  1128. copy5.Clear();
  1129. }
  1130. }