No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Main.cs 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. using UnityEngine.UI;
  6. using UnityEngine.Networking;
  7. using UnityEngine.EventSystems;
  8. using System.Text.RegularExpressions;
  9. using System.Data.SqlClient;
  10. using System.Runtime.InteropServices;
  11. using System.Text;
  12. using TMPro;
  13. using System;
  14. using System.IO;
  15. using ZXing;
  16. using ZXing.QrCode;
  17. using System.Net;
  18. using System.Data;
  19. using SimpleJSON;
  20. using System.Linq;
  21. using System.ComponentModel;
  22. using System.Runtime.InteropServices;
  23. using System.Globalization;
  24. public class Main : MonoBehaviour
  25. {
  26. [SerializeField] TMP_Dropdown 連動下拉;
  27. public CanvasScaler canvasScaler;
  28. float screenWidth;
  29. float screenHeight;
  30. [SerializeField] Button 物料使用狀況;
  31. [SerializeField] Button 庫存查詢;
  32. [SerializeField] Button 銷售報表;
  33. [SerializeField] Button 車輛入廠紀錄;
  34. [SerializeField] Button 收支單一覽表;
  35. [SerializeField] Button 收支單審核;
  36. [SerializeField] GameObject 讀取面板;
  37. [SerializeField] TextMeshProUGUI 讀取;
  38. [SerializeField] GameObject 彈跳面板;
  39. [SerializeField] TextMeshProUGUI 彈跳文字;
  40. private string loadingText = "";
  41. private int dotCount = 0;
  42. private List<Button> bts = new List<Button>();
  43. void Start()
  44. {
  45. Screen.autorotateToPortrait = false;
  46. Screen.orientation = ScreenOrientation.Portrait;
  47. float rate = 1000.0f / 1600.0f;
  48. if (canvasScaler == null)
  49. {
  50. canvasScaler = GetComponent<CanvasScaler>();
  51. }
  52. if (Main.Global.rate>rate)
  53. {
  54. canvasScaler.matchWidthOrHeight = 1f;
  55. }
  56. else
  57. {
  58. canvasScaler.matchWidthOrHeight = 0f;
  59. }
  60. StartCoroutine(AnimateText());
  61. 讀取面板.SetActive(true);
  62. StartCoroutine(讀取CC());
  63. }
  64. IEnumerator AnimateText()
  65. {
  66. string qqq = 讀取.text.ToString();
  67. while (true)
  68. {
  69. yield return new WaitForSeconds(0.5f);
  70. if (dotCount < 3)
  71. {
  72. loadingText += ".";
  73. dotCount++;
  74. }
  75. else
  76. {
  77. loadingText = "";
  78. dotCount = 0;
  79. }
  80. 讀取.text = qqq+loadingText;
  81. }
  82. }
  83. IEnumerator 讀取CC()
  84. {
  85. string strcon = "讀取";
  86. string name = Main.Global.PA;
  87. string ps = Main.Global.PB;
  88. string se = Main.Global.預設伺服器路徑;
  89. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&帳號={1}&密碼={2}&se={3}", strcon, name, ps, se);
  90. Debug.Log(strUrl);
  91. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  92. yield return request.SendWebRequest();
  93. if (request.result == UnityWebRequest.Result.ConnectionError)
  94. {
  95. //Debug.Log(request.error);
  96. }
  97. JSONNode json1 = JSON.Parse(request.downloadHandler.text);
  98. Debug.Log(json1);
  99. 讀取面板.SetActive(false);
  100. Main.Global.人員 = json1[0].ToString().Trim('"');
  101. Main.Global.級別 = json1[129].ToString().Trim('"');
  102. Main.Global.職稱 = json1[131].ToString().Trim('"');
  103. if (json1[104].ToString()=="0")
  104. {
  105. Main.Global.可選擇車廠型式=false;
  106. }
  107. else
  108. {
  109. Main.Global.可選擇車廠型式=true;
  110. }
  111. if (json1[106].ToString()=="0")
  112. {
  113. Main.Global.開啟帳本=false;
  114. }
  115. else
  116. {
  117. Main.Global.開啟帳本=true;
  118. }
  119. if (json1[124].ToString()=="0")
  120. {
  121. 物料使用狀況.gameObject.SetActive(false);
  122. }
  123. else
  124. {
  125. bts.Add(物料使用狀況);
  126. }
  127. if (json1[125].ToString()=="0")
  128. {
  129. 庫存查詢.gameObject.SetActive(false);
  130. }
  131. else
  132. {
  133. bts.Add(庫存查詢);
  134. }
  135. if (json1[63].ToString()=="0")
  136. {
  137. 銷售報表.gameObject.SetActive(false);
  138. }
  139. else
  140. {
  141. bts.Add(銷售報表);
  142. }
  143. if (json1[126].ToString()=="0")
  144. {
  145. 車輛入廠紀錄.gameObject.SetActive(false);
  146. }
  147. else
  148. {
  149. bts.Add(車輛入廠紀錄);
  150. }
  151. if (json1[93].ToString()=="0")
  152. {
  153. 收支單一覽表.gameObject.SetActive(false);
  154. }
  155. else
  156. {
  157. bts.Add(收支單一覽表);
  158. }
  159. if (json1[92].ToString()=="0")
  160. {
  161. 收支單審核.gameObject.SetActive(false);
  162. }
  163. else
  164. {
  165. bts.Add(收支單審核);
  166. }
  167. for (int i = 0; i < bts.Count; i++)
  168. {
  169. // 設定按鈕的位置
  170. float x = 150 + (i % 2) * 450; // 在每一行的水平位置
  171. float y = -250 - (i / 2) * 475; // 在每一行的垂直位置
  172. RectTransform rt = bts[i].GetComponent<RectTransform>();
  173. rt.anchoredPosition = new Vector2(x, y);
  174. }
  175. if (Main.Global.連動.Count > 1)
  176. {
  177. 連動下拉.gameObject.SetActive(true);
  178. 連動下拉.options.Clear();
  179. List<TMP_Dropdown.OptionData> options = new List<TMP_Dropdown.OptionData>();
  180. string qa = "";
  181. for (int i = 0; i < Main.Global.連動.Count; i++)
  182. {
  183. if (Main.Global.連動[i][1].ToString().Trim('"') == Main.Global.預設伺服器路徑)
  184. {
  185. qa = Main.Global.連動[i][0].ToString().Trim('"');
  186. }
  187. string str = Main.Global.連動[i][0].ToString().Trim('"');
  188. options.Add(new TMP_Dropdown.OptionData(str));
  189. }
  190. 連動下拉.AddOptions(options);
  191. int index1 = 連動下拉.options.FindIndex(option => option.text == qa);
  192. 連動下拉.value = index1;
  193. 連動下拉.onValueChanged.AddListener(delegate
  194. {
  195. for (int i = 0; i<Main.Global.連動.Count; i++)
  196. {
  197. if (Main.Global.連動[i][0].ToString().Trim('"') == 連動下拉.options[連動下拉.value].text)
  198. {
  199. Main.Global.預設伺服器路徑 = Main.Global.連動[i][1].ToString().Trim('"');
  200. }
  201. }
  202. Debug.Log(Main.Global.預設伺服器路徑);
  203. });
  204. }
  205. else
  206. {
  207. 連動下拉.gameObject.SetActive(false);
  208. }
  209. 讀取面板.SetActive(false);
  210. }
  211. public void 營銷報表()
  212. {
  213. //Main.Global.判斷是否第一次=true;
  214. change_Secen(2);
  215. }
  216. public void 庫存()
  217. {
  218. //Main.Global.判斷是否第一次=true;
  219. change_Secen(3);
  220. }
  221. public void 審核()
  222. {
  223. //Main.Global.判斷是否第一次=true;
  224. change_Secen(6);
  225. }
  226. public void 物料使用()
  227. {
  228. //Main.Global.判斷是否第一次=true;
  229. change_Secen(4);
  230. }
  231. public void 車輛紀錄()
  232. {
  233. //Main.Global.判斷是否第一次=true;
  234. change_Secen(5);
  235. }
  236. public void 一覽表()
  237. {
  238. //Main.Global.判斷是否第一次=true;
  239. change_Secen(7);
  240. }
  241. public void changen()
  242. {
  243. //Main.Global.判斷是否第一次=true;
  244. change_Secen(0);
  245. }
  246. public void change_Secen(int _screenNum)
  247. {
  248. //Main.Global.判斷是否第一次=true;
  249. SceneManager.LoadScene(_screenNum);
  250. }
  251. public static class Global
  252. {
  253. public static string 登入人IP, 年,日期, 職稱,狀態,系統語言, 使用者名稱, 密碼, 進入, 離開, 資料庫版本號, 執行檔版本號,版本號比對,預設伺服器路徑,版本號,選擇組別,阿帕契路徑,阿帕契,CC判別,合約內容,合約編號,級別,ID,查詢日期,人員,連動客戶;
  254. public static bool 開啟帳本,判斷是否連線,可選擇車廠型式 ,啟動完畢,系統分區控制,登入位置,鏡頭啟動,有無清單 ,讀取完畢, 首次登入, 讀取年份, 快速登入, show1, show2, show3, show4, show5, show6, show7,展示帳號登入,qwe,印尼內網;
  255. public static int 部門編號,camfps;
  256. public static float rate, rate_;
  257. //public static TimeSpan 運行天數;
  258. public static string PA, PB, PC, PD, PE, PF, PG, PH, PI, PJ, PK, PA1, PA2, PA3, PA4, PA5, PA6, PA9, PA20;
  259. //public static bool[] 電表異常BL = new bool[999];
  260. // public static Sprite[] Wnum;
  261. // public static Sprite[] Bnum;
  262. public static string[] 系統語言資料;
  263. // public static string[] CC判斷=new string[999];
  264. public static Dictionary<string, string> 系統語言字典 = new Dictionary<string, string>() { };
  265. public static string[,] PHP = new string[5, 2];
  266. public static JSONNode 連動;
  267. }
  268. }