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] Button 存檔紐; [SerializeField] Button 刪除紐; [SerializeField] Button 切換紐; [SerializeField] Button 回首紐; [SerializeField] RawImage 縮圖; [SerializeField] RawImage 拍照用; [SerializeField] RawImage 放圖用; [SerializeField] GameObject 主頁; [SerializeField] GameObject 圖頁; [SerializeField] TextMeshProUGUI 提示字; private WebCamTexture myCam;//接收攝影機返回的圖片數據 public GameObject buttonPrefab; public Transform buttonParent; public GameObject buttonceneter; private List copy = new List(); public GameObject buttonPrefab1; public Transform buttonParent1; public GameObject buttonceneter1; private List copy1 = new List(); public TMP_Dropdown 年; public TMP_Dropdown 月; public TMP_Dropdown 假別; public TMP_Dropdown 時數; [SerializeField] TextMeshProUGUI 日期; [SerializeField] TextMeshProUGUI 申請人; [SerializeField] TextMeshProUGUI 編號; [SerializeField] TMP_InputField 事由; public CanvasScaler canvasScaler; [SerializeField] GameObject 人員清單面板; [SerializeField] GameObject 人員清單按鈕; [SerializeField] GameObject 讀取面板; [SerializeField] TextMeshProUGUI 讀取; [SerializeField] GameObject 彈跳面板; [SerializeField] TextMeshProUGUI 彈跳文字; private string loadingText = ""; private int dotCount = 0; string 生效; string 圖片資料庫; bool 是否有圖; string 選擇資料庫; string 選擇流水號; void Start() { Screen.autorotateToPortrait = false; Screen.orientation = ScreenOrientation.Portrait; Main.Global.螢幕方向="直"; //Main.Global.固高=1900f; //Main.Global.固寬=900f; //Main.Global.固比=1f; //Main.Global.螢幕格式="瘦"; //Main.Global.考勤主管權限=false; //Main.Global.PA="盧婕柔"; //Main.Global.編號="999"; canvasScaler.referenceResolution = new Vector2(Main.Global.固寬, Main.Global.固高); canvasScaler.matchWidthOrHeight=Main.Global.固比; //Main.Global.阿帕契路徑="http://106.1.48.106:8080/wp-content/themes/event-star/hskin_login.php?"; //Main.Global.預設伺服器路徑="test"; 存檔紐.interactable = false; 刪除紐.interactable = false; 切換紐.interactable = false; 回首紐.interactable = true; 主頁.SetActive(true); 圖頁.SetActive(false); if (Main.Global.考勤主管權限==true) { 人員清單按鈕.SetActive(true); } else { 人員清單按鈕.SetActive(false); } StartCoroutine(AnimateText()); StartCoroutine(圖片資料庫選擇()); 是否有圖=false; } 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); 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") { 讀取面板.SetActive(false); 彈跳面板.SetActive(true); 彈跳文字.text = "圖片資料庫已滿,請找系統管理員!!"; yield return new WaitForSeconds(2); change_Secen(2); } else { 圖片資料庫 =str; yield return 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; } JSONNode json = JSON.Parse(request.downloadHandler.text); 年.options.Clear(); List options = new List(); for (int i = 0; i < json.Count; i++) { string str = json[i].ToString().Trim('"'); options.Add(new TMP_Dropdown.OptionData(str)); } 年.AddOptions(options); DateTime currentDate = DateTime.Now; string year = currentDate.Year.ToString(); string month = currentDate.Month.ToString("D2"); int currentIndex = 年.options.FindIndex(option => option.text == year); 年.value = currentIndex; int currentIndex1 = 月.options.FindIndex(option => option.text == month); 月.value = currentIndex1; 年.onValueChanged.AddListener((value) => OnDropdown1ValueChanged()); 月.onValueChanged.AddListener((value) => OnDropdown1ValueChanged()); if (Main.Global.PA=="測試號") { 申請人.text=Main.Global.PA; 編號.text=Main.Global.編號; yield return StartCoroutine(請假申請明細表()); } else { yield return StartCoroutine(請假申請人員清單()); } } private void OnDropdown1ValueChanged() { StartCoroutine(請假申請人員清單()); } IEnumerator 請假申請人員清單() { 讀取面板.SetActive(true); if (copy!= null) { DeleteCopies(copy); } string strcon = "請假申請人員清單"; string se = Main.Global.預設伺服器路徑; string pa = 月.options[月.value].text; string pa1 = 年.options[年.value].text; string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA={2}&PA1={3}", strcon, se, pa,pa1); 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 = 5; for (int i = 0; i < json.Count; i++) { GameObject buttonObj = Instantiate(buttonPrefab) as GameObject; buttonObj.GetComponent().anchoredPosition = new Vector2(2, -sum); buttonObj.transform.SetParent(buttonParent, false); TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren(); text[0].text = (i+1).ToString(); text[1].text = json[i][1].ToString().Trim('"'); text[2].text = json[i][2].ToString().Trim('"'); Button bt = buttonObj.GetComponentInChildren