1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
- using UnityEngine.Networking;
- using System.Text.RegularExpressions;
- using System.Data.SqlClient;
- using TMPro;
- using System;
- using System.IO;
- using ZXing;
- using ZXing.QrCode;
- using System.Net;
- using SimpleJSON;
- using System.ComponentModel;
- using System.Runtime.InteropServices;
-
- public class 盤營盤損申請 : MonoBehaviour
- {
- [SerializeField] GameObject 盤點頁;
- [SerializeField] GameObject 複點頁;
-
- [SerializeField] GameObject 儲存1;
- [SerializeField] GameObject 儲存2;
- [SerializeField] GameObject 選擇畫面;
- [SerializeField] GameObject 選擇單號;
- [SerializeField] GameObject 查找紐;
- [SerializeField] GameObject 選擇;
- [SerializeField] GameObject 選擇1;
- [SerializeField] GameObject 選擇2;
- [SerializeField] GameObject 選擇3;
- [SerializeField] GameObject 初始畫面;
- [SerializeField] GameObject 主畫面;
- [SerializeField] TextMeshProUGUI 單號;
- [SerializeField] TextMeshProUGUI 日期;
- [SerializeField] TextMeshProUGUI 人員s;
- public TMP_Dropdown 盤點類型;
- [SerializeField] TMP_InputField 備註;
- [SerializeField] TMP_InputField 關鍵字;
- public CanvasScaler canvasScaler;
- float screenWidth;
- float screenHeight;
-
- [SerializeField] GameObject 彈跳面板叉叉;
- [SerializeField] GameObject 彈跳面板;
- [SerializeField] GameObject 彈跳面板的按鈕;
- [SerializeField] TextMeshProUGUI 彈跳文字;
- [SerializeField] Button 彈跳是;
- [SerializeField] Button 彈跳否;
-
- [SerializeField] GameObject 讀取面板;
- [SerializeField] TextMeshProUGUI 讀取;
-
- JSONNode 清單;
- JSONNode 清單1;
- public GameObject buttonPrefab;
- public Transform buttonParent;
- public GameObject buttonceneter;
- private List<GameObject> copy = new List<GameObject>();
-
- public GameObject buttonPrefab1;
- public Transform buttonParent1;
- public GameObject buttonceneter1;
- private List<GameObject> copy1 = new List<GameObject>();
-
- public GameObject buttonPrefab2;
- public Transform buttonParent2;
- public GameObject buttonceneter2;
- private List<GameObject> copy2 = new List<GameObject>();
-
- public GameObject buttonPrefab3;
- public Transform buttonParent3;
- public GameObject buttonceneter3;
- private List<GameObject> copy3 = new List<GameObject>();
-
- public GameObject buttonPrefab4;
- public Transform buttonParent4;
- public GameObject buttonceneter4;
- private List<GameObject> copy4 = new List<GameObject>();
-
- public GameObject buttonPrefab5;
- public Transform buttonParent5;
- public GameObject buttonceneter5;
- private List<GameObject> copy5 = new List<GameObject>();
-
- private string loadingText = "";
- private int dotCount = 0;
- bool ttt = false;
- string ddd;
- bool ttt1 = false;
- string 模式 = "";
- // Start is called before the first frame update
- void Start()
- {
- Screen.autorotateToPortrait = false;
- Screen.orientation = ScreenOrientation.Portrait;
- float rate = 900.0f / 1900.0f;
- if (Main.Global.rate>rate)
- {
- canvasScaler.matchWidthOrHeight = 1f;
- }
- else
- {
- canvasScaler.matchWidthOrHeight = 0f;
- }
- //Main.Global.阿帕契路徑="http://106.1.48.106:8080/wp-content/themes/event-star/shto_main.php?";
- //Main.Global.預設伺服器路徑="official";
- //Main.Global.人員="李卓叡";
- StartCoroutine(AnimateText());
-
- StartCoroutine(群組碼清單());
- 查找紐.SetActive(false);
- 選擇.SetActive(false);
- 選擇1.SetActive(true);
- 選擇2.SetActive(false);
- 選擇3.SetActive(false);
- 初始畫面.SetActive(false);
- 主畫面.SetActive(false);
- 選擇單號.SetActive(false);
- 選擇畫面.SetActive(true);
- }
- IEnumerator AnimateText()
- {
- string qqq = 讀取.text.ToString();
- while (true)
- {
- yield return new WaitForSeconds(0.5f);
-
- if (dotCount < 3)
- {
- loadingText += ".";
- dotCount++;
- }
- else
- {
- loadingText = "";
- dotCount = 0;
- }
-
- 讀取.text = qqq+loadingText;
- }
- }
- IEnumerator 盤營盤損歷表()
- {
- 讀取面板.SetActive(true);
- if (copy4 != null)
- {
- DeletetextCopies4();
- }
- string strcon = "";
- if (模式 == "續點")
- {
- strcon = "盤營盤損歷表本";
- }
- else
- {
- strcon = "盤營盤損歷表非本";
- }
- string pa = Main.Global.人員;
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}", strcon, se,pa);
-
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- JSONNode json = JSON.Parse(request.downloadHandler.text);
- int sum = 2;
- for (int i = 0; i < json.Count; i++)
- {
- GameObject buttonObj = Instantiate(buttonPrefab4) as GameObject;
- buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
- buttonObj.transform.SetParent(buttonParent4, false);
- TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
- Button bt = buttonObj.GetComponentInChildren<Button>();
- int index = i;
- bt.onClick.AddListener(() =>
- {
- 初始畫面.SetActive(true);
- 選擇畫面.SetActive(false);
- 選擇單號.SetActive(false);
- 單號.text=json[index][0].ToString().Trim('"');
- 日期.text=json[index][3].ToString().Trim('"');
- 備註.text=json[index][5].ToString().Trim('"');
- 人員s.text=json[index][2].ToString().Trim('"');
- int index2 = 盤點類型.options.FindIndex(option => option.text == json[index][4].ToString().Trim('"'));
- 盤點類型.value = index2;
- });
- text[0].text = json[i][0].ToString().Trim('"');
- text[1].text = json[i][3].ToString().Trim('"');
- sum+=100;
- copy4.Add(buttonObj);
- }
- buttonceneter4.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter4.GetComponent<RectTransform>().sizeDelta.x, sum);
- 讀取面板.SetActive(false);
- }
- IEnumerator 群組碼清單()
- {
- string strcon = "群組碼清單";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- JSONNode json = JSON.Parse(request.downloadHandler.text);
- Debug.Log(json);
- int sum = 2;
- for (int i = 0; i < json.Count; i++)
- {
- GameObject buttonObj = Instantiate(buttonPrefab) as GameObject;
- buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
- buttonObj.transform.SetParent(buttonParent, false);
- TextMeshProUGUI text = buttonObj.GetComponentInChildren<TextMeshProUGUI>();
- Button bt = buttonObj.GetComponentInChildren<Button>();
- int index = i;
- bt.onClick.AddListener(() =>
- {
- string str = json[index].ToString().Trim('"');
- StartCoroutine(物料清單(str));
- 選擇1.SetActive(false);
- 選擇2.SetActive(true);
- });
- text.text = json[i].ToString().Trim('"');
- sum+=200;
- copy.Add(buttonObj);
- }
- buttonceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter.GetComponent<RectTransform>().sizeDelta.x, sum);
-
- yield return StartCoroutine(起始刪除());
- }
- IEnumerator 物料清單(string pa)
- {
- if (copy1 != null)
- {
- DeletetextCopies1();
- }
- string strcon = "物料清單";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}", strcon, se, pa );
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- JSONNode json = JSON.Parse(request.downloadHandler.text);
- int sum = 2;
- for (int i = 0; i < json.Count; i++)
- {
- GameObject buttonObj = Instantiate(buttonPrefab1) as GameObject;
- buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
- buttonObj.transform.SetParent(buttonParent1, false);
- TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
- Button bt = buttonObj.GetComponentInChildren<Button>();
- int index = i;
- bt.onClick.AddListener(() =>
- {
- string str = json[index][0].ToString().Trim('"');
- string str1 = json[index][1].ToString().Trim('"');
- StartCoroutine(物料明細清單(str,str1));
- 選擇2.SetActive(false);
- 選擇3.SetActive(true);
- });
- text[0].text = (i+1).ToString();
- text[1].text = json[i][2].ToString().Trim('"');
- sum+=100;
- copy1.Add(buttonObj);
- }
- buttonceneter1.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter1.GetComponent<RectTransform>().sizeDelta.x, sum);
-
- }
- IEnumerator 物料明細清單(string pa, string pa1)
- {
- if (copy2 != null)
- {
- DeletetextCopies2();
- }
- string strcon = "物料明細清單";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}", strcon, se, pa, pa1);
- Debug.Log(strUrl);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- JSONNode json = JSON.Parse(request.downloadHandler.text);
- Debug.Log(json);
- int sum = 2;
- int j = 1;
- for (int i = 0; i < json.Count; i++)
- {
- if (json[i][9].ToString().Trim('"') != "是")
- {
- GameObject buttonObj = Instantiate(buttonPrefab2) as GameObject;
- buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
- buttonObj.transform.SetParent(buttonParent2, false);
- TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
- Button bt = buttonObj.GetComponentInChildren<Button>();
- int index = i;
- bt.onClick.AddListener(() =>
- {
- 讀取面板.SetActive(true);
- string str = json[index][2].ToString().Trim('"');
- string str1 = json[index][5].ToString().Trim('"');
- StartCoroutine(選定物料庫存量讀取(str,str1));
-
- });
- text[0].text = j.ToString();
- text[1].text = json[i][5].ToString().Trim('"');
- text[2].text = json[i][6].ToString().Trim('"');
- j+=1;
- sum+=150;
- copy2.Add(buttonObj);
- }
- }
- buttonceneter2.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter2.GetComponent<RectTransform>().sizeDelta.x, sum);
-
- }
-
- IEnumerator 選定物料庫存量讀取(string 料號,string 品名)
- {
- string strcon = "選定物料庫存量讀取";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}", strcon, se, 料號);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- string str = request.downloadHandler.text.ToString();
- string 庫存 = "";
- if (str == "n")
- {
- 庫存="0";
- }
- else
- {
- 庫存 = str;
- }
- Debug.Log(庫存);
- yield return StartCoroutine(物料明細讀取(料號, 品名, 庫存));
- }
- IEnumerator 物料明細讀取(string 料號, string 品名, string 庫存)
- {
-
- string pa = 單號.text;
- string strcon = "物料明細讀取";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}", strcon, se, pa, 料號);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- string str = request.downloadHandler.text.ToString();
- if (str == "n")
- {
- Debug.Log("t");
- yield return StartCoroutine(盤營盤損明細流水號最後一比(料號, 品名, 庫存));
- }
- else
- {
- 讀取面板.SetActive(false);
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "此單已有此料號";
- }
-
- }
- IEnumerator 盤營盤損明細流水號最後一比(string 料號, string 品名, string 庫存)
- {
- string strcon = "盤營盤損明細流水號最後一比";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- string str = request.downloadHandler.text.ToString();
- string 流水 = "";
- if (str == "n")
- {
- 流水="ID00000000";
- }
- else
- {
- int NUM1 = int.Parse(str.Substring(2)) + 1;
- 流水 = "ID" + NUM1.ToString().PadLeft(8, '0');
- }
- yield return StartCoroutine(盤點申請明細表新增(流水, 品名, 料號, 庫存));
- }
- IEnumerator 盤點申請明細表新增(string 流水 ,string 品名 , string 料號 , string 庫存)
- {
- string strcon = "盤點申請明細表新增";
- string se = Main.Global.預設伺服器路徑;
- string pa1 = 單號.text;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}&PA5={6}"
- , strcon, se, 流水, pa1, 品名, 料號, 庫存);
- Debug.Log(strUrl);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- 讀取面板.SetActive(false);
- 彈跳面板.SetActive(true);
- 彈跳文字.text="新增物料成功";
- 彈跳面板的按鈕.SetActive(true);
- }
-
- IEnumerator 起始刪除()
- {
- string strcon = "起始刪除";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
-
- }
- public void 儲存單號()
- {
- 初始畫面.SetActive(false);
- 主畫面.SetActive(true);
- 讀取面板.SetActive(true);
- if (模式 == "複點")
- {
- 查找紐.SetActive(false);
- 盤點頁.SetActive(false);
- 複點頁.SetActive(true);
- StartCoroutine(庫存盤點申請明細表讀取1());
- }
- else
- {
- 查找紐.SetActive(true);
- 盤點頁.SetActive(true);
- 複點頁.SetActive(false);
- StartCoroutine(盤點申請控制表修改());
- }
-
- }
-
- public void 新增()
- {
- 模式 = "新增";
- 初始畫面.SetActive(true);
- 選擇畫面.SetActive(false);
- 人員s.text=Main.Global.人員;
- DateTime currentDate = DateTime.Now;
- 日期.text = currentDate.ToString("yyyy/MM/dd");
- StartCoroutine(盤營盤損流水號最後一比());
- }
- public void 續點()
- {
- 模式 = "續點";
- 選擇單號.SetActive(true);
- StartCoroutine(盤營盤損歷表());
- }
- public void 複點()
- {
- 模式 = "複點";
- 選擇單號.SetActive(true);
- StartCoroutine(盤營盤損歷表());
- }
- public void 關()
- {
- 模式 = "";
- 選擇單號.SetActive(false);
- }
-
-
-
- IEnumerator 盤營盤損流水號最後一比()
- {
- 讀取面板.SetActive(true);
- string strcon = "盤營盤損流水號最後一比";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- string str = request.downloadHandler.text.ToString();
- if (str == "n")
- {
- 單號.text="IN00000000";
- }
- else
- {
- int NUM1 = int.Parse(str.Substring(2)) + 1;
- 單號.text = "IN" + NUM1.ToString().PadLeft(8, '0');
- }
- yield return StartCoroutine(盤點申請控制表新增());
- }
- IEnumerator 盤點申請控制表新增()
- {
-
- string strcon = "盤點申請控制表新增";
- string se = Main.Global.預設伺服器路徑;
- string pa1 = 單號.text;
- string pa2 = 人員s.text;
- string pa3 = 日期.text;
- string pa4 = 盤點類型.options[盤點類型.value].text;
- string pa5 = 備註.text;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}&PA5={6}"
- , strcon, se, pa1, pa2, pa3, pa4, pa5);
- Debug.Log(strUrl);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- 讀取面板.SetActive(false);
- 彈跳面板.SetActive(true);
- 彈跳文字.text="新增單號成功";
-
- }
- IEnumerator 盤點申請控制表修改()
- {
- string strcon = "盤點申請控制表修改";
- string se = Main.Global.預設伺服器路徑;
- string pa1 = 單號.text;
- string pa2 = 人員s.text;
- string pa3 = 日期.text;
- string pa4 = 盤點類型.options[盤點類型.value].text;
- string pa5 = 備註.text;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}&PA5={6}"
- , strcon, se, pa1, pa2, pa3, pa4, pa5);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
-
- yield return StartCoroutine(庫存盤點申請明細表讀取());
- }
-
- IEnumerator 庫存盤點申請明細表讀取()
- {
- 讀取面板.SetActive(true);
- if (copy3 != null)
- {
- DeletetextCopies3();
- }
- string pa = 單號.text;
- string pa1 = 關鍵字.text;
- string strcon = "庫存盤點申請明細表讀取";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}", strcon, se, pa, pa1);
- Debug.Log(strUrl);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- 清單 = JSON.Parse(request.downloadHandler.text);
-
- int sum = 2;
- for (int i = 0; i < 清單.Count; i++)
- {
- GameObject buttonObj = Instantiate(buttonPrefab3) as GameObject;
- buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
- buttonObj.transform.SetParent(buttonParent3, false);
- TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
- TMP_InputField texti = buttonObj.GetComponentInChildren<TMP_InputField>();
- Button[] bt = buttonObj.GetComponentsInChildren<Button>();
- Image[] im = buttonObj.GetComponentsInChildren<Image>();
- int index = i;
-
- bt[0].onClick.AddListener(() =>
- {
- if (清單[index][10]==1)
- {
- 清單[index][10]=0;
- im[2].color = new Color32(255, 255, 255, 255);
- }
- else
- {
- 清單[index][10]=1;
- im[2].color = new Color32(160, 255, 160, 255);
- }
- });
-
- bt[1].onClick.AddListener(() =>
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "是否刪除物料";
- 彈跳是.gameObject.SetActive(true);
- 彈跳否.gameObject.SetActive(true);
- 彈跳是.onClick.AddListener(() =>
- {
- ttt = true;
- ddd = 清單[index][0].ToString().Trim('"');
- StartCoroutine(明細表儲存());
- });
- 彈跳否.onClick.AddListener(() =>
- {
-
- 彈跳面板關閉();
- });
- });
-
- text[0].text = (i+1).ToString();
- text[1].text = 清單[i][4].ToString().Trim('"');
- text[2].text = 清單[i][6].ToString().Trim('"');
- texti.text = 清單[i][7].ToString().Trim('"');
- if(清單[i][10]==1)
- {
- im[2].color = new Color32(160, 255, 160, 255);
- }
-
- texti.onValueChanged.AddListener((string newText) =>
- {
- if (int.TryParse(newText, out int currentValue))
- {
- if (currentValue< 0)
- {
- texti.text = "0";
- }
- else
- {
- 清單[index][7]=newText;
-
- Debug.Log(清單);
- }
- }
-
- });
- sum+=100;
- copy3.Add(buttonObj);
- }
- buttonceneter3.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter3.GetComponent<RectTransform>().sizeDelta.x, sum);
- 讀取面板.SetActive(false);
- if (ttt1==true)
- {
- yield return StartCoroutine(最後儲存());
- }
- }
- IEnumerator 庫存盤點申請明細表讀取1()
- {
- 讀取面板.SetActive(true);
- if (copy5 != null)
- {
- DeletetextCopies5();
- }
- string pa = 單號.text;
- string pa1 = 關鍵字.text;
- string strcon = "庫存盤點申請明細表讀取1";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}", strcon, se, pa, pa1);
- Debug.Log(strUrl);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- 清單1 = JSON.Parse(request.downloadHandler.text);
- Debug.Log(清單1);
- int sum = 2;
- for (int i = 0; i < 清單1.Count; i++)
- {
- GameObject buttonObj = Instantiate(buttonPrefab5) as GameObject;
- buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
- buttonObj.transform.SetParent(buttonParent5, false);
- TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
- Toggle tg = buttonObj.GetComponentInChildren<Toggle>();
- Button bt = buttonObj.GetComponentInChildren<Button>();
- int index = i;
- bt.onClick.AddListener(() =>
- {
- if (tg.isOn)
- {
- tg.isOn = false;
- 清單1[index][12] = 0;
-
- }
- else
- {
- tg.isOn = true;
- 清單1[index][12] = 1;
- }
- Debug.Log(清單1);
- });
- text[0].text = (i+1).ToString();
- text[1].text = 清單1[i][4].ToString().Trim('"');
- text[2].text = 清單1[i][6].ToString().Trim('"');
- text[3].text = 清單1[i][7].ToString().Trim('"');
- if (清單1[i][12] == 1)
- {
- tg.isOn = true;
- }
- sum+=100;
- copy5.Add(buttonObj);
- }
- buttonceneter5.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter5.GetComponent<RectTransform>().sizeDelta.x, sum);
- 讀取面板.SetActive(false);
- }
- IEnumerator 庫存盤點申請明細表刪除()
- {
- string strcon = "庫存盤點申請明細表刪除";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}", strcon, se, ddd);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- int index = 0;
- for (int i = 0; i < 清單.Count; i++)
- {
- if (清單[i][0]== ddd)
- {
- index = i;
- break;
- }
- }
- yield return StartCoroutine(盤營盤損排程流水號刪除(index));
-
- }
-
- public void 複點存檔()
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "複點儲存成功";
- StartCoroutine(明細表複點());
- }
-
- public IEnumerator 明細表複點()
- {
- 讀取面板.SetActive(true);
- 讀取面板.SetActive(true);
- for (int i = 0; i < 清單1.Count; i++)
- {
- yield return StartCoroutine(盤營盤損明細表複點修改(i));
- }
- 讀取面板.SetActive(false);
- yield return StartCoroutine(庫存盤點申請明細表讀取1());
- 讀取面板.SetActive(false);
- }
- IEnumerator 盤營盤損明細表複點修改(int i)
- {
- string strcon = "盤營盤損明細表複點修改";
- string se = Main.Global.預設伺服器路徑;
- string pa1 = 清單1[i][0];
- string pa2 = 清單1[i][12];
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}"
- , strcon, se, pa1, pa2);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- Debug.Log(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- }
- public IEnumerator 明細表儲存()
- {
- 讀取面板.SetActive(true);
- for (int i = 0; i < 清單.Count; i++)
- {
- int 庫存 = 清單[i][6];
- int 盤點 = 清單[i][7];
- int 總和 = 盤點-庫存;
- if (總和 > 0)
- {
- 清單[i][8]=總和.ToString();
- 清單[i][9]="0";
- }
- else
- {
- 清單[i][8]="0";
- 清單[i][9]=(-總和).ToString();
- }
- yield return StartCoroutine(盤點申請明細表儲存(i));
- }
- if (ttt==true)
- {
- ttt=false;
- yield return StartCoroutine(庫存盤點申請明細表刪除());
-
- }
- else
- {
- if (ttt1==true)
- {
- yield return StartCoroutine(庫存盤點申請明細表讀取());
- }
- else
- {
- yield return StartCoroutine(庫存盤點申請明細表讀取());
- }
-
- }
-
- }
- IEnumerator 盤點申請明細表儲存(int i)
- {
- string strcon = "盤點申請明細表儲存";
- string se = Main.Global.預設伺服器路徑;
- string pa1 = 清單[i][0];
- string pa2 = 清單[i][2];
- string pa3 = 清單[i][7];
- string pa4 = 清單[i][8];
- string pa5 = 清單[i][9];
- string pa6 = 清單[i][10];
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}&PA5={6}&PA6={7}"
- , strcon, se, pa1, pa2, pa3, pa4, pa5, pa6);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
-
- }
-
- public void 關鍵字搜索()
- {
- if (模式 == "複點")
- {
- StartCoroutine(明細表複點());
- }
- else
- {
- StartCoroutine(明細表儲存());
- }
-
- }
- public void 儲存()
- {
- if (清單.Count > 0)
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "儲存成功";
- StartCoroutine(明細表儲存());
- }
-
- }
- public void 最終確認()
- {
-
- if (清單.Count > 0)
- {
- if (關鍵字.text == "")
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "最終確認,確認後將會離開此頁面";
- 彈跳是.gameObject.SetActive(true);
- 彈跳否.gameObject.SetActive(true);
- }
- else
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "刪除關鍵字,才能最終確認";
- 關鍵字.text="";
- 關鍵字搜索();
- }
-
- }
- 彈跳是.onClick.AddListener(() =>
- {
- ttt1 = true;
- 讀取面板.SetActive(true);
- 彈跳是.gameObject.SetActive(false);
- 彈跳否.gameObject.SetActive(false);
-
- StartCoroutine(明細表儲存());
- });
- 彈跳否.onClick.AddListener(() =>
- {
- 彈跳面板關閉();
- });
-
- }
- public IEnumerator 最後儲存()
- {
- 讀取面板.SetActive(true);
- for (int i = 0; i < 清單.Count; i++)
- {
- if (清單[i][2] != "")
- {
- yield return StartCoroutine(盤營盤損明細表排程流水號修改(i));
- }
- }
- for (int i = 0; i < 清單.Count; i++)
- {
- int 庫存 = 清單[i][6];
- int 盤點 = 清單[i][7];
- int 總和 = 盤點-庫存;
- if (總和 > 0)
- {
- 清單[i][8]=總和.ToString();
- 清單[i][9]="0";
- yield return StartCoroutine(盤營盤損排程流水號最後一比(總和, i));
- }
- else if (總和 < 0)
- {
- 清單[i][8]="0";
- 清單[i][9]=(-總和).ToString();
- yield return StartCoroutine(盤營盤損排程流水號最後一比(總和, i));
- }
- }
- 讀取面板.SetActive(false);
- 彈跳面板叉叉.SetActive(false);
- 彈跳文字.text = "即將離開";
- yield return StartCoroutine(盤營盤損控制表狀況修改());
- yield return new WaitForSeconds(1f);
- change_Secen(1);
- }
- IEnumerator 盤營盤損控制表狀況修改()
- {
- string pa1 = 單號.text;
- string pa2 = "盤點完畢";
- string strcon = "盤營盤損控制表狀況修改";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}", strcon, se,pa1,pa2);
- Debug.Log(strUrl);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- }
-
- IEnumerator 盤營盤損排程流水號最後一比(int 總和, int i)
- {
- 讀取面板.SetActive(true);
- string strcon = "盤營盤損排程流水號最後一比";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- string str = request.downloadHandler.text.ToString();
- string 流水 = "";
- if (str == "n")
- {
- 流水="PS00000000";
- }
- else
- {
- int NUM1 = int.Parse(str.Substring(2)) + 1;
- 流水 = "PS" + NUM1.ToString().PadLeft(8, '0');
- }
- yield return StartCoroutine(盤點申請排程明細表新增(流水, 總和,i));
- }
- IEnumerator 盤點申請排程明細表新增(string 流水 , int 總和, int i)
- {
- string strcon = "盤點申請排程明細表新增";
- string se = Main.Global.預設伺服器路徑;
- string pa1 = 流水;
- string pa2 = 清單[i][5];
- string pa3 = "";
- string pa4 = "";
- string pa5 = "";
- string pa6 = "";
- string pa8 = "";
- string pa7 = 人員s.text;
- string pa9 = 清單[i][4];
- if (總和 > 0)
- {
- pa3 = 總和.ToString();
- pa4 = "0";
- pa5 = 日期.text;
- pa8 = "盤盈待核";
- }
- else
- {
- pa3 = "0";
- pa4 = (-總和).ToString();
- pa6 = 日期.text;
- pa8 = "盤損待核";
- }
- 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}"
- , strcon, se, pa1, pa2, pa3, pa4, pa5, pa6, pa7, pa8, pa9);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- 清單[i][2] = 流水;
- yield return StartCoroutine(盤點申請明細表儲存(i));
- }
- IEnumerator 盤營盤損排程流水號刪除(int i)
- {
- string strcon = "盤營盤損排程流水號刪除";
- string se = Main.Global.預設伺服器路徑;
- string pa = 清單[i][2];
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}", strcon, se, pa);
- Debug.Log(strUrl);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- if (ddd != "")
- {
- yield return StartCoroutine(庫存盤點申請明細表讀取());
- ddd="";
- 彈跳面板關閉();
- }
- else
- {
- 清單[i][2]="";
- }
-
-
- }
- IEnumerator 盤營盤損明細表排程流水號修改(int i)
- {
- string strcon = "盤營盤損明細表排程流水號修改";
- string se = Main.Global.預設伺服器路徑;
- string pa = 清單[i][0];
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}", strcon, se, pa);
- Debug.Log(strUrl);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- yield return StartCoroutine(盤營盤損排程流水號刪除(i));
- }
-
- public void 彈跳面板關閉()
- {
-
- 彈跳面板.SetActive(false);
- 彈跳文字.text = "";
- 彈跳是.gameObject.SetActive(false);
- 彈跳否.gameObject.SetActive(false);
- 彈跳面板的按鈕.SetActive(false);
- 彈跳是.onClick.RemoveAllListeners();
- 彈跳否.onClick.RemoveAllListeners();
- }
- public void 上一頁0()
- {
- 初始畫面.SetActive(false);
- 選擇畫面.SetActive(true);
- }
-
- public void 上一頁()
- {
- 選擇2.SetActive(false);
- 選擇1.SetActive(true);
- }
- public void 上一頁1()
- {
- 選擇3.SetActive(false);
- 選擇2.SetActive(true);
- }
- public void 上一頁2()
- {
- if (模式 == "複點")
- {
- if (清單 != null)
- {
- StartCoroutine(明細表儲存());
- }
- }
- else
- {
- if (清單1 != null)
- {
- StartCoroutine(明細表複點());
- }
- }
- 主畫面.SetActive(false);
- 查找紐.SetActive(false);
- 初始畫面.SetActive(true);
- }
- public void back()
- {
- change_Secen(1);
- }
- public void 查找按鈕()
- {
- 彈跳面板關閉();
- if (選擇.activeSelf)
- {
- StartCoroutine(庫存盤點申請明細表讀取());
- }
- else
- {
- if (清單.Count > 0)
- {
- StartCoroutine(明細表儲存());
- }
-
- }
- 選擇.SetActive(!選擇.activeSelf);
- 主畫面.SetActive(!主畫面.activeSelf);
-
- }
- public void change_Secen(int _screenNum)
- {
-
- SceneManager.LoadScene(_screenNum);
- }
- public void DeletetextCopies1()
- {
- // 刪除複製出來的物件
- foreach (GameObject copy in copy1)
- {
- Destroy(copy);
- }
- copy1.Clear();
- }
- public void DeletetextCopies2()
- {
- // 刪除複製出來的物件
- foreach (GameObject copy in copy2)
- {
- Destroy(copy);
- }
- copy2.Clear();
- }
- public void DeletetextCopies3()
- {
- // 刪除複製出來的物件
- foreach (GameObject copy in copy3)
- {
- Destroy(copy);
- }
- copy3.Clear();
- }
- public void DeletetextCopies4()
- {
- // 刪除複製出來的物件
- foreach (GameObject copy in copy4)
- {
- Destroy(copy);
- }
- copy4.Clear();
- }
- public void DeletetextCopies5()
- {
- // 刪除複製出來的物件
- foreach (GameObject copy in copy5)
- {
- Destroy(copy);
- }
- copy5.Clear();
- }
- }
|