123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 |
- 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 主頁;
- [SerializeField] GameObject 明細頁;
- [SerializeField] GameObject 審查按鈕;
-
- [SerializeField] TextMeshProUGUI 單號;
- [SerializeField] TextMeshProUGUI 日期;
- [SerializeField] TextMeshProUGUI 人員;
- [SerializeField] TextMeshProUGUI 類型;
- [SerializeField] TextMeshProUGUI 狀態;
- [SerializeField] TextMeshProUGUI 備註;
- [SerializeField] TMP_InputField 關鍵字;
- public CanvasScaler canvasScaler;
- float screenWidth;
- float screenHeight;
-
- [SerializeField] GameObject 彈跳面板叉叉;
- [SerializeField] GameObject 彈跳面板;
- [SerializeField] TextMeshProUGUI 彈跳文字;
- [SerializeField] Button 彈跳是;
- [SerializeField] Button 彈跳否;
-
- [SerializeField] GameObject 讀取面板;
- [SerializeField] TextMeshProUGUI 讀取;
- 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>();
- private string loadingText = "";
- private int dotCount = 0;
-
- string 模式 = "";
- JSONNode 簽名檔;
- JSONNode 計算;
- // 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());
- 初始頁.SetActive(true);
- 選擇頁.SetActive(false);
- 主頁.SetActive(false);
- 明細頁.SetActive(false);
- 審查按鈕.SetActive(false);
- StartCoroutine(主管簽名檔清單());
- }
- 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;
- }
- 簽名檔 = JSON.Parse(request.downloadHandler.text);
- Debug.Log(簽名檔);
- }
- 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;
- }
- }
- public void 審查()
- {
- if (Main.Global.級別 == "00" && Main.Global.職稱 == "00000.NA")
- {
- 模式 = "審查";
- 選擇頁.SetActive(true);
- StartCoroutine(盤營盤損歷表());
- }
- else if (Main.Global.級別 == "03" && Main.Global.職稱 == "31001.廠務部廠長")
- {
- 模式 = "審查";
- 選擇頁.SetActive(true);
- StartCoroutine(盤營盤損歷表());
- }
- else
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "簽核權限錯誤!!";
- }
-
- }
- public void 未審()
- {
- 模式 = "未審";
- 選擇頁.SetActive(true);
- StartCoroutine(盤營盤損歷表());
- }
- public void 已審()
- {
- 模式 = "已審";
- 選擇頁.SetActive(true);
- StartCoroutine(盤營盤損歷表());
- }
- public void 關()
- {
- 模式 = "";
- 選擇頁.SetActive(false);
- }
- IEnumerator 盤營盤損歷表()
- {
- 讀取面板.SetActive(true);
- if (copy != null)
- {
- DeletetextCopies();
- }
- string strcon = "";
- if (模式 == "已審")
- {
- strcon = "盤營盤損已審";
- }
- else if(模式 == "未審")
- {
- strcon = "盤營盤損未審";
- }
- else
- {
- 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);
- 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.GetComponentsInChildren<TextMeshProUGUI>();
- Button bt = buttonObj.GetComponentInChildren<Button>();
- int index = i;
- bt.onClick.AddListener(() =>
- {
- 初始頁.SetActive(false);
- 選擇頁.SetActive(false);
- 主頁.SetActive(true);
- 單號.text=json[index][0].ToString().Trim('"');
- 日期.text=json[index][3].ToString().Trim('"');
- 備註.text=json[index][5].ToString().Trim('"');
- 人員.text=json[index][2].ToString().Trim('"');
- 類型.text=json[index][4].ToString().Trim('"');
- Debug.Log(json[index][8]);
- if(json[index][8] == null || json[index][8].ToString().Trim('"')=="")
- {
- 狀態.text="盤點未完成";
- }
- else
- {
- 狀態.text=json[index][8].ToString().Trim('"');
- }
-
- StartCoroutine(庫存盤點申請明細表讀取());
- });
- text[0].text = json[i][0].ToString().Trim('"');
- text[1].text = json[i][3].ToString().Trim('"');
- sum+=100;
- copy.Add(buttonObj);
- }
- buttonceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter.GetComponent<RectTransform>().sizeDelta.x, sum);
- 讀取面板.SetActive(false);
- }
- public void 關鍵字搜尋()
- {
- StartCoroutine(庫存盤點申請明細表讀取());
- }
- IEnumerator 庫存盤點申請明細表讀取()
- {
- 讀取面板.SetActive(true);
- if (copy1 != null)
- {
- DeletetextCopies1();
- }
- 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(buttonPrefab1) as GameObject;
- buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
- buttonObj.transform.SetParent(buttonParent1, false);
- TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
- text[0].text = (i+1).ToString();
- text[1].text = 計算[i][4].ToString().Trim('"');
- text[2].text = 計算[i][6].ToString().Trim('"');
- text[3].text = 計算[i][7].ToString().Trim('"');
- sum+=100;
- copy1.Add(buttonObj);
- }
- buttonceneter1.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter1.GetComponent<RectTransform>().sizeDelta.x, sum);
- 讀取面板.SetActive(false);
- }
- public void 審核()
- {
- for (int i = 0; i < 簽名檔.Count; i++)
- {
- if (Main.Global.人員 == 簽名檔[i][1].ToString().Trim('"'))
- {
- string str = 簽名檔[i][0].ToString().Trim('"');
- StartCoroutine(修改盤營盤損控制表簽名(str));
- }
- }
-
- }
- IEnumerator 修改盤營盤損控制表簽名(string str)
- {
- string strcon = "修改盤營盤損控制表簽名";
- string se = Main.Global.預設伺服器路徑;
- string pa2 = DateTime.Now.ToString("yyyy/MM/dd");
- string pa3 = 單號.text;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}"
- , strcon, se, str, pa2, pa3);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- Debug.Log(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
-
- for (int i = 0; i < 計算.Count; i++)
- {
- if (計算[i][2].ToString().Trim('"') != "")
- {
- int 庫存 = 計算[i][6];
- int 盤點 = 計算[i][7];
- int 總和 = 盤點-庫存;
- string 流水 = 計算[i][2].ToString().Trim('"');
- if (總和 > 0)
- {
- yield return StartCoroutine(盤點審核排程明細表修改(流水,"盤盈核准"));
- }
- else if (總和 < 0)
- {
- yield return StartCoroutine(盤點審核排程明細表修改(流水,"盤損核准"));
- }
- }
- }
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "審核成功!!";
- 模式 = "";
- 單號.text="";
- 日期.text="";
- 備註.text="";
- 人員.text="";
- 類型.text="";
- 狀態.text="";
- 初始頁.SetActive(true);
- 選擇頁.SetActive(false);
- 主頁.SetActive(false);
- 明細頁.SetActive(false);
- }
- IEnumerator 盤點審核排程明細表修改(string 流水號, string 狀態)
- {
- string strcon = "盤點審核排程明細表修改";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}", strcon, se, 流水號, 狀態);
- 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 void 上一頁21()
- {
- 模式 = "";
- 單號.text="";
- 日期.text="";
- 備註.text="";
- 人員.text="";
- 類型.text="";
- 狀態.text="";
- 初始頁.SetActive(true);
- 選擇頁.SetActive(false);
- 主頁.SetActive(false);
-
- }
- public void 上一頁32()
- {
- 主頁.SetActive(true);
- 明細頁.SetActive(false);
- }
- public void 下一頁23()
- {
- 主頁.SetActive(false);
- 明細頁.SetActive(true);
- if (模式 == "審查")
- {
- 審查按鈕.SetActive(true);
- }
- else
- {
- 審查按鈕.SetActive(false);
- }
- }
- public void 彈跳關閉()
- {
- 彈跳面板.SetActive(false);
- 彈跳文字.text = "";
- }
- public void home()
- {
- change_Secen(1);
- }
- public void change_Secen(int _screenNum)
- {
-
- SceneManager.LoadScene(_screenNum);
- }
- public void DeletetextCopies1()
- {
- // 刪除複製出來的物件
- foreach (GameObject copy in copy1)
- {
- Destroy(copy);
- }
- copy1.Clear();
- }
- public void DeletetextCopies()
- {
- // 刪除複製出來的物件
- foreach (GameObject copy in copy)
- {
- Destroy(copy);
- }
- copy.Clear();
- }
- }
|