123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992 |
- 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;
- [SerializeField] GameObject 主畫面;
- [SerializeField] GameObject 出勤狀況;
- [SerializeField] GameObject 查找;
- [SerializeField] GameObject 點名1;
- [SerializeField] GameObject 點名2;
- [SerializeField] GameObject 點名1按鈕;
- [SerializeField] GameObject 點名2按鈕;
-
- [SerializeField] TMP_InputField 工作重點s;
- [SerializeField] TMP_InputField 臨時狀況s;
- [SerializeField] TMP_InputField 備註內容s;
-
- [SerializeField] Button Button1;
- [SerializeField] Button Button2;
- [SerializeField] Button Button3;
- [SerializeField] Button Button4;
- [SerializeField] Button Button5;
- [SerializeField] Button Button6;
- [SerializeField] Button Button7;
- [SerializeField] Button Button8;
- [SerializeField] Button Button9;
-
- [SerializeField] RawImage rawImage1;
- [SerializeField] RawImage rawImage2;
- [SerializeField] RawImage rawImage3;
- [SerializeField] RawImage rawImage4;
-
- [SerializeField] GameObject 彈跳面板;
- [SerializeField] TextMeshProUGUI 彈跳文字;
-
- [SerializeField] GameObject 讀取面板;
- [SerializeField] TextMeshProUGUI 讀取;
-
-
- public TMP_Dropdown 年下拉;
- public TMP_Dropdown 月下拉;
- public TMP_Dropdown 日下拉;
- JSONNode 簽名檔;
-
- public TMP_Dropdown 年下拉1;
- public TMP_Dropdown 月下拉1;
-
- public GameObject buttonPrefab;
- public Transform buttonParent;
- public GameObject buttonceneter;
- private List<GameObject> copy = new List<GameObject>();
-
- public GameObject buttonPrefab1;
- public Transform buttonParent1;
- public GameObject buttonceneter1;
- private List<GameObject> copy1 = new List<GameObject>();
-
-
- // Start is called before the first frame update
- JSONNode 點名清單;
- JSONNode 控制表;
- public Sprite 紅燈;
- public Sprite 綠燈;
- bool 已點名;
- bool 廠長已點名;
- bool 副總已點名;
- bool 總經理已點名;
- bool 啟動;
-
- private string loadingText = "";
- private int dotCount = 0;
- void Start()
- {
-
- Screen.autorotateToPortrait = false;
- Screen.orientation = ScreenOrientation.Portrait;
- float rate = 900.0f / 1900.0f;
- if (canvasScaler == null)
- {
- canvasScaler = GetComponent<CanvasScaler>();
- }
-
- 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";
- Main.Global.人員 = "劉俊男";
- Main.Global.級別 = "01";
- Main.Global.職稱 = "00002.總經理";*/
-
- StartCoroutine(AnimateText());
- 讀取面板.SetActive(true);
-
- DateTime currentDate = DateTime.Now;
- 年下拉.value = currentDate.Year - 2023;
- 月下拉.value = currentDate.Month - 1;
- 年下拉1.value = currentDate.Year - 2023;
- 月下拉1.value = currentDate.Month - 1;
- UpdateDayDropdown(currentDate.Year, currentDate.Month);
- 日下拉.value=currentDate.Day - 1;
- 啟動=false;
- StartCoroutine(點名主表(currentDate.Year.ToString(), currentDate.Month.ToString()));
- 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;
- }
- }
- public void UpdateDayDropdown(int year ,int month)
- {
- // 清空日期選項
- 日下拉.options.Clear();
- int daysInMonth = DateTime.DaysInMonth(year, month);
- List<TMP_Dropdown.OptionData> options = new List<TMP_Dropdown.OptionData>();
- for (int i = 1; i <= daysInMonth; i++)
- {
- if (i<10)
- {
- string 補零 = "0"+i.ToString();
- options.Add(new TMP_Dropdown.OptionData(補零));
- }
- else
- {
- options.Add(new TMP_Dropdown.OptionData(i.ToString()));
- }
-
- }
- 日下拉.AddOptions(options);
- }
- IEnumerator 點名主表(string pa, string pa1)
- {
- if (copy != null)
- {
- DeletetextCopies();
- }
- string strcon = "點名主表";
- string se = Main.Global.預設伺服器路徑;
- 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 = 0;
- for (int i = 0; i < json.Count; i++)
- {
- GameObject buttonObj = Instantiate(buttonPrefab) as GameObject;
- buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
- buttonObj.transform.SetParent(buttonParent, false);
- TextMeshProUGUI text = buttonObj.GetComponentInChildren<TextMeshProUGUI>();
- Button bt = buttonObj.GetComponentInChildren<Button>();
- int index = i;
- bt.onClick.AddListener(() =>
- {
-
- 年下拉.onValueChanged.RemoveListener(年份改變);
- 月下拉.onValueChanged.RemoveListener(月份改變);
- 日下拉.onValueChanged.RemoveListener(日期改變);
- 讀取面板.SetActive(true);
- string datez =json[index][1].ToString().Trim('"');
- DateTime date = DateTime.ParseExact(datez,"yyyy/MM/dd",null);
- int year = date.Year;
- int month = date.Month;
- int day = date.Day;
- 年下拉.value = year - 2023;
- 月下拉.value = month - 1;
- 日下拉.value = day - 1;
- if (點名2按鈕.activeSelf)
- {
- 查找.SetActive(false);
- 點名2.SetActive(true);
- }
- else
- {
- 查找.SetActive(false);
- 點名1.SetActive(true);
- }
- 年下拉.onValueChanged.AddListener(年份改變);
- 月下拉.onValueChanged.AddListener(月份改變);
- 日下拉.onValueChanged.AddListener(日期改變);
- StartCoroutine(點名流水號查詢());
- });
- text.text = json[i][1].ToString().Trim('"');
- sum+=100;
- copy.Add(buttonObj);
- }
- buttonceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter.GetComponent<RectTransform>().sizeDelta.x, sum);
- 讀取面板.SetActive(false);
- }
- 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;
- }
- 簽名檔 = JSON.Parse(request.downloadHandler.text);
- Debug.Log(簽名檔);
- if (啟動==false)
- {
- Debug.Log("有加入");
- 年下拉.onValueChanged.AddListener(年份改變);
- 月下拉.onValueChanged.AddListener(月份改變);
- 日下拉.onValueChanged.AddListener(日期改變);
- 年下拉1.onValueChanged.AddListener(年份改變1);
- 月下拉1.onValueChanged.AddListener(月份改變1);
- }
- StartCoroutine(點名流水號查詢());
- }
- IEnumerator 點名流水號查詢()
- {
-
- 讀取面板.SetActive(true);
- string strcon = "點名流水號查詢";
- string se = Main.Global.預設伺服器路徑;
- string year = 年下拉.options[年下拉.value].text;
- string month = 月下拉.options[月下拉.value].text;
- string day = 日下拉.options[日下拉.value].text;
- string pa = year+"/"+month+"/"+day;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA={2}", strcon,se,pa);
- 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();
- Debug.Log(str);
- string 流水號 = "";
- 工作重點s.text ="";
- 臨時狀況s.text ="";
- 備註內容s.text ="";
- if (str != "n")
- {
- 已點名=true;
- 流水號 = str;
- yield return StartCoroutine(點名明細1(流水號));
- }
- else
- {
- 已點名=false;
- rawImage1.texture = 紅燈.texture;
- rawImage2.texture = 紅燈.texture;
- rawImage3.texture = 紅燈.texture;
- rawImage4.texture = 紅燈.texture;
- }
- yield return StartCoroutine(點名明細(流水號));
-
-
- }
- IEnumerator 點名明細1(string 流水號)
- {
- string strcon = "點名明細1";
- string se = Main.Global.預設伺服器路徑;
- string pa = 流水號;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}", strcon, se, pa);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- 控制表=JSON.Parse(request.downloadHandler.text);
- 工作重點s.text =控制表[2].ToString().Trim('"');
- 臨時狀況s.text =控制表[3].ToString().Trim('"');
- 備註內容s.text =控制表[4].ToString().Trim('"');
- bool 已點名;
- bool 廠長已點名;
- bool 副總已點名;
- bool 總經理已點名;
- if (控制表[11]!= null && 控制表[11].ToString().Trim('"')!= "")
- {
- 已點名=true;
- rawImage1.texture = 綠燈.texture;
- }
- else
- {
- 已點名=false;
- rawImage1.texture = 紅燈.texture;
- }
- if (控制表[9]!= null && 控制表[9].ToString().Trim('"')!= "")
- {
- 廠長已點名=true;
- rawImage2.texture = 綠燈.texture;
- }
- else
- {
- 廠長已點名=false;
- rawImage2.texture = 紅燈.texture;
- }
- if (控制表[7]!= null && 控制表[7].ToString().Trim('"')!= "")
- {
- rawImage3.texture = 綠燈.texture;
- 副總已點名=true;
- }
- else
- {
- 副總已點名=false;
- rawImage3.texture = 紅燈.texture;
- }
- if (控制表[5]!= null && 控制表[5].ToString().Trim('"')!= "")
- {
- rawImage4.texture = 綠燈.texture;
- 總經理已點名=true;
- }
- else
- {
- 總經理已點名=false;
- rawImage4.texture = 紅燈.texture;
- }
- 讀取面板.SetActive(false);
-
- }
- IEnumerator 點名明細(string pa)
- {
- if (copy1 != null)
- {
- DeletetextCopies1();
- }
- string strcon = "點名明細";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA={2}", strcon, se, pa);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- 點名清單 = JSON.Parse(request.downloadHandler.text);
- Debug.Log(點名清單);
- int sum = 0;
- for (int i = 0; i < 點名清單.Count; i++)
- {
- GameObject buttonObj = Instantiate(buttonPrefab1) as GameObject;
- buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(5, -sum);
- buttonObj.transform.SetParent(buttonParent1, false);
- TextMeshProUGUI[] texts = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
- Toggle tg = buttonObj.GetComponentInChildren<Toggle>();
- Button[] bts = buttonObj.GetComponentsInChildren<Button>();
- texts[0].text = 點名清單[i][1].ToString().Trim('"');
- if (點名清單[i][0] == null)
- {
- 點名清單[i][0]=pa;
- }
- if (點名清單[i][2] == null)
- {
- 點名清單[i][2]=0;
- }
- if (點名清單[i][3] == null)
- {
- texts[1].text = "";
- 點名清單[i][3]="";
- }
- else
- {
- texts[1].text = 點名清單[i][3].ToString().Trim('"');
- }
-
- if (點名清單[i][2]==1)
- {
- tg.isOn=true;
- }
- else
- {
- tg.isOn=false;
- }
- int index = i;
- bts[0].onClick.AddListener(() =>
- {
- if (點名清單[index][2].ToString().Trim('"')=="0")
- {
- tg.isOn = true;
- 點名清單[index][2] = 1;
- Debug.Log(點名清單);
- }
- else
- {
- tg.isOn = false;
- 點名清單[index][2] = 0;
- Debug.Log(點名清單);
- }
- });
- bts[1].onClick.AddListener(() =>
- {
- 出勤狀況.SetActive(true);
- Button1.onClick.RemoveAllListeners();
- Button2.onClick.RemoveAllListeners();
- Button3.onClick.RemoveAllListeners();
- Button4.onClick.RemoveAllListeners();
- Button5.onClick.RemoveAllListeners();
- Button6.onClick.RemoveAllListeners();
- Button7.onClick.RemoveAllListeners();
- Button8.onClick.RemoveAllListeners();
- Button9.onClick.RemoveAllListeners();
- Button1.onClick.AddListener(() =>
- {
- 點名清單[index][3]="";
- texts[1].text = "";
- 出勤狀況.SetActive(false);
- Debug.Log(點名清單);
- });
- Button2.onClick.AddListener(() =>
- {
- 點名清單[index][3]="事假";
- texts[1].text = "事假";
- 出勤狀況.SetActive(false);
- Debug.Log(點名清單);
- });
- Button3.onClick.AddListener(() =>
- {
- 點名清單[index][3]="病假";
- texts[1].text = "病假";
- 出勤狀況.SetActive(false);
- Debug.Log(點名清單);
- });
- Button4.onClick.AddListener(() =>
- {
- 點名清單[index][3]="外出卸貨";
- texts[1].text = "外出卸貨";
- 出勤狀況.SetActive(false);
- Debug.Log(點名清單);
- });
- Button5.onClick.AddListener(() =>
- {
- 點名清單[index][3]="外出修補";
- texts[1].text = "外出修補";
- 出勤狀況.SetActive(false);
- Debug.Log(點名清單);
- });
- Button6.onClick.AddListener(() =>
- {
- 點名清單[index][3]="支援";
- texts[1].text = "支援";
- 出勤狀況.SetActive(false);
- Debug.Log(點名清單);
- });
- Button7.onClick.AddListener(() =>
- {
- 點名清單[index][3]="探親";
- texts[1].text = "探親";
- 出勤狀況.SetActive(false);
- Debug.Log(點名清單);
- });
- Button8.onClick.AddListener(() =>
- {
- 點名清單[index][3]="合約期滿";
- texts[1].text = "合約期滿";
- 出勤狀況.SetActive(false);
- Debug.Log(點名清單);
- });
- Button9.onClick.AddListener(() =>
- {
- 點名清單[index][3]="解約";
- texts[1].text = "解約";
- 出勤狀況.SetActive(false);
- Debug.Log(點名清單);
- });
- });
- sum+=100;
- copy1.Add(buttonObj);
- }
- buttonceneter1.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter1.GetComponent<RectTransform>().sizeDelta.x, sum);
- 讀取面板.SetActive(false);
- 啟動=true;
- }
- public void DeletetextCopies1()
- {
- // 刪除複製出來的物件
- foreach (GameObject copy in copy1)
- {
- Destroy(copy);
- }
- copy1.Clear();
- }
- public void DeletetextCopies()
- {
- // 刪除複製出來的物件
- foreach (GameObject copy in copy)
- {
- Destroy(copy);
- }
- copy.Clear();
- }
- private void 年份改變(int value)
- {
- 讀取面板.SetActive(true);
- int a = value + 2023;
- int b = 月下拉.value + 1;
- UpdateDayDropdown(a, b);
- StartCoroutine(點名流水號查詢());
- }
- private void 月份改變(int value)
- {
- 讀取面板.SetActive(true);
- int a = 年下拉.value + 2023;
- int b = value + 1;
- UpdateDayDropdown(a, b);
- StartCoroutine(點名流水號查詢());
- }
- private void 年份改變1(int value)
- {
- 讀取面板.SetActive(true);
- int a = value + 2023;
- int b = 月下拉.value + 1;
- StartCoroutine(點名主表(a.ToString(), b.ToString()));
- }
- private void 月份改變1(int value)
- {
- 讀取面板.SetActive(true);
- int a = 年下拉.value + 2023;
- int b = value + 1;
- StartCoroutine(點名主表(a.ToString(), b.ToString()));
- }
- private void 日期改變(int value)
- {
- 讀取面板.SetActive(true);
- StartCoroutine(點名流水號查詢());
- }
- public void 查找按鈕()
- {
- if (點名2按鈕.activeSelf)
- {
- 查找.SetActive(!查找.activeSelf);
- 點名2.SetActive(!點名2.activeSelf);
- }
- else
- {
- 查找.SetActive(!查找.activeSelf);
- 點名1.SetActive(!點名1.activeSelf);
- }
-
- }
-
- public void 備註()
- {
- 點名1.SetActive(false);
- 點名2.SetActive(true);
- 點名1按鈕.SetActive(false);
- 點名2按鈕.SetActive(true);
-
- }
- public void 點名()
- {
- 點名2.SetActive(false);
- 點名1.SetActive(true);
- 點名2按鈕.SetActive(false);
- 點名1按鈕.SetActive(true);
- }
- public void 存檔()
- {
- 讀取面板.SetActive(true);
- StartCoroutine(點名查找當日日期());
-
- }
- IEnumerator 點名查找當日日期()
- {
- string strcon = "點名查找當日日期";
- string se = Main.Global.預設伺服器路徑;
- string year = 年下拉.options[年下拉.value].text;
- string month = 月下拉.options[月下拉.value].text;
- string day = 日下拉.options[日下拉.value].text;
- string pa = year+"/"+month+"/"+day;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA={2}", strcon, se, pa);
- 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 == "無")
- {
- string wa = Main.Global.人員;
- string 序號 = "";
- for (int j = 0; j < 簽名檔.Count; j++)
- {
- Debug.Log(wa);
- string wa1 = 簽名檔[j][1].ToString().Trim('"');
- if (wa==wa1)
- {
- 序號 =簽名檔[j][0].ToString().Trim('"');
- }
- }
- yield return StartCoroutine(查找點名最後一筆流水號(序號));
- }
- else
- {
- StartCoroutine(修改點名控制表資料());
- }
- }
- IEnumerator 查找點名最後一筆流水號(string 序號)
- {
- 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 num = request.downloadHandler.text.ToString();
- string 流水號 = "GS";
- if (num == "n")
- {
- 流水號 +="00000000";
- }
- else
- {
- string cnum = num.Substring(2);
- int inum = int.Parse(cnum);
- inum+=1;
- if (inum<10)
- {
- 流水號+="0000000"+inum.ToString();
- }
- if (inum>9 && inum<100)
- {
- 流水號+="000000"+inum.ToString();
- }
- if (inum>99 && inum<1000)
- {
- 流水號+="00000"+inum.ToString();
- }
- if (inum>999 && inum<10000)
- {
- 流水號+="0000"+inum.ToString();
- }
- if (inum>9999 && inum<100000)
- {
- 流水號+="000"+inum.ToString();
- }
- if (inum>99999 && inum<10000000)
- {
- 流水號+="00"+inum.ToString();
- }
- if (inum>999999 && inum<10000000)
- {
- 流水號+="0"+inum.ToString();
- }
- if (inum>9999999 && inum<100000000)
- {
- 流水號+=inum.ToString();
- }
- StartCoroutine(新增點名控制表資料(流水號, 序號));
- }
- }
- IEnumerator 新增點名控制表資料(string 流水號, string 序號)
- {
- string strcon = "新增點名控制表資料";
- string se = Main.Global.預設伺服器路徑;
- string pa1 = 流水號;
- string year1 = 年下拉.options[年下拉.value].text;
- string month1 = 月下拉.options[月下拉.value].text;
- string day = 日下拉.options[日下拉.value].text;
- string pa2 = year1+"/"+month1+"/"+day;
- //string pa2 = DateTime.Now.ToString("yyyy/MM/dd");
- string pa3 = 工作重點s.text;
- string pa4 = 臨時狀況s.text;
- string pa5 = 備註內容s.text;
- string pa6 = 序號;
- string pa7 = DateTime.Now.ToString("yyyy/MM/dd");
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}&PA5={6}&PA6={7}&PA7={8}"
- , strcon, se, pa1, pa2, pa3, pa4, pa5, pa6, pa7);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
-
- for (int i = 0; i < 點名清單.Count; i++)
- {
- string a2 = 點名清單[i][4].ToString().Trim('"');
- int b3 = 點名清單[i][2];
- string a4 = 點名清單[i][3].ToString().Trim('"');
- yield return StartCoroutine(新增點名明細表資料(流水號, a2, b3, a4));
- if (i == 點名清單.Count-1)
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "新增成功";
- string year = 年下拉.options[年下拉.value].text;
- string month = 月下拉.options[月下拉.value].text;
- 年下拉1.value = 年下拉.value;
- 月下拉1.value = 月下拉.value;
- yield return StartCoroutine(點名主表(year, month));
- yield return StartCoroutine(點名流水號查詢());
- //讀取面板.SetActive(false);
- }
- }
- }
- IEnumerator 新增點名明細表資料(string 流水號, string 帳號, int 點名狀況, string 出勤狀態)
- {
- string strcon = "新增點名明細表資料";
- string se = Main.Global.預設伺服器路徑;
- string pa1 = 流水號;
- string pa2 = 帳號;
- int pa3 = 點名狀況;
- string pa4 = 出勤狀態;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}"
- , strcon, se, pa1, pa2, pa3, pa4);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- }
- IEnumerator 修改點名控制表資料()
- {
- string strcon = "修改點名控制表資料";
- string se = Main.Global.預設伺服器路徑;
- string pa1 = 工作重點s.text;
- string pa2 = 臨時狀況s.text;
- string pa3 = 備註內容s.text;
- string year = 年下拉.options[年下拉.value].text;
- string month = 月下拉.options[月下拉.value].text;
- string day = 日下拉.options[日下拉.value].text;
- string pa4 = year+"/"+month+"/"+day;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}"
- , strcon, se, pa1, pa2, pa3, pa4);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- for (int i = 0; i < 點名清單.Count; i++)
- {
- string 流水號 = 點名清單[i][0].ToString().Trim('"');
- string a2 = 點名清單[i][4].ToString().Trim('"');
- int b3 = 點名清單[i][2];
- string a4 = 點名清單[i][3].ToString().Trim('"');
- yield return StartCoroutine(修改點名明細表資料(流水號, a2, b3, a4));
- if (i == 點名清單.Count-1)
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "修改成功";
- StartCoroutine(點名流水號查詢());
- 讀取面板.SetActive(false);
- }
- }
- }
- IEnumerator 修改點名明細表資料(string 流水號, string 帳號, int 點名狀況, string 出勤狀態)
- {
- string strcon = "修改點名明細表資料";
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}"
- , strcon, se, 點名狀況, 出勤狀態, 帳號, 流水號);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- }
- public void 彈跳面板關閉()
- {
- 彈跳面板.SetActive(false);
- 彈跳文字.text = "";
- }
-
- public void 審核()
- {
- if (已點名==true)
- {
- string wa = Main.Global.人員;
- string 序號 = "";
- for (int j = 0; j < 簽名檔.Count; j++)
- {
- string wa1 = 簽名檔[j][1].ToString().Trim('"');
- if (wa==wa1)
- {
- 序號 =簽名檔[j][0].ToString().Trim('"');
- }
- }
- if (Main.Global.級別 == "00" && Main.Global.職稱 == "00000.NA")
- {
- StartCoroutine(修改點名控制表簽名());
- }
- else if(Main.Global.級別 == "01" && Main.Global.職稱 == "00002.總經理")
- {
- if (rawImage2.texture == 紅燈.texture)
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "廠長尚未確認,單據無法簽核!";
- }
- else if (rawImage3.texture == 紅燈.texture)
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "副總尚未確認,單據無法簽核!";
- }
- else
- {
- StartCoroutine(修改點名控制表簽名總(序號));
- }
-
- }
- else if (Main.Global.級別 == "02" && Main.Global.職稱 == "00003.副總經理")
- {
- if (rawImage2.texture == 紅燈.texture)
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "廠長尚未確認,單據無法簽核!";
- }
- else
- {
- StartCoroutine(修改點名控制表簽名副(序號));
- }
- }
- else if (Main.Global.級別 == "03" && Main.Global.職稱 == "31001.廠務部廠長")
- {
-
- StartCoroutine(修改點名控制表簽名廠(序號));
-
-
- }
- else
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "簽核權限錯誤!";
- }
- }
- else
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "點名單據尚未建立,無法簽核!";
- }
- }
- IEnumerator 修改點名控制表簽名副(string 序號)
- {
- string strcon = "修改點名控制表簽名副";
- string se = Main.Global.預設伺服器路徑;
- string pa2 = DateTime.Now.ToString("yyyy/MM/dd"); ;
- string year = 年下拉.options[年下拉.value].text;
- string month = 月下拉.options[月下拉.value].text;
- string day = 日下拉.options[日下拉.value].text;
- string pa3 = year+"/"+month+"/"+day;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}"
- , strcon, se, 序號, pa2, pa3);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "簽核成功!";
- StartCoroutine(點名流水號查詢());
- }
- IEnumerator 修改點名控制表簽名廠(string 序號)
- {
- string strcon = "修改點名控制表簽名廠";
- string se = Main.Global.預設伺服器路徑;
- string pa2 = DateTime.Now.ToString("yyyy/MM/dd"); ;
- string year = 年下拉.options[年下拉.value].text;
- string month = 月下拉.options[月下拉.value].text;
- string day = 日下拉.options[日下拉.value].text;
- string pa3 = year+"/"+month+"/"+day;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}"
- , strcon, se, 序號, pa2, pa3);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "簽核成功!";
- StartCoroutine(點名流水號查詢());
- }
- IEnumerator 修改點名控制表簽名總(string 序號)
- {
- string strcon = "修改點名控制表簽名總";
- string se = Main.Global.預設伺服器路徑;
- string pa2 = DateTime.Now.ToString("yyyy/MM/dd"); ;
- string year = 年下拉.options[年下拉.value].text;
- string month = 月下拉.options[月下拉.value].text;
- string day = 日下拉.options[日下拉.value].text;
- string pa3 = year+"/"+month+"/"+day;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}"
- , strcon, se, 序號, pa2, pa3);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "簽核成功!";
- StartCoroutine(點名流水號查詢());
- }
- IEnumerator 修改點名控制表簽名()
- {
- string strcon = "修改點名控制表簽名";
- string se = Main.Global.預設伺服器路徑;
- string date = DateTime.Now.ToString("yyyy/MM/dd"); ;
- string year = 年下拉.options[年下拉.value].text;
- string month = 月下拉.options[月下拉.value].text;
- string day = 日下拉.options[日下拉.value].text;
- string pa3 = year+"/"+month+"/"+day;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA2={3}&PA3={4}&PA4={5}&PA5={6}&PA6={7}&PA7={8}"
- , strcon, se,"PG00000001", date,"PG00000002", date,"PG00000003", date,pa3);
- Debug.Log(strUrl);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request.error);
- yield break;
- }
- 彈跳面板.SetActive(true);
- 彈跳文字.text = "簽核成功!";
- StartCoroutine(點名流水號查詢());
- }
- public void back()
- {
- change_Secen(1);
- }
- public void change_Secen(int _screenNum)
- {
-
- SceneManager.LoadScene(_screenNum);
- }
- public void 截圖()
- {
- string fileName = string.Format("{0}/screenshot_{1}.png", Application.persistentDataPath, System.DateTime.Now.ToString("yyyyMMdd_HHmmss"));
- ScreenCapture.CaptureScreenshot(fileName);
- }
- }
|