123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- 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
- {
- public CanvasScaler canvasScaler;
- float screenWidth;
- float screenHeight;
-
- private string loadingText = "";
- private int dotCount = 0;
-
- public GameObject buttonPrefab;
- public Transform buttonParent;
- public GameObject buttonceneter;
- private List<GameObject> copy = new List<GameObject>();
-
- [SerializeField] GameObject 讀取面板;
- [SerializeField] TextMeshProUGUI 讀取;
-
- [SerializeField] GameObject 彈跳面板;
- [SerializeField] TextMeshProUGUI 彈跳文字;
-
- // Start is called before the first frame update
- void Start()
- {
- Screen.autorotateToPortrait = false;
- Screen.orientation = ScreenOrientation.LandscapeLeft;
- 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";
-
- StartCoroutine(AnimateText());
- 讀取面板.SetActive(true);
- StartCoroutine(生產排程明細表());
- }
- 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 生產排程明細表()
- {
- if (copy != null)
- {
- DeletetextCopies();
- }
- 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);
- int sum = 3;
- for (int i = 0; i < json.Count; i++)
- {
- GameObject buttonObj = Instantiate(buttonPrefab) as GameObject;
- buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(3, -sum);
- buttonObj.transform.SetParent(buttonParent, false);
- TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
- Button bt = buttonObj.GetComponentInChildren<Button>();
- TMP_InputField tif = buttonObj.GetComponentInChildren<TMP_InputField>();
- int index = i;
- bt.onClick.AddListener(() =>
- {
- string str= json[index][0].ToString().Trim('"');
- string str1 = json[index][5].ToString().Trim('"');
- if (Main.Global.部門 == "3.廠務部" || Main.Global.部門 == "0.NA")
- {
- 讀取面板.SetActive(true);
- StartCoroutine(生產排程表修改(str, str1));
- }
- else
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "登入權限不足!!";
- }
- });
- tif.onValueChanged.AddListener((value) =>
- {
- json[index][5] = value;
- });
- text[0].text = json[i][2].ToString().Trim('"');
- text[1].text = json[i][3].ToString().Trim('"');
- text[2].text = json[i][4].ToString().Trim('"');
- text[4].text = json[i][10].ToString().Trim('"');
- tif.text = json[i][5].ToString().Trim('"');
-
- sum+=80;
- copy.Add(buttonObj);
- }
- buttonceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter.GetComponent<RectTransform>().sizeDelta.x, sum);
- 讀取面板.SetActive(false);
- }
- IEnumerator 生產排程表修改(string 流水 ,string 產量)
- {
- DateTime currentDate = DateTime.Now;
- string pa= currentDate.ToString("yyyy/MM/dd");
- string strcon = "生產排程表修改";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}", 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;
- }
- StartCoroutine(生產排程明細表());
- }
- public void 彈跳面板關閉()
- {
- 彈跳面板.SetActive(false);
- 彈跳文字.text = "";
- }
- public void DeletetextCopies()
- {
- // 刪除複製出來的物件
- foreach (GameObject copy in copy)
- {
- Destroy(copy);
- }
- copy.Clear();
- }
- public void back()
- {
- change_Secen(12);
- }
- public void change_Secen(int _screenNum)
- {
-
- SceneManager.LoadScene(_screenNum);
- }
-
- }
|