Ei kuvausta
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.

晨會點名.cs 36KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992
  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 System.Text.RegularExpressions;
  8. using System.Data.SqlClient;
  9. using TMPro;
  10. using System;
  11. using System.IO;
  12. using ZXing;
  13. using ZXing.QrCode;
  14. using System.Net;
  15. using SimpleJSON;
  16. using System.ComponentModel;
  17. using System.Runtime.InteropServices;
  18. public class 晨會點名 : MonoBehaviour
  19. {
  20. public CanvasScaler canvasScaler;
  21. float screenWidth;
  22. float screenHeight;
  23. [SerializeField] GameObject 主畫面;
  24. [SerializeField] GameObject 出勤狀況;
  25. [SerializeField] GameObject 查找;
  26. [SerializeField] GameObject 點名1;
  27. [SerializeField] GameObject 點名2;
  28. [SerializeField] GameObject 點名1按鈕;
  29. [SerializeField] GameObject 點名2按鈕;
  30. [SerializeField] TMP_InputField 工作重點s;
  31. [SerializeField] TMP_InputField 臨時狀況s;
  32. [SerializeField] TMP_InputField 備註內容s;
  33. [SerializeField] Button Button1;
  34. [SerializeField] Button Button2;
  35. [SerializeField] Button Button3;
  36. [SerializeField] Button Button4;
  37. [SerializeField] Button Button5;
  38. [SerializeField] Button Button6;
  39. [SerializeField] Button Button7;
  40. [SerializeField] Button Button8;
  41. [SerializeField] Button Button9;
  42. [SerializeField] RawImage rawImage1;
  43. [SerializeField] RawImage rawImage2;
  44. [SerializeField] RawImage rawImage3;
  45. [SerializeField] RawImage rawImage4;
  46. [SerializeField] GameObject 彈跳面板;
  47. [SerializeField] TextMeshProUGUI 彈跳文字;
  48. [SerializeField] GameObject 讀取面板;
  49. [SerializeField] TextMeshProUGUI 讀取;
  50. public TMP_Dropdown 年下拉;
  51. public TMP_Dropdown 月下拉;
  52. public TMP_Dropdown 日下拉;
  53. JSONNode 簽名檔;
  54. public TMP_Dropdown 年下拉1;
  55. public TMP_Dropdown 月下拉1;
  56. public GameObject buttonPrefab;
  57. public Transform buttonParent;
  58. public GameObject buttonceneter;
  59. private List<GameObject> copy = new List<GameObject>();
  60. public GameObject buttonPrefab1;
  61. public Transform buttonParent1;
  62. public GameObject buttonceneter1;
  63. private List<GameObject> copy1 = new List<GameObject>();
  64. // Start is called before the first frame update
  65. JSONNode 點名清單;
  66. JSONNode 控制表;
  67. public Sprite 紅燈;
  68. public Sprite 綠燈;
  69. bool 已點名;
  70. bool 廠長已點名;
  71. bool 副總已點名;
  72. bool 總經理已點名;
  73. bool 啟動;
  74. private string loadingText = "";
  75. private int dotCount = 0;
  76. void Start()
  77. {
  78. Screen.autorotateToPortrait = false;
  79. Screen.orientation = ScreenOrientation.Portrait;
  80. float rate = 900.0f / 1900.0f;
  81. if (canvasScaler == null)
  82. {
  83. canvasScaler = GetComponent<CanvasScaler>();
  84. }
  85. if (Main.Global.rate>rate)
  86. {
  87. canvasScaler.matchWidthOrHeight = 1f;
  88. }
  89. else
  90. {
  91. canvasScaler.matchWidthOrHeight = 0f;
  92. }
  93. /*Main.Global.阿帕契路徑="http://106.1.48.106:8080/wp-content/themes/event-star/shto_main.php?";
  94. Main.Global.預設伺服器路徑="official";
  95. Main.Global.人員 = "劉俊男";
  96. Main.Global.級別 = "01";
  97. Main.Global.職稱 = "00002.總經理";*/
  98. StartCoroutine(AnimateText());
  99. 讀取面板.SetActive(true);
  100. DateTime currentDate = DateTime.Now;
  101. 年下拉.value = currentDate.Year - 2023;
  102. 月下拉.value = currentDate.Month - 1;
  103. 年下拉1.value = currentDate.Year - 2023;
  104. 月下拉1.value = currentDate.Month - 1;
  105. UpdateDayDropdown(currentDate.Year, currentDate.Month);
  106. 日下拉.value=currentDate.Day - 1;
  107. 啟動=false;
  108. StartCoroutine(點名主表(currentDate.Year.ToString(), currentDate.Month.ToString()));
  109. StartCoroutine(主管簽名檔清單());
  110. }
  111. IEnumerator AnimateText()
  112. {
  113. string qqq = 讀取.text.ToString();
  114. while (true)
  115. {
  116. yield return new WaitForSeconds(0.5f);
  117. if (dotCount < 3)
  118. {
  119. loadingText += ".";
  120. dotCount++;
  121. }
  122. else
  123. {
  124. loadingText = "";
  125. dotCount = 0;
  126. }
  127. 讀取.text = qqq+loadingText;
  128. }
  129. }
  130. public void UpdateDayDropdown(int year ,int month)
  131. {
  132. // 清空日期選項
  133. 日下拉.options.Clear();
  134. int daysInMonth = DateTime.DaysInMonth(year, month);
  135. List<TMP_Dropdown.OptionData> options = new List<TMP_Dropdown.OptionData>();
  136. for (int i = 1; i <= daysInMonth; i++)
  137. {
  138. if (i<10)
  139. {
  140. string 補零 = "0"+i.ToString();
  141. options.Add(new TMP_Dropdown.OptionData(補零));
  142. }
  143. else
  144. {
  145. options.Add(new TMP_Dropdown.OptionData(i.ToString()));
  146. }
  147. }
  148. 日下拉.AddOptions(options);
  149. }
  150. IEnumerator 點名主表(string pa, string pa1)
  151. {
  152. if (copy != null)
  153. {
  154. DeletetextCopies();
  155. }
  156. string strcon = "點名主表";
  157. string se = Main.Global.預設伺服器路徑;
  158. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA={2}&PA1={3}", strcon, se, pa, pa1);
  159. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  160. yield return request.SendWebRequest();
  161. if (request.result == UnityWebRequest.Result.ConnectionError)
  162. {
  163. Debug.Log(request.error);
  164. yield break;
  165. }
  166. JSONNode json = JSON.Parse(request.downloadHandler.text);
  167. int sum = 0;
  168. for (int i = 0; i < json.Count; i++)
  169. {
  170. GameObject buttonObj = Instantiate(buttonPrefab) as GameObject;
  171. buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
  172. buttonObj.transform.SetParent(buttonParent, false);
  173. TextMeshProUGUI text = buttonObj.GetComponentInChildren<TextMeshProUGUI>();
  174. Button bt = buttonObj.GetComponentInChildren<Button>();
  175. int index = i;
  176. bt.onClick.AddListener(() =>
  177. {
  178. 年下拉.onValueChanged.RemoveListener(年份改變);
  179. 月下拉.onValueChanged.RemoveListener(月份改變);
  180. 日下拉.onValueChanged.RemoveListener(日期改變);
  181. 讀取面板.SetActive(true);
  182. string datez =json[index][1].ToString().Trim('"');
  183. DateTime date = DateTime.ParseExact(datez,"yyyy/MM/dd",null);
  184. int year = date.Year;
  185. int month = date.Month;
  186. int day = date.Day;
  187. 年下拉.value = year - 2023;
  188. 月下拉.value = month - 1;
  189. 日下拉.value = day - 1;
  190. if (點名2按鈕.activeSelf)
  191. {
  192. 查找.SetActive(false);
  193. 點名2.SetActive(true);
  194. }
  195. else
  196. {
  197. 查找.SetActive(false);
  198. 點名1.SetActive(true);
  199. }
  200. 年下拉.onValueChanged.AddListener(年份改變);
  201. 月下拉.onValueChanged.AddListener(月份改變);
  202. 日下拉.onValueChanged.AddListener(日期改變);
  203. StartCoroutine(點名流水號查詢());
  204. });
  205. text.text = json[i][1].ToString().Trim('"');
  206. sum+=100;
  207. copy.Add(buttonObj);
  208. }
  209. buttonceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter.GetComponent<RectTransform>().sizeDelta.x, sum);
  210. 讀取面板.SetActive(false);
  211. }
  212. IEnumerator 主管簽名檔清單()
  213. {
  214. string strcon = "主管簽名檔清單";
  215. string se = Main.Global.預設伺服器路徑;
  216. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
  217. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  218. yield return request.SendWebRequest();
  219. if (request.result == UnityWebRequest.Result.ConnectionError)
  220. {
  221. Debug.Log(request.error);
  222. yield break;
  223. }
  224. 簽名檔 = JSON.Parse(request.downloadHandler.text);
  225. Debug.Log(簽名檔);
  226. if (啟動==false)
  227. {
  228. Debug.Log("有加入");
  229. 年下拉.onValueChanged.AddListener(年份改變);
  230. 月下拉.onValueChanged.AddListener(月份改變);
  231. 日下拉.onValueChanged.AddListener(日期改變);
  232. 年下拉1.onValueChanged.AddListener(年份改變1);
  233. 月下拉1.onValueChanged.AddListener(月份改變1);
  234. }
  235. StartCoroutine(點名流水號查詢());
  236. }
  237. IEnumerator 點名流水號查詢()
  238. {
  239. 讀取面板.SetActive(true);
  240. string strcon = "點名流水號查詢";
  241. string se = Main.Global.預設伺服器路徑;
  242. string year = 年下拉.options[年下拉.value].text;
  243. string month = 月下拉.options[月下拉.value].text;
  244. string day = 日下拉.options[日下拉.value].text;
  245. string pa = year+"/"+month+"/"+day;
  246. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA={2}", strcon,se,pa);
  247. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  248. yield return request.SendWebRequest();
  249. if (request.result == UnityWebRequest.Result.ConnectionError)
  250. {
  251. Debug.Log(request.error);
  252. yield break;
  253. }
  254. string str = request.downloadHandler.text.ToString();
  255. Debug.Log(str);
  256. string 流水號 = "";
  257. 工作重點s.text ="";
  258. 臨時狀況s.text ="";
  259. 備註內容s.text ="";
  260. if (str != "n")
  261. {
  262. 已點名=true;
  263. 流水號 = str;
  264. yield return StartCoroutine(點名明細1(流水號));
  265. }
  266. else
  267. {
  268. 已點名=false;
  269. rawImage1.texture = 紅燈.texture;
  270. rawImage2.texture = 紅燈.texture;
  271. rawImage3.texture = 紅燈.texture;
  272. rawImage4.texture = 紅燈.texture;
  273. }
  274. yield return StartCoroutine(點名明細(流水號));
  275. }
  276. IEnumerator 點名明細1(string 流水號)
  277. {
  278. string strcon = "點名明細1";
  279. string se = Main.Global.預設伺服器路徑;
  280. string pa = 流水號;
  281. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}", strcon, se, pa);
  282. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  283. yield return request.SendWebRequest();
  284. if (request.result == UnityWebRequest.Result.ConnectionError)
  285. {
  286. Debug.Log(request.error);
  287. yield break;
  288. }
  289. 控制表=JSON.Parse(request.downloadHandler.text);
  290. 工作重點s.text =控制表[2].ToString().Trim('"');
  291. 臨時狀況s.text =控制表[3].ToString().Trim('"');
  292. 備註內容s.text =控制表[4].ToString().Trim('"');
  293. bool 已點名;
  294. bool 廠長已點名;
  295. bool 副總已點名;
  296. bool 總經理已點名;
  297. if (控制表[11]!= null && 控制表[11].ToString().Trim('"')!= "")
  298. {
  299. 已點名=true;
  300. rawImage1.texture = 綠燈.texture;
  301. }
  302. else
  303. {
  304. 已點名=false;
  305. rawImage1.texture = 紅燈.texture;
  306. }
  307. if (控制表[9]!= null && 控制表[9].ToString().Trim('"')!= "")
  308. {
  309. 廠長已點名=true;
  310. rawImage2.texture = 綠燈.texture;
  311. }
  312. else
  313. {
  314. 廠長已點名=false;
  315. rawImage2.texture = 紅燈.texture;
  316. }
  317. if (控制表[7]!= null && 控制表[7].ToString().Trim('"')!= "")
  318. {
  319. rawImage3.texture = 綠燈.texture;
  320. 副總已點名=true;
  321. }
  322. else
  323. {
  324. 副總已點名=false;
  325. rawImage3.texture = 紅燈.texture;
  326. }
  327. if (控制表[5]!= null && 控制表[5].ToString().Trim('"')!= "")
  328. {
  329. rawImage4.texture = 綠燈.texture;
  330. 總經理已點名=true;
  331. }
  332. else
  333. {
  334. 總經理已點名=false;
  335. rawImage4.texture = 紅燈.texture;
  336. }
  337. 讀取面板.SetActive(false);
  338. }
  339. IEnumerator 點名明細(string pa)
  340. {
  341. if (copy1 != null)
  342. {
  343. DeletetextCopies1();
  344. }
  345. string strcon = "點名明細";
  346. string se = Main.Global.預設伺服器路徑;
  347. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA={2}", strcon, se, pa);
  348. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  349. yield return request.SendWebRequest();
  350. if (request.result == UnityWebRequest.Result.ConnectionError)
  351. {
  352. Debug.Log(request.error);
  353. yield break;
  354. }
  355. 點名清單 = JSON.Parse(request.downloadHandler.text);
  356. Debug.Log(點名清單);
  357. int sum = 0;
  358. for (int i = 0; i < 點名清單.Count; i++)
  359. {
  360. GameObject buttonObj = Instantiate(buttonPrefab1) as GameObject;
  361. buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
  362. buttonObj.transform.SetParent(buttonParent1, false);
  363. TextMeshProUGUI[] texts = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
  364. Toggle tg = buttonObj.GetComponentInChildren<Toggle>();
  365. Button[] bts = buttonObj.GetComponentsInChildren<Button>();
  366. texts[0].text = 點名清單[i][1].ToString().Trim('"');
  367. if (點名清單[i][0] == null)
  368. {
  369. 點名清單[i][0]=pa;
  370. }
  371. if (點名清單[i][2] == null)
  372. {
  373. 點名清單[i][2]=0;
  374. }
  375. if (點名清單[i][3] == null)
  376. {
  377. texts[1].text = "";
  378. 點名清單[i][3]="";
  379. }
  380. else
  381. {
  382. texts[1].text = 點名清單[i][3].ToString().Trim('"');
  383. }
  384. if (點名清單[i][2]==1)
  385. {
  386. tg.isOn=true;
  387. }
  388. else
  389. {
  390. tg.isOn=false;
  391. }
  392. int index = i;
  393. bts[0].onClick.AddListener(() =>
  394. {
  395. if (點名清單[index][2].ToString().Trim('"')=="0")
  396. {
  397. tg.isOn = true;
  398. 點名清單[index][2] = 1;
  399. Debug.Log(點名清單);
  400. }
  401. else
  402. {
  403. tg.isOn = false;
  404. 點名清單[index][2] = 0;
  405. Debug.Log(點名清單);
  406. }
  407. });
  408. bts[1].onClick.AddListener(() =>
  409. {
  410. 出勤狀況.SetActive(true);
  411. Button1.onClick.RemoveAllListeners();
  412. Button2.onClick.RemoveAllListeners();
  413. Button3.onClick.RemoveAllListeners();
  414. Button4.onClick.RemoveAllListeners();
  415. Button5.onClick.RemoveAllListeners();
  416. Button6.onClick.RemoveAllListeners();
  417. Button7.onClick.RemoveAllListeners();
  418. Button8.onClick.RemoveAllListeners();
  419. Button9.onClick.RemoveAllListeners();
  420. Button1.onClick.AddListener(() =>
  421. {
  422. 點名清單[index][3]="";
  423. texts[1].text = "";
  424. 出勤狀況.SetActive(false);
  425. Debug.Log(點名清單);
  426. });
  427. Button2.onClick.AddListener(() =>
  428. {
  429. 點名清單[index][3]="事假";
  430. texts[1].text = "事假";
  431. 出勤狀況.SetActive(false);
  432. Debug.Log(點名清單);
  433. });
  434. Button3.onClick.AddListener(() =>
  435. {
  436. 點名清單[index][3]="病假";
  437. texts[1].text = "病假";
  438. 出勤狀況.SetActive(false);
  439. Debug.Log(點名清單);
  440. });
  441. Button4.onClick.AddListener(() =>
  442. {
  443. 點名清單[index][3]="外出卸貨";
  444. texts[1].text = "外出卸貨";
  445. 出勤狀況.SetActive(false);
  446. Debug.Log(點名清單);
  447. });
  448. Button5.onClick.AddListener(() =>
  449. {
  450. 點名清單[index][3]="外出修補";
  451. texts[1].text = "外出修補";
  452. 出勤狀況.SetActive(false);
  453. Debug.Log(點名清單);
  454. });
  455. Button6.onClick.AddListener(() =>
  456. {
  457. 點名清單[index][3]="支援";
  458. texts[1].text = "支援";
  459. 出勤狀況.SetActive(false);
  460. Debug.Log(點名清單);
  461. });
  462. Button7.onClick.AddListener(() =>
  463. {
  464. 點名清單[index][3]="探親";
  465. texts[1].text = "探親";
  466. 出勤狀況.SetActive(false);
  467. Debug.Log(點名清單);
  468. });
  469. Button8.onClick.AddListener(() =>
  470. {
  471. 點名清單[index][3]="合約期滿";
  472. texts[1].text = "合約期滿";
  473. 出勤狀況.SetActive(false);
  474. Debug.Log(點名清單);
  475. });
  476. Button9.onClick.AddListener(() =>
  477. {
  478. 點名清單[index][3]="解約";
  479. texts[1].text = "解約";
  480. 出勤狀況.SetActive(false);
  481. Debug.Log(點名清單);
  482. });
  483. });
  484. sum+=100;
  485. copy1.Add(buttonObj);
  486. }
  487. buttonceneter1.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter1.GetComponent<RectTransform>().sizeDelta.x, sum);
  488. 讀取面板.SetActive(false);
  489. 啟動=true;
  490. }
  491. public void DeletetextCopies1()
  492. {
  493. // 刪除複製出來的物件
  494. foreach (GameObject copy in copy1)
  495. {
  496. Destroy(copy);
  497. }
  498. copy1.Clear();
  499. }
  500. public void DeletetextCopies()
  501. {
  502. // 刪除複製出來的物件
  503. foreach (GameObject copy in copy)
  504. {
  505. Destroy(copy);
  506. }
  507. copy.Clear();
  508. }
  509. private void 年份改變(int value)
  510. {
  511. 讀取面板.SetActive(true);
  512. int a = value + 2023;
  513. int b = 月下拉.value + 1;
  514. UpdateDayDropdown(a, b);
  515. StartCoroutine(點名流水號查詢());
  516. }
  517. private void 月份改變(int value)
  518. {
  519. 讀取面板.SetActive(true);
  520. int a = 年下拉.value + 2023;
  521. int b = value + 1;
  522. UpdateDayDropdown(a, b);
  523. StartCoroutine(點名流水號查詢());
  524. }
  525. private void 年份改變1(int value)
  526. {
  527. 讀取面板.SetActive(true);
  528. int a = value + 2023;
  529. int b = 月下拉.value + 1;
  530. StartCoroutine(點名主表(a.ToString(), b.ToString()));
  531. }
  532. private void 月份改變1(int value)
  533. {
  534. 讀取面板.SetActive(true);
  535. int a = 年下拉.value + 2023;
  536. int b = value + 1;
  537. StartCoroutine(點名主表(a.ToString(), b.ToString()));
  538. }
  539. private void 日期改變(int value)
  540. {
  541. 讀取面板.SetActive(true);
  542. StartCoroutine(點名流水號查詢());
  543. }
  544. public void 查找按鈕()
  545. {
  546. if (點名2按鈕.activeSelf)
  547. {
  548. 查找.SetActive(!查找.activeSelf);
  549. 點名2.SetActive(!點名2.activeSelf);
  550. }
  551. else
  552. {
  553. 查找.SetActive(!查找.activeSelf);
  554. 點名1.SetActive(!點名1.activeSelf);
  555. }
  556. }
  557. public void 備註()
  558. {
  559. 點名1.SetActive(false);
  560. 點名2.SetActive(true);
  561. 點名1按鈕.SetActive(false);
  562. 點名2按鈕.SetActive(true);
  563. }
  564. public void 點名()
  565. {
  566. 點名2.SetActive(false);
  567. 點名1.SetActive(true);
  568. 點名2按鈕.SetActive(false);
  569. 點名1按鈕.SetActive(true);
  570. }
  571. public void 存檔()
  572. {
  573. 讀取面板.SetActive(true);
  574. StartCoroutine(點名查找當日日期());
  575. }
  576. IEnumerator 點名查找當日日期()
  577. {
  578. string strcon = "點名查找當日日期";
  579. string se = Main.Global.預設伺服器路徑;
  580. string year = 年下拉.options[年下拉.value].text;
  581. string month = 月下拉.options[月下拉.value].text;
  582. string day = 日下拉.options[日下拉.value].text;
  583. string pa = year+"/"+month+"/"+day;
  584. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA={2}", strcon, se, pa);
  585. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  586. yield return request.SendWebRequest();
  587. if (request.result == UnityWebRequest.Result.ConnectionError)
  588. {
  589. Debug.Log(request.error);
  590. yield break;
  591. }
  592. string str = request.downloadHandler.text.ToString();
  593. if (str == "無")
  594. {
  595. string wa = Main.Global.人員;
  596. string 序號 = "";
  597. for (int j = 0; j < 簽名檔.Count; j++)
  598. {
  599. Debug.Log(wa);
  600. string wa1 = 簽名檔[j][1].ToString().Trim('"');
  601. if (wa==wa1)
  602. {
  603. 序號 =簽名檔[j][0].ToString().Trim('"');
  604. }
  605. }
  606. yield return StartCoroutine(查找點名最後一筆流水號(序號));
  607. }
  608. else
  609. {
  610. StartCoroutine(修改點名控制表資料());
  611. }
  612. }
  613. IEnumerator 查找點名最後一筆流水號(string 序號)
  614. {
  615. string strcon = "查找點名最後一筆流水號";
  616. string se = Main.Global.預設伺服器路徑;
  617. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon, se);
  618. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  619. yield return request.SendWebRequest();
  620. if (request.result == UnityWebRequest.Result.ConnectionError)
  621. {
  622. Debug.Log(request.error);
  623. yield break;
  624. }
  625. string num = request.downloadHandler.text.ToString();
  626. string 流水號 = "GS";
  627. if (num == "n")
  628. {
  629. 流水號 +="00000000";
  630. }
  631. else
  632. {
  633. string cnum = num.Substring(2);
  634. int inum = int.Parse(cnum);
  635. inum+=1;
  636. if (inum<10)
  637. {
  638. 流水號+="0000000"+inum.ToString();
  639. }
  640. if (inum>9 && inum<100)
  641. {
  642. 流水號+="000000"+inum.ToString();
  643. }
  644. if (inum>99 && inum<1000)
  645. {
  646. 流水號+="00000"+inum.ToString();
  647. }
  648. if (inum>999 && inum<10000)
  649. {
  650. 流水號+="0000"+inum.ToString();
  651. }
  652. if (inum>9999 && inum<100000)
  653. {
  654. 流水號+="000"+inum.ToString();
  655. }
  656. if (inum>99999 && inum<10000000)
  657. {
  658. 流水號+="00"+inum.ToString();
  659. }
  660. if (inum>999999 && inum<10000000)
  661. {
  662. 流水號+="0"+inum.ToString();
  663. }
  664. if (inum>9999999 && inum<100000000)
  665. {
  666. 流水號+=inum.ToString();
  667. }
  668. StartCoroutine(新增點名控制表資料(流水號, 序號));
  669. }
  670. }
  671. IEnumerator 新增點名控制表資料(string 流水號, string 序號)
  672. {
  673. string strcon = "新增點名控制表資料";
  674. string se = Main.Global.預設伺服器路徑;
  675. string pa1 = 流水號;
  676. string year1 = 年下拉.options[年下拉.value].text;
  677. string month1 = 月下拉.options[月下拉.value].text;
  678. string day = 日下拉.options[日下拉.value].text;
  679. string pa2 = year1+"/"+month1+"/"+day;
  680. //string pa2 = DateTime.Now.ToString("yyyy/MM/dd");
  681. string pa3 = 工作重點s.text;
  682. string pa4 = 臨時狀況s.text;
  683. string pa5 = 備註內容s.text;
  684. string pa6 = 序號;
  685. string pa7 = DateTime.Now.ToString("yyyy/MM/dd");
  686. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}&PA5={6}&PA6={7}&PA7={8}"
  687. , strcon, se, pa1, pa2, pa3, pa4, pa5, pa6, pa7);
  688. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  689. yield return request.SendWebRequest();
  690. if (request.result == UnityWebRequest.Result.ConnectionError)
  691. {
  692. Debug.Log(request.error);
  693. yield break;
  694. }
  695. for (int i = 0; i < 點名清單.Count; i++)
  696. {
  697. string a2 = 點名清單[i][4].ToString().Trim('"');
  698. int b3 = 點名清單[i][2];
  699. string a4 = 點名清單[i][3].ToString().Trim('"');
  700. yield return StartCoroutine(新增點名明細表資料(流水號, a2, b3, a4));
  701. if (i == 點名清單.Count-1)
  702. {
  703. 彈跳面板.SetActive(true);
  704. 彈跳文字.text = "新增成功";
  705. string year = 年下拉.options[年下拉.value].text;
  706. string month = 月下拉.options[月下拉.value].text;
  707. 年下拉1.value = 年下拉.value;
  708. 月下拉1.value = 月下拉.value;
  709. yield return StartCoroutine(點名主表(year, month));
  710. yield return StartCoroutine(點名流水號查詢());
  711. //讀取面板.SetActive(false);
  712. }
  713. }
  714. }
  715. IEnumerator 新增點名明細表資料(string 流水號, string 帳號, int 點名狀況, string 出勤狀態)
  716. {
  717. string strcon = "新增點名明細表資料";
  718. string se = Main.Global.預設伺服器路徑;
  719. string pa1 = 流水號;
  720. string pa2 = 帳號;
  721. int pa3 = 點名狀況;
  722. string pa4 = 出勤狀態;
  723. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}"
  724. , strcon, se, pa1, pa2, pa3, pa4);
  725. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  726. yield return request.SendWebRequest();
  727. if (request.result == UnityWebRequest.Result.ConnectionError)
  728. {
  729. Debug.Log(request.error);
  730. yield break;
  731. }
  732. }
  733. IEnumerator 修改點名控制表資料()
  734. {
  735. string strcon = "修改點名控制表資料";
  736. string se = Main.Global.預設伺服器路徑;
  737. string pa1 = 工作重點s.text;
  738. string pa2 = 臨時狀況s.text;
  739. string pa3 = 備註內容s.text;
  740. string year = 年下拉.options[年下拉.value].text;
  741. string month = 月下拉.options[月下拉.value].text;
  742. string day = 日下拉.options[日下拉.value].text;
  743. string pa4 = year+"/"+month+"/"+day;
  744. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}"
  745. , strcon, se, pa1, pa2, pa3, pa4);
  746. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  747. yield return request.SendWebRequest();
  748. if (request.result == UnityWebRequest.Result.ConnectionError)
  749. {
  750. Debug.Log(request.error);
  751. yield break;
  752. }
  753. for (int i = 0; i < 點名清單.Count; i++)
  754. {
  755. string 流水號 = 點名清單[i][0].ToString().Trim('"');
  756. string a2 = 點名清單[i][4].ToString().Trim('"');
  757. int b3 = 點名清單[i][2];
  758. string a4 = 點名清單[i][3].ToString().Trim('"');
  759. yield return StartCoroutine(修改點名明細表資料(流水號, a2, b3, a4));
  760. if (i == 點名清單.Count-1)
  761. {
  762. 彈跳面板.SetActive(true);
  763. 彈跳文字.text = "修改成功";
  764. StartCoroutine(點名流水號查詢());
  765. 讀取面板.SetActive(false);
  766. }
  767. }
  768. }
  769. IEnumerator 修改點名明細表資料(string 流水號, string 帳號, int 點名狀況, string 出勤狀態)
  770. {
  771. string strcon = "修改點名明細表資料";
  772. string se = Main.Global.預設伺服器路徑;
  773. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}"
  774. , strcon, se, 點名狀況, 出勤狀態, 帳號, 流水號);
  775. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  776. yield return request.SendWebRequest();
  777. if (request.result == UnityWebRequest.Result.ConnectionError)
  778. {
  779. Debug.Log(request.error);
  780. yield break;
  781. }
  782. }
  783. public void 彈跳面板關閉()
  784. {
  785. 彈跳面板.SetActive(false);
  786. 彈跳文字.text = "";
  787. }
  788. public void 審核()
  789. {
  790. if (已點名==true)
  791. {
  792. string wa = Main.Global.人員;
  793. string 序號 = "";
  794. for (int j = 0; j < 簽名檔.Count; j++)
  795. {
  796. string wa1 = 簽名檔[j][1].ToString().Trim('"');
  797. if (wa==wa1)
  798. {
  799. 序號 =簽名檔[j][0].ToString().Trim('"');
  800. }
  801. }
  802. if (Main.Global.級別 == "00" && Main.Global.職稱 == "00000.NA")
  803. {
  804. StartCoroutine(修改點名控制表簽名());
  805. }
  806. else if(Main.Global.級別 == "01" && Main.Global.職稱 == "00002.總經理")
  807. {
  808. if (rawImage2.texture == 紅燈.texture)
  809. {
  810. 彈跳面板.SetActive(true);
  811. 彈跳文字.text = "廠長尚未確認,單據無法簽核!";
  812. }
  813. else if (rawImage3.texture == 紅燈.texture)
  814. {
  815. 彈跳面板.SetActive(true);
  816. 彈跳文字.text = "副總尚未確認,單據無法簽核!";
  817. }
  818. else
  819. {
  820. StartCoroutine(修改點名控制表簽名總(序號));
  821. }
  822. }
  823. else if (Main.Global.級別 == "02" && Main.Global.職稱 == "00003.副總經理")
  824. {
  825. if (rawImage2.texture == 紅燈.texture)
  826. {
  827. 彈跳面板.SetActive(true);
  828. 彈跳文字.text = "廠長尚未確認,單據無法簽核!";
  829. }
  830. else
  831. {
  832. StartCoroutine(修改點名控制表簽名副(序號));
  833. }
  834. }
  835. else if (Main.Global.級別 == "03" && Main.Global.職稱 == "31001.廠務部廠長")
  836. {
  837. StartCoroutine(修改點名控制表簽名廠(序號));
  838. }
  839. else
  840. {
  841. 彈跳面板.SetActive(true);
  842. 彈跳文字.text = "簽核權限錯誤!";
  843. }
  844. }
  845. else
  846. {
  847. 彈跳面板.SetActive(true);
  848. 彈跳文字.text = "點名單據尚未建立,無法簽核!";
  849. }
  850. }
  851. IEnumerator 修改點名控制表簽名副(string 序號)
  852. {
  853. string strcon = "修改點名控制表簽名副";
  854. string se = Main.Global.預設伺服器路徑;
  855. string pa2 = DateTime.Now.ToString("yyyy/MM/dd"); ;
  856. string year = 年下拉.options[年下拉.value].text;
  857. string month = 月下拉.options[月下拉.value].text;
  858. string day = 日下拉.options[日下拉.value].text;
  859. string pa3 = year+"/"+month+"/"+day;
  860. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}"
  861. , strcon, se, 序號, pa2, pa3);
  862. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  863. yield return request.SendWebRequest();
  864. if (request.result == UnityWebRequest.Result.ConnectionError)
  865. {
  866. Debug.Log(request.error);
  867. yield break;
  868. }
  869. 彈跳面板.SetActive(true);
  870. 彈跳文字.text = "簽核成功!";
  871. StartCoroutine(點名流水號查詢());
  872. }
  873. IEnumerator 修改點名控制表簽名廠(string 序號)
  874. {
  875. string strcon = "修改點名控制表簽名廠";
  876. string se = Main.Global.預設伺服器路徑;
  877. string pa2 = DateTime.Now.ToString("yyyy/MM/dd"); ;
  878. string year = 年下拉.options[年下拉.value].text;
  879. string month = 月下拉.options[月下拉.value].text;
  880. string day = 日下拉.options[日下拉.value].text;
  881. string pa3 = year+"/"+month+"/"+day;
  882. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}"
  883. , strcon, se, 序號, pa2, pa3);
  884. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  885. yield return request.SendWebRequest();
  886. if (request.result == UnityWebRequest.Result.ConnectionError)
  887. {
  888. Debug.Log(request.error);
  889. yield break;
  890. }
  891. 彈跳面板.SetActive(true);
  892. 彈跳文字.text = "簽核成功!";
  893. StartCoroutine(點名流水號查詢());
  894. }
  895. IEnumerator 修改點名控制表簽名總(string 序號)
  896. {
  897. string strcon = "修改點名控制表簽名總";
  898. string se = Main.Global.預設伺服器路徑;
  899. string pa2 = DateTime.Now.ToString("yyyy/MM/dd"); ;
  900. string year = 年下拉.options[年下拉.value].text;
  901. string month = 月下拉.options[月下拉.value].text;
  902. string day = 日下拉.options[日下拉.value].text;
  903. string pa3 = year+"/"+month+"/"+day;
  904. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}"
  905. , strcon, se, 序號, pa2, pa3);
  906. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  907. yield return request.SendWebRequest();
  908. if (request.result == UnityWebRequest.Result.ConnectionError)
  909. {
  910. Debug.Log(request.error);
  911. yield break;
  912. }
  913. 彈跳面板.SetActive(true);
  914. 彈跳文字.text = "簽核成功!";
  915. StartCoroutine(點名流水號查詢());
  916. }
  917. IEnumerator 修改點名控制表簽名()
  918. {
  919. string strcon = "修改點名控制表簽名";
  920. string se = Main.Global.預設伺服器路徑;
  921. string date = DateTime.Now.ToString("yyyy/MM/dd"); ;
  922. string year = 年下拉.options[年下拉.value].text;
  923. string month = 月下拉.options[月下拉.value].text;
  924. string day = 日下拉.options[日下拉.value].text;
  925. string pa3 = year+"/"+month+"/"+day;
  926. string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}&PA5={6}&PA6={7}&PA7={8}"
  927. , strcon, se,"PG00000001", date,"PG00000002", date,"PG00000003", date,pa3);
  928. Debug.Log(strUrl);
  929. UnityWebRequest request = UnityWebRequest.Get(strUrl);
  930. yield return request.SendWebRequest();
  931. if (request.result == UnityWebRequest.Result.ConnectionError)
  932. {
  933. Debug.Log(request.error);
  934. yield break;
  935. }
  936. 彈跳面板.SetActive(true);
  937. 彈跳文字.text = "簽核成功!";
  938. StartCoroutine(點名流水號查詢());
  939. }
  940. public void back()
  941. {
  942. change_Secen(1);
  943. }
  944. public void change_Secen(int _screenNum)
  945. {
  946. SceneManager.LoadScene(_screenNum);
  947. }
  948. public void 截圖()
  949. {
  950. string fileName = string.Format("{0}/screenshot_{1}.png", Application.persistentDataPath, System.DateTime.Now.ToString("yyyyMMdd_HHmmss"));
  951. ScreenCapture.CaptureScreenshot(fileName);
  952. }
  953. }