123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- 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;
- using System.Globalization;
-
-
- public class 加班紀錄表 : MonoBehaviour
- {
- public CanvasScaler canvasScaler;
- private string loadingText = "";
- private int dotCount = 0;
-
- [SerializeField] GameObject 讀取面板;
- [SerializeField] TextMeshProUGUI 讀取;
-
- [SerializeField] GameObject 彈跳面板;
- [SerializeField] TextMeshProUGUI 彈跳文字;
-
- [SerializeField] TextMeshProUGUI 日期;
- public GameObject buttonPrefab;
- public ScrollRect buttonscroll;
- private List<GameObject> copy = new List<GameObject>();
- private DateTime currentDate;
- // 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";
- currentDate = DateTime.Now;
- UpdateDateDisplay();
- StartCoroutine(AnimateText());
- }
- IEnumerator 生產排程明細表()
- {
- 讀取面板.SetActive(true);
- if (copy != null)
- {
- DeleteCopies(copy);
- }
- string strcon = "考勤日期查詢清單";
- string se = Main.Global.預設伺服器路徑;
- string pa = currentDate.ToString("yyyy/MM/dd");
- string strUrl = string.Format(Main.Global.阿帕契路徑 + "comm={0}&se={1}&PA={2}&PA1={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;
- }
- 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);
- Transform tran = buttonscroll.content;
- buttonObj.transform.SetParent(tran, false);
- TextMeshProUGUI[] texts = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
- if (json[i][0] != null)
- {
- texts[0].text = json[i][0].ToString().Trim('"');
- }
- if (json[i][5] != null)
- {
- texts[1].text = json[i][5].ToString().Trim('"');
- }
- if (json[i][14] != null)
- {
- texts[2].text = json[i][14].ToString().Trim('"');
- }
- if (json[i][15] != null)
- {
- texts[3].text = json[i][15].ToString().Trim('"');
- }
- if (json[i][16] != null)
- {
- texts[4].text = json[i][16].ToString().Trim('"');
- }
- if (json[i][17] != null)
- {
- texts[5].text = json[i][17].ToString().Trim('"');
- }
- sum += 80;
- copy.Add(buttonObj);
- }
- RectTransform contentTransform = buttonscroll.content;
- contentTransform.anchoredPosition = new Vector2(contentTransform.anchoredPosition.x, 0);
- contentTransform.sizeDelta = new Vector2(contentTransform.sizeDelta.x, sum);
- if (sum > 703)
- {
- buttonscroll.vertical = true;
- }
- else
- {
- buttonscroll.vertical = false;
- }
- 讀取面板.SetActive(false);
- }
- void UpdateDateDisplay()
- {
- CultureInfo chineseCulture = new CultureInfo("zh-CN");
- // 更新日期和星期顯示
- 日期.text = currentDate.ToString("yyyy/MM/dd-dddd", chineseCulture);
- StartCoroutine(生產排程明細表());
- }
-
- public void 上一天()
- {
- // 減少一天
- currentDate = currentDate.AddDays(-1);
- UpdateDateDisplay();
- }
-
- public void 下一天()
- {
- // 增加一天
- currentDate = currentDate.AddDays(1);
- UpdateDateDisplay();
- }
- 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 彈跳面板關閉()
- {
- 彈跳面板.SetActive(false);
- 彈跳文字.text = "";
- }
- private void DeleteCopies(List<GameObject> copyList)
- {
- foreach (GameObject copy in copyList)
- {
- Destroy(copy);
- }
- copyList.Clear();
- }
- public void back()
- {
- change_Secen(12);
- }
- public void change_Secen(int _screenNum)
- {
-
- SceneManager.LoadScene(_screenNum);
- }
- }
|