1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.UI;
- using UnityEngine.Networking;
- using UnityEngine.EventSystems;
- using System.Text.RegularExpressions;
- using System.Data.SqlClient;
- using System.Runtime.InteropServices;
- using System.Text;
- using TMPro;
- using System;
- using System.IO;
- using ZXing;
- using ZXing.QrCode;
- using System.Net;
- using System.Data;
- using SimpleJSON;
- using System.Linq;
-
- public class yawoo : MonoBehaviour
- {
- [SerializeField] GameObject 彈跳面板;
- [SerializeField] TextMeshProUGUI 彈跳文字;
- [SerializeField] Button 彈跳叉;
- [SerializeField] Button 是;
- [SerializeField] Button 否;
-
- [SerializeField] TextMeshProUGUI 標題;
-
- [SerializeField] TextMeshProUGUI 未折價前;
- [SerializeField] TextMeshProUGUI 報價小計;
- [SerializeField] TextMeshProUGUI 預估工資總成本;
- [SerializeField] TextMeshProUGUI 預估材料總成本;
- [SerializeField] TextMeshProUGUI 總成本;
- [SerializeField] TextMeshProUGUI 預估工資總報價;
- [SerializeField] TextMeshProUGUI 預估材料總報價;
- [SerializeField] TextMeshProUGUI 總報價;
- [SerializeField] TextMeshProUGUI 利潤比;
- [SerializeField] TextMeshProUGUI 利潤比1;
- [SerializeField] TextMeshProUGUI 利潤比2;
- [SerializeField] TextMeshProUGUI 利潤比3;
- [SerializeField] TextMeshProUGUI 預估利潤;
- [SerializeField] TextMeshProUGUI 未折價前_錢;
- [SerializeField] TextMeshProUGUI 報價小計_錢;
- [SerializeField] TextMeshProUGUI 預估工資總成本_錢;
- [SerializeField] TextMeshProUGUI 預估材料總成本_錢;
- [SerializeField] TextMeshProUGUI 總成本_錢;
- [SerializeField] TextMeshProUGUI 預估工資總報價_錢;
- [SerializeField] TextMeshProUGUI 預估材料總報價_錢;
- [SerializeField] TextMeshProUGUI 總報價_錢;
- [SerializeField] TextMeshProUGUI 利潤比_錢;
- [SerializeField] TextMeshProUGUI 利潤比1_錢;
- [SerializeField] TextMeshProUGUI 利潤比2_錢;
- [SerializeField] TextMeshProUGUI 利潤比3_錢;
- [SerializeField] TextMeshProUGUI 預估利潤_錢;
- [SerializeField] TextMeshProUGUI 折讓金額;
- [SerializeField] TextMeshProUGUI 總成本1;
- [SerializeField] TextMeshProUGUI 總報價1;
-
- [SerializeField] GameObject 調整係數頁面;
-
- [SerializeField] GameObject 明細下一頁;
- [SerializeField] GameObject 明細上一頁;
-
- [SerializeField] GameObject 下一頁;
- [SerializeField] GameObject 上一頁;
- [SerializeField] GameObject 面板_建立;
- [SerializeField] GameObject 面板_明細;
- [SerializeField] GameObject 面板_利潤;
- [SerializeField] GameObject 面板_利潤表頭;
- [SerializeField] GameObject 報價;
- [SerializeField] GameObject image_row;
- [SerializeField] GameObject 左;
- [SerializeField] GameObject 右;
- [SerializeField] TextMeshProUGUI 合約編號;
- [SerializeField] TextMeshProUGUI 工程名稱;
- [SerializeField] TextMeshProUGUI 客戶名稱;
- [SerializeField] TextMeshProUGUI 負責人;
- [SerializeField] TextMeshProUGUI 工程地點;
- [SerializeField] TextMeshProUGUI 地址;
- [SerializeField] TextMeshProUGUI 公司名稱;
- [SerializeField] TextMeshProUGUI 負責人1;
- [SerializeField] TextMeshProUGUI 地址1;
- [SerializeField] TextMeshProUGUI 合約編號s;
- [SerializeField] TextMeshProUGUI 工程名稱s;
- [SerializeField] TextMeshProUGUI 客戶名稱s;
- [SerializeField] TextMeshProUGUI 負責人s;
- [SerializeField] TextMeshProUGUI 工程地點s;
- [SerializeField] TextMeshProUGUI 地址s;
- [SerializeField] TextMeshProUGUI 公司名稱s;
- [SerializeField] TextMeshProUGUI 負責人1s;
- [SerializeField] TextMeshProUGUI 地址1s;
-
- [SerializeField] GameObject 選擇面板;
- [SerializeField] TextMeshProUGUI 選擇語言;
- [SerializeField] TextMeshProUGUI 中;
- [SerializeField] TextMeshProUGUI 英;
- [SerializeField] TextMeshProUGUI 印;
- [SerializeField] TextMeshProUGUI 簡;
- [SerializeField] Button 中按鈕;
- [SerializeField] Button 英按鈕;
- [SerializeField] Button 印按鈕;
- [SerializeField] Button 簡按鈕;
-
- public CanvasScaler canvasScaler;
- public float idleTime = 300f; // 5分鐘的閒置時間
- private float timeSinceLastInteraction = 0f;
- private float timer = 0f;
- private float interval = 60f;
-
- [SerializeField] GameObject 讀取面板;
- [SerializeField] TextMeshProUGUI 讀取;
- private string loadingText = "";
- private int dotCount = 0;
- private Button[] bts;
- int nd;
- private JSONNode 合約清單;
- private JSONNode 合約內容;
- private JSONNode 報價係數;
- private JSONNode 報價明細;
- private JSONNode 報價內容;
- private JSONArray 調整係數;
- private JSONNode 初始係數;
-
- 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>();
-
- public GameObject buttonPrefab2;
- public Transform buttonParent2;
- public GameObject buttonceneter2;
- private List<GameObject> copy2 = new List<GameObject>();
-
- public GameObject buttonPrefab3;
- public Transform buttonParent3;
- public GameObject buttonceneter3;
- private List<GameObject> copy3 = new List<GameObject>();
-
- private int itemsPerPage = 6;
- private int currentPage = 0;
-
- [SerializeField] GameObject 網頁面板;
- UniWebView webView;
- public GameObject panel;
- float scale = 0;
- float xbar = 0;
- float ybar = 0;
- RectTransform panelRectTransform;
- void Start()
- {
- Screen.autorotateToPortrait = false;
- Screen.orientation = ScreenOrientation.LandscapeLeft;
- float screenWidth = Screen.width;
- float screenHeight = Screen.height;
- float rate = screenWidth/screenHeight;
- if (canvasScaler == null)
- {
- canvasScaler = GetComponent<CanvasScaler>();
- }
- if (rate>1.6)
- {
- canvasScaler.matchWidthOrHeight = 1f;
- }
- else
- {
- canvasScaler.matchWidthOrHeight = 0f;
- }
- if (canvasScaler.matchWidthOrHeight == 0f)
- {
- scale = screenWidth / 1600;
- xbar=0;
- ybar=(screenHeight-(1000*scale))/2;
- }
- else
- {
- scale = screenHeight/ 1000;
- xbar=(screenWidth-(1600*scale))/2;
- ybar=0;
- }
-
- panelRectTransform = panel.GetComponent<RectTransform>();
- StartCoroutine(判斷更新());
- StartCoroutine(AnimateText());
- //Main.Global.阿帕契路徑="http://106.1.48.106:8080/wp-content/themes/event-star/tab.php?";
- //Main.Global.阿帕契路徑="http://103.231.201.230/hxpgsweb/wp-content/themes/twentytwentyone/tab.php?";
- //初始化系統語言();
- //Main.Global.預設伺服器路徑="tw";
- //Main.Global.系統語言="繁體中文";
- 語言選擇按鈕();
- 系統語言轉換();
- 網頁(panelRectTransform, scale, xbar, ybar);
- StartCoroutine(審核清單());
-
- }
- IEnumerator 審核清單()
- {
- 讀取面板.SetActive(true);
- string strcon1 = "審核清單";
- string se = Main.Global.預設伺服器路徑;
- string strUrl1 = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}", strcon1, se);
- UnityWebRequest request1 = UnityWebRequest.Get(strUrl1);
- yield return request1.SendWebRequest();
- if (request1.result == UnityWebRequest.Result.ConnectionError)
- {
- //Debug.Log(request.error);
- yield break;
- }
- 合約清單 = JSON.Parse(request1.downloadHandler.text);
- 合約編號s.text="";
- 客戶名稱s.text="";
- 負責人s.text="";
- 工程地點s.text="";
- 地址s.text="";
- 工程名稱s.text="";
- 公司名稱s.text="";
- 負責人1s.text="";
- 地址1s.text="";
- if (Main.Global.跳轉==true)
- {
- for (int i = 0; i < 合約清單.Count; i++)
- {
- string str = 合約清單[i][0].ToString().Trim('"');
- if (str == Main.Global.跳轉1)
- {
- nd = i;
- break;
- }
- }
- if (nd < 1)
- {
- 左.SetActive(false);
- 右.SetActive(true);
- }
- else if (nd > 合約清單.Count-2)
- {
- 左.SetActive(true);
- 右.SetActive(false);
- }
- else
- {
- 左.SetActive(true);
- 右.SetActive(true);
- }
- }
- else
- {
- nd=0;
- if (合約清單.Count <= 1)
- {
- 左.SetActive(false);
- 右.SetActive(false);
- }
- else
- {
- 左.SetActive(false);
- 右.SetActive(true);
- }
- }
- currentPage=0;
- StartCoroutine(合約內容清單());
-
- }
- IEnumerator 合約內容清單()
- {
- 讀取面板.SetActive(true);
- string strcon = "合約內容";
- string name1 = 合約清單[nd][0].ToString().Trim('"');
- string se = Main.Global.預設伺服器路徑;
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}&字={1}&se={2}", strcon, name1, 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);
-
- 合約編號s.text=合約內容[0];
- 客戶名稱s.text=合約內容[1];
- 負責人s.text=合約內容[2];
- 工程地點s.text=合約內容[3];
- 地址s.text=合約內容[4];
- if (Main.Global.系統語言=="繁體中文" || Main.Global.系統語言=="簡體中文")
- {
- 工程名稱s.text=合約內容[5];
-
- }
- else
- {
- 工程名稱s.text=合約內容[6];
-
- }
- 公司名稱s.text=合約內容[7];
- 負責人1s.text=合約內容[8];
- 地址1s.text=合約內容[9];
- StartCoroutine(合約報價係數());
- }
- IEnumerator 合約報價係數()
- {
- string strcon3 = "合約報價係數";
- string se = Main.Global.預設伺服器路徑;
- string num = 合約清單[nd][0].ToString().Trim('"');
- string strUrl3 = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&編號={2}", strcon3, se, num);
- UnityWebRequest request3 = UnityWebRequest.Get(strUrl3);
- yield return request3.SendWebRequest();
- if (request3.result == UnityWebRequest.Result.ConnectionError)
- {
- //Debug.Log(request.error);
- yield break;
- }
- 報價係數 = JSON.Parse(request3.downloadHandler.text);
- 初始係數 = JSON.Parse(request3.downloadHandler.text);
- StartCoroutine(報價內容清單());
- }
- IEnumerator 報價內容清單()
- {
- string strcon1 = "報價內容";
- string se = Main.Global.預設伺服器路徑;
- //string se = "id";
- string num = 合約清單[nd][0].ToString().Trim('"');
- string strUrl1 = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&編號={2}", strcon1, se, num);
- UnityWebRequest request1 = UnityWebRequest.Get(strUrl1);
- yield return request1.SendWebRequest();
- if (request1.result == UnityWebRequest.Result.ConnectionError)
- {
- //Debug.Log(request.error);
- yield break;
- }
- 報價內容 = JSON.Parse(request1.downloadHandler.text);
-
- StartCoroutine(報價明細清單());
- }
- IEnumerator 報價明細清單()
- {
- string strcon1 = "報價明細";
- string se = Main.Global.預設伺服器路徑;
- string lan = Main.Global.系統語言;
- string num = 合約清單[nd][0].ToString().Trim('"');
- string strUrl1 = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&編號={2}&語言={3}", strcon1, se, num,lan);
- UnityWebRequest request1 = UnityWebRequest.Get(strUrl1);
- yield return request1.SendWebRequest();
- if (request1.result == UnityWebRequest.Result.ConnectionError)
- {
- //Debug.Log(request.error);
- yield break;
- }
- 報價明細 = JSON.Parse(request1.downloadHandler.text);
- 調整係數 = new JSONArray();
- HashSet<string> addedItems = new HashSet<string>();
- for (int i = 0; i < 報價係數.Count; i++)
- {
- for (int j = 0; j < 報價明細.Count; j++)
- {
- string str = 報價係數[i][2].ToString().Trim('"');
- if (str==報價明細[j][32].ToString().Trim('"') || str==報價明細[j][60].ToString().Trim('"') || str==報價明細[j][61].ToString().Trim('"'))
- {
- if (addedItems.Add(str))
- {
- JSONNode newValue = new JSONObject();
- newValue["項目"] = str;
- newValue["係數"] = 報價係數[i][3].ToString().Trim('"');
- newValue["單位"] = 報價係數[i][4].ToString().Trim('"');
- 調整係數.Add(newValue);
- }
- }
- }
- }
- if (copy != null)
- {
- DeleteCopies(copy);
- }
- int sum = 2;
-
- for (int i = 0; i < 調整係數.Count; i++)
- {
- GameObject buttonObj = Instantiate(buttonPrefab) as GameObject;
- buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, -sum);
- buttonObj.transform.SetParent(buttonParent, false);
- TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
- TMP_InputField intext = buttonObj.GetComponentInChildren<TMP_InputField>();
- text[0].text =調整係數[i][0].ToString().Trim('"');
- text[2].text =調整係數[i][2].ToString().Trim('"');
- int index = i;
- intext.text =double.Parse(調整係數[i][1]).ToString("#.####");
- intext.onSubmit.AddListener((inputText) =>
- {
- 讀取面板.SetActive(true);
- for (int i = 0; i < 報價係數.Count; i++)
- {
- if (調整係數[index][0] == 報價係數[i][2])
- {
- 報價係數[i][3] =inputText;
- }
- }
- 明細自動計算();
- 總表自動計算();
- 讀取面板.SetActive(false);
- });
- sum+=50;
- copy.Add(buttonObj);
- }
- buttonceneter.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter.GetComponent<RectTransform>().sizeDelta.x, sum);
- 明細自動計算();
- 總表自動計算();
- 讀取面板.SetActive(false);
- }
- private void 明細自動計算()
- {
- double 合計 = 0;
- double 利潤 = 0;
- double 工資係數 = 0;
- double 工資成本 = 0;
- double 工資利潤 = 0;
- double 材料係數 = 0;
- double 材基係數 = 0;
- double 材料成本 = 0;
- double 材料利潤 = 0;
- for (int i = 0; i < 報價係數.Count; i++)
- {
- if (報價係數[i][2].ToString().Trim('"') == "工資利潤")
- {
- 工資係數 = double.Parse(報價係數[i][3]);
- }
-
- if (報價係數[i][2].ToString().Trim('"') == "材料係數")
- {
- 材基係數 = double.Parse(報價係數[i][3]);
- break;
- }
- }
- for (int i = 0; i < 報價明細.Count; i++)
- {
- 報價明細[i][4]=報價明細[i][8];
-
- for (int ii= 0; ii < 報價係數.Count; ii++)
- {
- if(報價係數[ii][2]==報價明細[i][61] && 報價係數[ii][4].ToString().Trim('"') == "RP")
- {
- 報價明細[i][9]=報價係數[ii][3];
- break;
- }
- }
- double 數量 = double.Parse(報價明細[i][8]);
- double 成本單價 = double.Parse(報價明細[i][9]);
- 報價明細[i][10]=(數量*成本單價).ToString();
- if (報價明細[i][33] == 0)
- {
- if (報價明細[i][60] == "")
- {
- 報價明細[i][11] = (成本單價 * 工資係數 / 100).ToString();
- }
- else
- {
- for (int ii = 0; ii < 報價係數.Count; ii++)
- {
- if(報價明細[i][60]==報價係數[ii][2] && 報價係數[ii][4].ToString().Trim('"') == "%")
- {
- double 係數 = double.Parse(報價係數[ii][3]);
- 報價明細[i][11]=(成本單價 * 係數 / 100).ToString();
- }
- else if (報價明細[i][60]==報價係數[ii][2] && 報價係數[ii][4].ToString().Trim('"') == "RP")
- {
- 報價明細[i][11] = (成本單價 * 工資係數 / 100).ToString();
- }
- }
- }
- }
- else
- {
- 報價明細[i][11]="0";
- }
- double 工資報價單價 = double.Parse(報價明細[i][11]);
- 報價明細[i][12]=(工資報價單價*數量).ToString();
-
- for (int ii = 0; ii < 報價係數.Count; ii++)
- {
- if (報價係數[ii][2]==報價明細[i][32] && 報價係數[ii][4].ToString().Trim('"') == "RP")
- {
- 報價明細[i][13]=報價係數[ii][3];
- break;
- }
- }
- double 材料成本單價 = double.Parse(報價明細[i][13]);
- 報價明細[i][14]= (數量*材料成本單價).ToString();
-
- if (報價明細[i][32].ToString().Trim('"') == "")
- {
- 材料係數 = 100;
- }
- else
- {
- for (int ii = 0; ii < 報價係數.Count; ii++)
- {
- if (報價明細[i][32]==報價係數[ii][2] && 報價係數[ii][4].ToString().Trim('"') == "%")
- {
- double 係數 = double.Parse(報價係數[ii][3]);
-
- 材料係數=報價係數[ii][3];
- break;
- }
- else if (報價明細[i][32]==報價係數[ii][2] && 報價係數[ii][4].ToString().Trim('"') == "RP")
- {
- 材料係數=材基係數;
- }
- }
- }
-
- if (報價明細[i][33] == 0)
- {
- 報價明細[i][15] = (材料成本單價 * 材料係數 / 100).ToString();
- }
- else
- {
- 報價明細[i][15]="0";
- }
- double 材料報價單價 = double.Parse(報價明細[i][15]);
- 報價明細[i][16]=(材料報價單價*數量).ToString();
-
- double 工資報價後價 = double.Parse(報價明細[i][12]);
- double 材料報價後價 = double.Parse(報價明細[i][16]);
- double 材料成本後價 = double.Parse(報價明細[i][14]);
- double 工資成本後價 = double.Parse(報價明細[i][10]);
- 報價明細[i][17]=(材料報價後價+工資報價後價-材料成本後價-工資成本後價).ToString();
-
- if (報價明細[i][33] == 0)
- {
- 報價明細[i][5] =(工資報價單價+材料報價單價).ToString();
- 報價明細[i][6] =((工資報價單價+材料報價單價)*數量).ToString();
- }
- else
- {
- 報價明細[i][5] ="0";
- 報價明細[i][6] ="0";
- }
- double AMOUNT = double.Parse(報價明細[i][6]);
- double 表利潤 = double.Parse(報價明細[i][17]);
- if (報價明細[i][1].ToString().Trim('"') != "*")
- {
- 合計+=AMOUNT;
- 利潤+=表利潤;
- 工資成本+=工資成本後價;
- 工資利潤+=工資報價後價;
- 材料成本+=材料成本後價;
- 材料利潤+=材料報價後價;
- }
- if (報價明細[i][1].ToString().Trim('"') == "*")
- {
- 報價明細[i][6]=合計.ToString();
- 合計=0;
- 報價明細[i][17]=利潤.ToString();
- 利潤=0;
- 報價明細[i][10]=工資成本.ToString();
- 工資成本=0;
- 報價明細[i][12]=工資利潤.ToString();
- 工資利潤=0;
- 報價明細[i][14]=材料成本.ToString();
- 材料成本=0;
- 報價明細[i][16]=材料利潤.ToString();
- 材料利潤=0;
- }
-
- }
- 工資成本 = 0;
- 材料成本 = 0;
- 工資利潤 = 0;
- 材料利潤 = 0;
- for (int i = 0; i < 報價明細.Count; i++)
- {
- if (報價明細[i][1].ToString().Trim('"') == "*")
- {
- double 工資報價後價 = double.Parse(報價明細[i][12]);
- double 材料報價後價 = double.Parse(報價明細[i][16]);
- double 材料成本後價 = double.Parse(報價明細[i][14]);
- double 工資成本後價 = double.Parse(報價明細[i][10]);
- 工資成本+=工資成本後價;
- 工資利潤+=工資報價後價;
- 材料成本+=材料成本後價;
- 材料利潤+=材料報價後價;
- }
- }
-
- double 折讓 = 0;
-
- for (int i = 0; i < 報價內容.Count; i++)
- {
- if (報價內容[i][2].ToString().Trim('"')=="折讓 Discount")
- {
- 折讓+=double.Parse(報價內容[i][6]);
- }
- }
-
-
- long doci = (long)Math.Round(工資成本);
- long doci1 = (long)Math.Round(材料成本);
- long doci2 = (long)Math.Round(工資利潤);
- long doci3 = (long)Math.Round(材料利潤);
- long 折讓1 = (long)Math.Round(折讓);
- double rate = 1-(工資成本/工資利潤);
- rate= rate*100;
- double rate1 = 1-(材料成本/材料利潤);
- rate1= rate1*100;
- double rate2 = 1-((工資成本+材料成本)/(工資利潤+材料利潤));
- rate2= rate2*100;
- double rate3 = 1-((工資成本+材料成本)/(工資利潤+材料利潤+折讓));
- rate3= rate3*100;
- if (double.IsNaN(rate))
- {
- rate=0;
- }
- if (double.IsNaN(rate1))
- {
- rate1=0;
- }
- if (double.IsNaN(rate2))
- {
- rate2=0;
- }
- if (double.IsNaN(rate3))
- {
- rate3=0;
- }
- 利潤比_錢.text=((int)Math.Round(rate)).ToString()+"%";
- 利潤比1_錢.text=((int)Math.Round(rate1)).ToString()+"%";
- 利潤比2_錢.text=((int)Math.Round(rate2)).ToString()+"%";
- 利潤比3_錢.text=((int)Math.Round(rate3)).ToString()+"%";
- 預估工資總成本_錢.text=doci.ToString("#,##0");
- 預估材料總成本_錢.text=doci1.ToString("#,##0");
- 總成本_錢.text=(doci+doci1).ToString("#,##0");
- 預估工資總報價_錢.text=doci2.ToString("#,##0");
- 預估材料總報價_錢.text=doci3.ToString("#,##0");
- 總報價_錢.text=(doci2+doci3).ToString("#,##0");
- 預估利潤_錢.text=((doci2+doci3)-((doci+doci1)-折讓1)).ToString("#,##0");
- 明細圖表();
- }
- private void 明細圖表()
- {
- int startIndex = currentPage * itemsPerPage;
- int endIndex = Mathf.Min((currentPage + 1) * itemsPerPage, 報價明細.Count);
- if (copy1 != null)
- {
- DeleteCopies(copy1);
- }
-
- int sum = 2;
- for (int i = startIndex; i < endIndex; i++)
- {
- GameObject buttonObj = Instantiate(buttonPrefab1) as GameObject;
- buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, -sum);
- buttonObj.transform.SetParent(buttonParent1, false);
- TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
- text[0].text =報價明細[i][1].ToString().Trim('"');
- string jsonString = 報價明細[i][2].ToString().Trim('"');
- string unescapedString = Regex.Unescape(jsonString);
- text[1].text =unescapedString;
- text[2].text =報價明細[i][3].ToString().Trim('"');
- SetTextValue(text[3], 報價明細[i][4], true);
- SetTextValue(text[4], 報價明細[i][5], true);
- SetTextValue(text[5], 報價明細[i][6], true);
- text[6].text =報價明細[i][7].ToString().Trim('"');
- SetTextValue1(text[7], 報價明細[i][32]);
- SetTextValue1(text[8], 報價明細[i][60]);
- SetTextValue1(text[9], 報價明細[i][61]);
-
- sum+=100;
- copy1.Add(buttonObj);
- }
- buttonceneter1.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter1.GetComponent<RectTransform>().sizeDelta.x, sum);
-
- if (copy2 != null)
- {
- DeleteCopies(copy2);
- }
- int sum1 = 2;
- for (int i = startIndex; i < endIndex; i++)
- {
- GameObject buttonObj = Instantiate(buttonPrefab2) as GameObject;
- buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, -sum1);
- buttonObj.transform.SetParent(buttonParent2, false);
- TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
- text[0].text =報價明細[i][1].ToString().Trim('"');
- string jsonString = 報價明細[i][2].ToString().Trim('"');
- string unescapedString = Regex.Unescape(jsonString);
- text[1].text =unescapedString;
- double parsedValue = double.Parse(報價明細[i][8]);
- text[2].text = parsedValue.ToString("#,##0.00");
- SetTextValue(text[3], 報價明細[i][9], false);
- SetTextValue(text[4], 報價明細[i][10], false);
- SetTextValue(text[5], 報價明細[i][11], false);
- SetTextValue(text[6], 報價明細[i][12], false);
- SetTextValue(text[7], 報價明細[i][13], false);
- SetTextValue(text[8], 報價明細[i][14], false);
- SetTextValue(text[9], 報價明細[i][15], false);
- SetTextValue(text[10], 報價明細[i][16], false);
- SetTextValue(text[11], 報價明細[i][17], false);
- sum1+=100;
- copy2.Add(buttonObj);
- }
- buttonceneter2.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter2.GetComponent<RectTransform>().sizeDelta.x, sum1);
- }
- public void 下一頁s()
- {
- ChangePage(1);
- }
- public void 上一頁s()
- {
- ChangePage(-1);
- }
- private void ChangePage(int offset)
- {
- currentPage = Mathf.Clamp(currentPage + offset, 0, Mathf.CeilToInt((float)報價明細.Count / itemsPerPage) - 1);
- // 调用刷新页面的方法
- 明細圖表();
- }
- private void SetTextValue(TextMeshProUGUI text, string value ,bool 判斷)
- {
- if (判斷 == true)
- {
- if (value.Trim('"') == "0")
- {
- text.text = "";
- }
- else
- {
- double parsedValue = double.Parse(value);
- long roundedValue = (long)Math.Round(parsedValue);
- text.text = roundedValue.ToString("#,##0");
- }
- }
- else
- {
- double parsedValue = double.Parse(value);
- long roundedValue = (long)Math.Round(parsedValue);
- text.text = roundedValue.ToString("#,##0");
- }
- }
- private void SetTextValue1(TextMeshProUGUI text, string value)
- {
- if (string.IsNullOrEmpty(value))
- {
- text.text="";
- }
- else
- {
- for (int ii = 0; ii < 報價係數.Count; ii++)
- {
- if (value==報價係數[ii][2] && 報價係數[ii][4].ToString().Trim('"') == "%")
- {
- double 係數 = double.Parse(報價係數[ii][3]);
- text.text =(係數-100).ToString() +" %";
- }
- else if (value==報價係數[ii][2] && 報價係數[ii][4].ToString().Trim('"') == "RP")
- {
- double 係數 = double.Parse(報價係數[ii][3]);
- text.text =係數.ToString() +" RP";
- }
- }
- }
- }
-
- private void 總表自動計算()
- {
- for (int i = 0; i < 報價內容.Count; i++)
- {
- string trimmedString = 報價內容[i][2].ToString().Trim('"');
- if (trimmedString.Length >= 2)
- {
- if (報價內容[i][2].ToString().Trim('"').Substring(0, 2) == "管理")
- {
- 報價內容[i][1] = "^";
- }
- if (報價內容[i][2].ToString().Trim('"').Substring(0, 2) == "稅金")
- {
- 報價內容[i][1] = "*";
- }
- if (報價內容[i][2].ToString().Trim('"').Substring(0, 2) == "小計")
- {
- 報價內容[i][1] = "$";
- }
- if (報價內容[i][2].ToString().Trim('"').Substring(0, 2) == "總計")
- {
- 報價內容[i][1] = "@";
- }
- if (報價內容[i][2].ToString().Trim('"').Substring(0, 2) == "折讓")
- {
- 報價內容[i][1] = "#";
- }
- }
-
- if (報價內容[i][8].ToString().Trim('"') != "")
- {
- for (int ii = 0; ii < 報價明細.Count; ii++)
- {
- if (報價內容[i][8] == 報價明細[ii][18])
- {
- 報價內容[i][5] = 報價明細[ii][6];
- break;
- }
- }
- }
- }
- double 合計 = 0;
- double 合計無管 = 0;
- double 稅金 = 0;
- for (int i = 0; i < 報價內容.Count; i++)
- {
- if (報價內容[i][1].ToString().Trim('"') == "*" ||
- 報價內容[i][1].ToString().Trim('"') == "" ||
- 報價內容[i][1].ToString().Trim('"') == "@" ||
- 報價內容[i][1].ToString().Trim('"') == "^" ||
- 報價內容[i][1].ToString().Trim('"') == "$")
- {
- // Do nothing
- }
- else
- {
- if (DBNull.Value.Equals(報價內容[i][4]))
- {
- 報價內容[i][4] = "0";
- }
- if (DBNull.Value.Equals(報價內容[i][5]))
- {
- 報價內容[i][5] = "0";
- }
- double qty = double.Parse(報價內容[i][4]);
- double price = double.Parse(報價內容[i][5]);
- 報價內容[i][6]=(qty*price).ToString();
- }
- if (報價內容[i][1].ToString().Trim('"') != "*" &&
- 報價內容[i][1].ToString().Trim('"') != "" &&
- 報價內容[i][1].ToString().Trim('"') != "@" &&
- 報價內容[i][1].ToString().Trim('"') != "^" &&
- 報價內容[i][2].ToString().Trim('"') != "折讓 Discount")
- {
- double amount = double.Parse(報價內容[i][6]);
- 合計無管 +=amount;
- }
-
- string description = 報價內容[i][2].ToString().Trim('"');
- if (description == "管理費 0%")
- {
- 報價內容[i][6] = (合計無管 * 0).ToString();
- }
- else if (description == "管理費 1%")
- {
- 報價內容[i][6] = (合計無管 * 0.01).ToString();
- }
- else if (description == "管理費 2%")
- {
- 報價內容[i][6] = (合計無管 * 0.02).ToString();
- }
- else if (description == "管理費 3%")
- {
- 報價內容[i][6] = (合計無管 * 0.03).ToString();
- }
- else if (description == "管理費 4%")
- {
- 報價內容[i][6] = (合計無管 * 0.04).ToString();
- }
- else if (description == "管理費 5%")
- {
- 報價內容[i][6] = (合計無管 * 0.05).ToString();
- }
- else if (description == "管理費 6%")
- {
- 報價內容[i][6] = (合計無管 * 0.06).ToString();
- }
- else if (description == "管理費 7%")
- {
- 報價內容[i][6] = (合計無管 * 0.07).ToString();
- }
- else if (description == "管理費 8%")
- {
- 報價內容[i][6] = (合計無管 * 0.08).ToString();
- }
- else if (description == "管理費 9%")
- {
- 報價內容[i][6] = (合計無管 * 0.09).ToString();
- }
- else if (description == "管理費 10%")
- {
- 報價內容[i][6] = (合計無管 * 0.1).ToString();
- }
- if (報價內容[i][1].ToString().Trim('"') != "*" &&
- 報價內容[i][1].ToString().Trim('"') != "$" &&
- 報價內容[i][1].ToString().Trim('"') != "@")
- {
- double amount = double.Parse(報價內容[i][6]);
- 合計 +=amount;
- }
- if (報價內容[i][2].ToString().Trim('"') == "小計(未稅) Subtotal(Excluding Tax)")
- {
- 報價內容[i][6] = 合計.ToString();
- }
- if (報價內容[i][2].ToString().Trim('"') == "稅金 10% Tax")
- {
- 稅金=合計 * 0.1;
- 報價內容[i][6] = 稅金.ToString();
- }
- else if (報價內容[i][2].ToString().Trim('"') == "稅金 11% Tax")
- {
- 稅金=合計 * 0.11;
- 報價內容[i][6] = 稅金.ToString();
- }
- string trimmedString = 報價內容[i][2].ToString().Trim('"');
- if (trimmedString.Length >= 2)
- {
- if (報價內容[i][2].ToString().Trim('"').Substring(0, 2) == "總計")
- {
- long ttt = (long)(合計 + Math.Floor(稅金));
- long lastThreeDigits = ttt % 1000;
- if (lastThreeDigits == 1)
- {
- ttt -= 1;
- }
- else if (lastThreeDigits == 999)
- {
- ttt += 1;
- }
- 報價內容[i][6] = ttt.ToString();
- }
- }
-
- }
- double 折讓 = 0;
- double 未折 = 0;
- double 小計 = 0;
-
- for (int i = 0; i < 報價內容.Count; i++)
- {
- if (報價內容[i][1].ToString().Trim('"') == "*" ||
- 報價內容[i][1].ToString().Trim('"') == "@" ||
- 報價內容[i][1].ToString().Trim('"') == "$" ||
- 報價內容[i][2].ToString().Trim('"') == "折讓 Discount")
- {
- }
- else
- {
- double amount = double.Parse(報價內容[i][6]);
- 未折+=amount;
- }
- if (報價內容[i][1].ToString().Trim('"') == "*" ||
- 報價內容[i][1].ToString().Trim('"') == "@" ||
- 報價內容[i][1].ToString().Trim('"') == "$")
- {
- }
- else
- {
- double amount = double.Parse(報價內容[i][6]);
- 小計+=amount;
- }
- }
- long total = (long)Math.Round(未折);
- long total1 = (long)Math.Round(小計);
- 未折價前_錢.text=total.ToString("#,##0");
- 報價小計_錢.text=total1.ToString("#,##0");
-
-
- if (copy3 != null)
- {
- DeleteCopies(copy3);
- }
- int sum1 = 2;
- for (int i = 0; i < 報價內容.Count; i++)
- {
- GameObject buttonObj = Instantiate(buttonPrefab3) as GameObject;
- buttonObj.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, -sum1);
- buttonObj.transform.SetParent(buttonParent3, false);
- TextMeshProUGUI[] text = buttonObj.GetComponentsInChildren<TextMeshProUGUI>();
- text[0].text =報價內容[i][1].ToString().Trim('"');
- string jsonString = 報價內容[i][2].ToString().Trim('"');
- string unescapedString = Regex.Unescape(jsonString);
- text[1].text =unescapedString;
- text[0].text =報價內容[i][3].ToString().Trim('"');
- SetTextValue(text[3], 報價內容[i][4], true);
- SetTextValue(text[4], 報價內容[i][5], true);
- SetTextValue(text[5], 報價內容[i][6], true);
- text[6].text =報價內容[i][7].ToString().Trim('"');
- sum1+=75;
- copy3.Add(buttonObj);
- }
- buttonceneter3.GetComponent<RectTransform>().sizeDelta = new Vector2(buttonceneter3.GetComponent<RectTransform>().sizeDelta.x, sum1);
- }
- public void 上一頁_click()
- {
- 上一頁.SetActive(false);
- 下一頁.SetActive(true);
- 明細下一頁.SetActive(false);
- 明細上一頁.SetActive(false);
- 面板_建立.SetActive(true);
- 面板_明細.SetActive(false);
- }
- public void 下一頁_click()
- {
- 上一頁.SetActive(true);
- 下一頁.SetActive(false);
- 明細下一頁.SetActive(true);
- 明細上一頁.SetActive(true);
- 面板_明細.SetActive(true);
- 面板_建立.SetActive(false);
- }
- public void 左按鈕()
- {
- nd--;
- if (nd==0)
- {
- 左.SetActive(false);
- }
- else
- {
- 左.SetActive(true);
- }
- if (nd==合約清單.Count-1)
- {
- 右.SetActive(false);
- }
- else
- {
- 右.SetActive(true);
- }
- 合約編號s.text="";
- 客戶名稱s.text="";
- 負責人s.text="";
- 工程地點s.text="";
- 地址s.text="";
- 工程名稱s.text="";
- 公司名稱s.text="";
- 負責人1s.text="";
- 地址1s.text="";
- 面板_建立.SetActive(true);
- 面板_明細.SetActive(false);
- 面板_利潤.SetActive(false);
- 面板_利潤表頭.SetActive(false);
- 報價.SetActive(false);
- image_row.SetActive(false);
- 上一頁.SetActive(false);
- 下一頁.SetActive(true);
- 明細下一頁.SetActive(false);
- 明細上一頁.SetActive(false);
- currentPage=0;
- StartCoroutine(合約內容清單());
- }
- public void 重新整理()
- {
- 合約編號s.text="";
- 客戶名稱s.text="";
- 負責人s.text="";
- 工程地點s.text="";
- 地址s.text="";
- 工程名稱s.text="";
- 公司名稱s.text="";
- 負責人1s.text="";
- 地址1s.text="";
- 面板_建立.SetActive(true);
- 面板_明細.SetActive(false);
- 面板_利潤.SetActive(false);
- 面板_利潤表頭.SetActive(false);
- 報價.SetActive(false);
- image_row.SetActive(false);
- 上一頁.SetActive(false);
- 下一頁.SetActive(true);
- 明細下一頁.SetActive(false);
- 明細上一頁.SetActive(false);
- currentPage=0;
- StartCoroutine(合約內容清單());
-
- }
- public void 右按鈕()
- {
- nd++;
- if (nd==合約清單.Count-1)
- {
- 右.SetActive(false);
- }
- else
- {
- 右.SetActive(true);
- }
- if (nd==0)
- {
- 左.SetActive(false);
- }
- else
- {
- 左.SetActive(true);
- }
- 合約編號s.text="";
- 客戶名稱s.text="";
- 負責人s.text="";
- 工程地點s.text="";
- 地址s.text="";
- 工程名稱s.text="";
- 公司名稱s.text="";
- 負責人1s.text="";
- 地址1s.text="";
- 面板_建立.SetActive(true);
- 面板_明細.SetActive(false);
- 面板_利潤.SetActive(false);
- 面板_利潤表頭.SetActive(false);
- 報價.SetActive(false);
- image_row.SetActive(false);
- 上一頁.SetActive(false);
- 下一頁.SetActive(true);
- 明細下一頁.SetActive(false);
- 明細上一頁.SetActive(false);
- currentPage=0;
- 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;
- }
- }
- void Update()
- {
- timer += Time.deltaTime;
- // 判斷是否達到時間間隔
- if (timer >= interval)
- {
- StartCoroutine(判斷更新());
- timer = 0f;
- }
- if (Main.Global.快速登入==false)
- {
- if (Input.anyKeyDown)
- {
- timeSinceLastInteraction = 0f;
- }
- else
- {
- timeSinceLastInteraction += Time.deltaTime;
- if (timeSinceLastInteraction > idleTime)
- {
- change_Secen(1);
- }
- }
- }
- }
- IEnumerator 判斷更新()
- {
- string strcon = "更新";
- string strUrl = string.Format(Main.Global.阿帕契路徑+"comm={0}", strcon);
- UnityWebRequest request = UnityWebRequest.Get(strUrl);
- yield return request.SendWebRequest();
- if (request.result == UnityWebRequest.Result.ConnectionError)
- {
- yield break;
- }
- string str = request.downloadHandler.text.ToString();
- Debug.Log(str);
- if (str == "系統更新")
- {
- change_Secen(1);
- }
- }
- public void 調整係數_存檔()
- {
- 讀取面板.SetActive(true);
- Debug.Log(報價係數);
- Debug.Log(初始係數);
- for (int i = 0; i < 報價係數.Count; i++)
- {
- for (int ii = 0; ii < 初始係數.Count; ii++)
- {
- if (報價係數[i][2]==初始係數[ii][2])
- {
- if(報價係數[i][3] !=初始係數[ii][3])
- {
- string str = 報價係數[i][3].ToString().Trim('"');
- string str2 = 報價係數[i][1].ToString().Trim('"');
- StartCoroutine(合約係數修改(str, str2));
- 初始係數[ii][3] = str;
- }
- }
- }
- }
- Debug.Log(報價係數);
- Debug.Log(初始係數);
- 明細自動計算();
- 總表自動計算();
- 調整係數頁面.SetActive(false);
- 讀取面板.SetActive(false);
- }
- IEnumerator 合約係數修改(string pa1, string pa4)
- {
- string strcon1 = "合約係數修改";
- string se = Main.Global.預設伺服器路徑;
- string pa3 = 合約編號s.text;
- string strUrl1 = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PA1={2}&PA3={3}&PA4={4}", strcon1, se, pa1, pa3, pa4);
- UnityWebRequest request1 = UnityWebRequest.Get(strUrl1);
- yield return request1.SendWebRequest();
- if (request1.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request1.error);
- yield break;
- }
- Debug.Log(request1.downloadHandler.text);
- }
- public void 縮放_click()
- {
- image_row.SetActive(!image_row.activeSelf);
- 報價.SetActive(false);
- }
- public void 調整係數_click()
- {
- 調整係數頁面.SetActive(true);
- }
- public void 調整係數關閉_click()
- {
- 調整係數頁面.SetActive(false);
- }
- public void 總價_click()
- {
- 報價.SetActive(!報價.activeSelf);
- image_row.SetActive(false);
- }
- public void 利潤_click()
- {
- 面板_利潤.SetActive(!面板_利潤.activeSelf);
- 面板_利潤表頭.SetActive(!面板_利潤表頭.activeSelf);
- }
- public void change_Secen(int _screenNum)
- {
-
- SceneManager.LoadScene(_screenNum);
- }
- public void 審核_click()
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text="是否放行";
- 彈跳叉.gameObject.SetActive(false);
- 是.gameObject.SetActive(true);
- 否.gameObject.SetActive(true);
- 是.onClick.RemoveAllListeners();
- 否.onClick.RemoveAllListeners();
- 是.onClick.AddListener(審核是);
- 否.onClick.AddListener(兩者否);
- }
- public void 作廢_click()
- {
- 彈跳面板.SetActive(true);
- 彈跳文字.text="是否作廢";
- 彈跳叉.gameObject.SetActive(false);
- 是.gameObject.SetActive(true);
- 否.gameObject.SetActive(true);
- 是.onClick.RemoveAllListeners();
- 否.onClick.RemoveAllListeners();
- 是.onClick.AddListener(作廢是);
- 否.onClick.AddListener(兩者否);
- }
- private void 審核是()
- {
- StartCoroutine(報價放行());
- 彈跳叉.gameObject.SetActive(true);
- 是.gameObject.SetActive(false);
- 否.gameObject.SetActive(false);
- 彈跳文字.text="放行成功";
- }
- private void 作廢是()
- {
- StartCoroutine(報價作廢());
- 彈跳叉.gameObject.SetActive(true);
- 是.gameObject.SetActive(false);
- 否.gameObject.SetActive(false);
- 彈跳文字.text="作廢成功";
- }
- public void 兩者否()
- {
- 彈跳叉.gameObject.SetActive(false);
- 是.gameObject.SetActive(false);
- 否.gameObject.SetActive(false);
- 彈跳面板.SetActive(false);
- 彈跳文字.text="";
- }
- IEnumerator 報價作廢()
- {
- string strcon1 = "報價作廢";
- string se = Main.Global.預設伺服器路徑;
- string pa = 合約編號s.text;
- string strUrl1 = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&編號={2}", strcon1, se, pa);
- UnityWebRequest request1 = UnityWebRequest.Get(strUrl1);
- yield return request1.SendWebRequest();
- if (request1.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request1.error);
- yield break;
- }
- yield return StartCoroutine(審核清單());
- }
- IEnumerator 報價放行()
- {
- string strcon1 = "報價放行";
- string se = Main.Global.預設伺服器路徑;
- string pa = 合約編號s.text;
- string strUrl1 = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&編號={2}", strcon1, se, pa);
- UnityWebRequest request1 = UnityWebRequest.Get(strUrl1);
- yield return request1.SendWebRequest();
- if (request1.result == UnityWebRequest.Result.ConnectionError)
- {
- Debug.Log(request1.error);
- yield break;
- }
- for (int i = 0; i < 報價係數.Count; i++)
- {
- for (int ii = 0; ii < 初始係數.Count; ii++)
- {
- if (報價係數[i][2]==初始係數[ii][2])
- {
- if (報價係數[i][3] !=初始係數[ii][3])
- {
- string str = 報價係數[i][3].ToString().Trim('"');
- string str2 = 報價係數[i][1].ToString().Trim('"');
- yield return StartCoroutine(合約係數修改(str, str2));
- }
- }
- }
- }
- yield return StartCoroutine(審核清單());
- }
- public void exit_click()
- {
- change_Secen(3);
- }
- public void setting_exit()
- {
- 選擇面板.SetActive(false);
- }
- public void setting_click()
- {
- 選擇面板.SetActive(true);
- }
- public void 網頁(RectTransform panelRectTransform, float scale, float xbar, float ybar)
- {
- var webViewGameObject = new GameObject("UniWebView");
- webView = webViewGameObject.AddComponent<UniWebView>();
- webView.Frame =new Rect(panelRectTransform.anchoredPosition.x*scale+xbar, (-panelRectTransform.anchoredPosition.y*scale)+ybar, panelRectTransform.sizeDelta.x*scale, panelRectTransform.sizeDelta.y*scale);
- if (Main.Global.系統語言=="繁體中文" || Main.Global.系統語言=="簡體中文")
- {
- webView.Load("https://gcm-smart.com/2024/01/17/hx-pgs-erp-app-51/");
- }
- else
- {
- webView.Load("https://gcm-smart.com/2024/01/17/hx-pgs-erp-app-52/");
- }
- StartCoroutine(說明顯示查詢());
-
- //webView.Show();
- }
- IEnumerator 說明顯示查詢()
- {
- string strcon1 = "說明顯示查詢";
- string se = Main.Global.預設伺服器路徑;
- string pb1 = Main.Global.人員;
- string pb2 = "APP-51-52";
- DateTime currentDate = DateTime.Now;
- int year = currentDate.Year;
- string ys = year.ToString();
- int month = currentDate.Month;
- string ms = "";
- if (month < 10)
- {
- ms = "0"+month.ToString();
- }
- else
- {
- ms = month.ToString();
- }
- string strUrl1 = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PB1={2}&PB2={3}&PB5={4}&PB6={5}", strcon1, se, pb1, pb2, ys, ms);
- UnityWebRequest request1 = UnityWebRequest.Get(strUrl1);
- yield return request1.SendWebRequest();
- if (request1.result == UnityWebRequest.Result.ConnectionError)
- {
- //Debug.Log(request.error);
- yield break;
- }
- JSONNode json = JSON.Parse(request1.downloadHandler.text);
- int 開啟, 公告;
- bool 是否新增 = false;
- if (json.Count>0)
- {
- float floatValue = float.Parse(json[2].ToString().Trim('"'));
- 開啟 = Mathf.RoundToInt(floatValue);
- float floatValue1 = float.Parse(json[3].ToString().Trim('"'));
- 公告 = Mathf.RoundToInt(floatValue1);
- if (開啟<3)
- {
- 網頁面板.SetActive(true);
- webView.Show();
- 開啟+=1;
- 公告+=1;
- }
- else
- {
- 開啟+=1;
- }
- }
- else
- {
- 網頁面板.SetActive(true);
- webView.Show();
- 開啟 = 1;
- 公告 = 1;
- 是否新增 = true;
- }
-
- if (是否新增==true)
- {
- yield return StartCoroutine(說明顯示新增(開啟, 公告));
- }
- else
- {
- yield return StartCoroutine(說明顯示修改(開啟, 公告));
- }
- }
- IEnumerator 說明顯示新增(int a1, int a2)
- {
- string strcon1 = "說明顯示新增";
- string se = Main.Global.預設伺服器路徑;
- string pb1 = Main.Global.人員;
- string pb2 = "APP-51-52";
- string pb3 = a1.ToString();
- string pb4 = a2.ToString();
- DateTime currentDate = DateTime.Now;
- int year = currentDate.Year;
- string ys = year.ToString();
- int month = currentDate.Month;
- string ms = "";
- if (month < 10)
- {
- ms = "0"+month.ToString();
- }
- else
- {
- ms = month.ToString();
- }
- string strUrl1 = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PB1={2}&PB2={3}&PB3={4}&PB4={5}&PB5={6}&PB6={7}", strcon1, se, pb1, pb2, pb3, pb4, ys, ms);
- UnityWebRequest request1 = UnityWebRequest.Get(strUrl1);
- yield return request1.SendWebRequest();
- if (request1.result == UnityWebRequest.Result.ConnectionError)
- {
- //Debug.Log(request.error);
- yield break;
- }
- }
- IEnumerator 說明顯示修改(int a1, int a2)
- {
- string strcon1 = "說明顯示修改";
- string se = Main.Global.預設伺服器路徑;
- string pb1 = Main.Global.人員;
- string pb2 = "APP-51-52";
- string pb3 = a1.ToString();
- string pb4 = a2.ToString();
- DateTime currentDate = DateTime.Now;
- int year = currentDate.Year;
- string ys = year.ToString();
- int month = currentDate.Month;
- string ms = "";
- if (month < 10)
- {
- ms = "0"+month.ToString();
- }
- else
- {
- ms = month.ToString();
- }
- string strUrl1 = string.Format(Main.Global.阿帕契路徑+"comm={0}&se={1}&PB1={2}&PB2={3}&PB3={4}&PB4={5}&PB5={6}&PB6={7}", strcon1, se, pb1, pb2, pb3, pb4, ys, ms);
- UnityWebRequest request1 = UnityWebRequest.Get(strUrl1);
- yield return request1.SendWebRequest();
- if (request1.result == UnityWebRequest.Result.ConnectionError)
- {
- //Debug.Log(request.error);
- yield break;
- }
- }
- public void 網頁面板關閉()
- {
- 網頁面板.SetActive(false);
- webView.Hide();
- }
- public void 網頁面板開啟()
- {
- 網頁面板.SetActive(true);
- webView.Show();
- }
- public void setting_中()
- {
- Main.Global.系統語言="繁體中文";
- 系統語言轉換();
- 語言選擇按鈕();
- 選擇面板.SetActive(false);
- webView.Load("https://gcm-smart.com/2024/01/17/hx-pgs-erp-app-51/");
- }
- public void setting_簡()
- {
- Main.Global.系統語言="簡體中文";
- 系統語言轉換();
- 語言選擇按鈕();
- 選擇面板.SetActive(false);
- webView.Load("https://gcm-smart.com/2024/01/17/hx-pgs-erp-app-51/");
- }
- public void setting_英()
- {
- Main.Global.系統語言="English";
-
- 系統語言轉換();
- 語言選擇按鈕();
- 選擇面板.SetActive(false);
- webView.Load("https://gcm-smart.com/2024/01/17/hx-pgs-erp-app-52/");
- }
- public void setting_印()
- {
- Main.Global.系統語言="Indonesian";
-
- 系統語言轉換();
- 語言選擇按鈕();
- 選擇面板.SetActive(false);
- webView.Load("https://gcm-smart.com/2024/01/17/hx-pgs-erp-app-52/");
- }
- public void 語言選擇按鈕()
- {
- if (bts == null)
- {
- if (Main.Global.系統語言=="繁體中文")
- {
- bts = new Button[] { 簡按鈕, 英按鈕, 印按鈕, 中按鈕 };
- }
- else if (Main.Global.系統語言=="簡體中文")
- {
- bts = new Button[] { 中按鈕, 英按鈕, 印按鈕, 簡按鈕 };
- }
- else if (Main.Global.系統語言=="English")
- {
- bts = new Button[] { 中按鈕, 簡按鈕, 印按鈕, 英按鈕 };
- }
- else
- {
- bts = new Button[] { 中按鈕, 簡按鈕, 英按鈕, 印按鈕 };
- }
- }
- else
- {
- for (int j = 0; j < bts.Length; j++)
- {
- bts[j] = null;
- }
- if (Main.Global.系統語言=="繁體中文")
- {
- bts = new Button[] { 簡按鈕, 英按鈕, 印按鈕, 中按鈕 };
- }
- else if (Main.Global.系統語言=="簡體中文")
- {
- bts = new Button[] { 中按鈕, 英按鈕, 印按鈕, 簡按鈕 };
- }
- else if (Main.Global.系統語言=="English")
- {
- bts = new Button[] { 中按鈕, 簡按鈕, 印按鈕, 英按鈕 };
- }
- else
- {
- bts = new Button[] { 中按鈕, 簡按鈕, 英按鈕, 印按鈕 };
- }
-
- }
- for (int i = 0; i < bts.Length; i++)
- {
- RectTransform rectTransform = bts[i].GetComponent<RectTransform>();
- if (i==3)
- {
- rectTransform.anchoredPosition = new Vector2(1200, 1200);
- }
- else
- {
- rectTransform.anchoredPosition = new Vector2(300*i, 0);
- }
-
- }
- }
- private void 系統語言轉換()
- {
- string 介面 = "H04";
- if (Main.Global.系統語言=="繁體中文")
- {
- 標題.text = Main.Global.系統語言字典[介面+"00CH"];
- 合約編號.text = Main.Global.系統語言字典[介面+"04CH"];
- 客戶名稱.text = Main.Global.系統語言字典[介面+"05CH"];
- 負責人.text = Main.Global.系統語言字典[介面+"06CH"];
- 負責人1.text = Main.Global.系統語言字典[介面+"06CH"];
- 工程地點.text = Main.Global.系統語言字典[介面+"07CH"];
- 地址.text = Main.Global.系統語言字典[介面+"08CH"];
- 地址1.text = Main.Global.系統語言字典[介面+"08CH"];
- 工程名稱.text = Main.Global.系統語言字典[介面+"09CH"];
- 公司名稱.text = Main.Global.系統語言字典[介面+"10CH"];
- 中.text = Main.Global.系統語言字典[介面+"11CH"];
- 英.text = Main.Global.系統語言字典[介面+"12CH"];
- 印.text = Main.Global.系統語言字典[介面+"13CH"];
- 簡.text = Main.Global.系統語言字典[介面+"29CH"];
- 選擇語言.text = Main.Global.系統語言字典[介面+"14CH"];
- 未折價前.text = Main.Global.系統語言字典[介面+"15CH"];
- 報價小計.text = Main.Global.系統語言字典[介面+"16CH"];
- 預估工資總成本.text = Main.Global.系統語言字典[介面+"17CH"];
- 預估材料總成本.text = Main.Global.系統語言字典[介面+"18CH"];
- 總成本.text = Main.Global.系統語言字典[介面+"19CH"];
- 總成本1.text = Main.Global.系統語言字典[介面+"19CH"];
- 預估工資總報價.text = Main.Global.系統語言字典[介面+"20CH"];
- 預估材料總報價.text = Main.Global.系統語言字典[介面+"21CH"];
- 總報價.text = Main.Global.系統語言字典[介面+"22CH"];
- 總報價1.text = Main.Global.系統語言字典[介面+"22CH"];
- 利潤比.text = Main.Global.系統語言字典[介面+"23CH"];
- 利潤比1.text = Main.Global.系統語言字典[介面+"23CH"];
- 利潤比2.text = Main.Global.系統語言字典[介面+"24CH"];
- 利潤比3.text = Main.Global.系統語言字典[介面+"25CH"];
- 預估利潤.text = Main.Global.系統語言字典[介面+"26CH"];
- 折讓金額.text = Main.Global.系統語言字典[介面+"27CH"];
- }
- else if (Main.Global.系統語言=="簡體中文")
- {
- 標題.text = Main.Global.系統語言字典[介面+"00CS"];
- 合約編號.text = Main.Global.系統語言字典[介面+"04CS"];
-
- 客戶名稱.text = Main.Global.系統語言字典[介面+"05CS"];
- 負責人.text = Main.Global.系統語言字典[介面+"06CS"];
- 負責人1.text = Main.Global.系統語言字典[介面+"06CS"];
- 工程地點.text = Main.Global.系統語言字典[介面+"07CS"];
- 地址.text = Main.Global.系統語言字典[介面+"08CS"];
- 地址1.text = Main.Global.系統語言字典[介面+"08CS"];
- 工程名稱.text = Main.Global.系統語言字典[介面+"09CS"];
-
- 公司名稱.text = Main.Global.系統語言字典[介面+"10CS"];
- 中.text = Main.Global.系統語言字典[介面+"11CS"];
- 英.text = Main.Global.系統語言字典[介面+"12CS"];
- 印.text = Main.Global.系統語言字典[介面+"13CS"];
- 簡.text = Main.Global.系統語言字典[介面+"29CS"];
- 選擇語言.text = Main.Global.系統語言字典[介面+"14CS"];
-
- 未折價前.text = Main.Global.系統語言字典[介面+"15CS"];
- 報價小計.text = Main.Global.系統語言字典[介面+"16CS"];
- 預估工資總成本.text = Main.Global.系統語言字典[介面+"17CS"];
- 預估材料總成本.text = Main.Global.系統語言字典[介面+"18CS"];
- 總成本.text = Main.Global.系統語言字典[介面+"19CS"];
- 總成本1.text = Main.Global.系統語言字典[介面+"19CS"];
- 預估工資總報價.text = Main.Global.系統語言字典[介面+"20CS"];
- 預估材料總報價.text = Main.Global.系統語言字典[介面+"21CS"];
- 總報價.text = Main.Global.系統語言字典[介面+"22CS"];
- 總報價1.text = Main.Global.系統語言字典[介面+"22CS"];
- 利潤比.text = Main.Global.系統語言字典[介面+"23CS"];
- 利潤比1.text = Main.Global.系統語言字典[介面+"23CS"];
- 利潤比2.text = Main.Global.系統語言字典[介面+"24CS"];
- 利潤比3.text = Main.Global.系統語言字典[介面+"25CS"];
- 預估利潤.text = Main.Global.系統語言字典[介面+"26CS"];
- 折讓金額.text = Main.Global.系統語言字典[介面+"27CS"];
- }
- else if (Main.Global.系統語言=="English")
- {
- 標題.text = Main.Global.系統語言字典[介面+"00EN"];
- 合約編號.text = Main.Global.系統語言字典[介面+"04EN"];
-
- 客戶名稱.text = Main.Global.系統語言字典[介面+"05EN"];
- 負責人.text = Main.Global.系統語言字典[介面+"06EN"];
- 負責人1.text = Main.Global.系統語言字典[介面+"06EN"];
- 工程地點.text = Main.Global.系統語言字典[介面+"07EN"];
- 地址.text = Main.Global.系統語言字典[介面+"08EN"];
- 地址1.text = Main.Global.系統語言字典[介面+"08EN"];
- 工程名稱.text = Main.Global.系統語言字典[介面+"09EN"];
-
- 公司名稱.text = Main.Global.系統語言字典[介面+"10EN"];
- 中.text = Main.Global.系統語言字典[介面+"11EN"];
- 英.text = Main.Global.系統語言字典[介面+"12EN"];
- 印.text = Main.Global.系統語言字典[介面+"13EN"];
- 簡.text = Main.Global.系統語言字典[介面+"29EN"];
- 選擇語言.text = Main.Global.系統語言字典[介面+"14EN"];
-
- 未折價前.text = Main.Global.系統語言字典[介面+"15EN"];
- 報價小計.text = Main.Global.系統語言字典[介面+"16EN"];
- 預估工資總成本.text = Main.Global.系統語言字典[介面+"17EN"];
- 預估材料總成本.text = Main.Global.系統語言字典[介面+"18EN"];
- 總成本.text = Main.Global.系統語言字典[介面+"19EN"];
- 總成本1.text = Main.Global.系統語言字典[介面+"19EN"];
- 預估工資總報價.text = Main.Global.系統語言字典[介面+"20EN"];
- 預估材料總報價.text = Main.Global.系統語言字典[介面+"21EN"];
- 總報價.text = Main.Global.系統語言字典[介面+"22EN"];
- 總報價1.text = Main.Global.系統語言字典[介面+"22EN"];
- 利潤比.text = Main.Global.系統語言字典[介面+"23EN"];
- 利潤比1.text = Main.Global.系統語言字典[介面+"23EN"];
- 利潤比2.text = Main.Global.系統語言字典[介面+"24EN"];
- 利潤比3.text = Main.Global.系統語言字典[介面+"25EN"];
- 預估利潤.text = Main.Global.系統語言字典[介面+"26EN"];
- 折讓金額.text = Main.Global.系統語言字典[介面+"27EN"];
- }
- else
- {
- 標題.text = Main.Global.系統語言字典[介面+"00ID"];
- 合約編號.text = Main.Global.系統語言字典[介面+"04ID"];
-
- 客戶名稱.text = Main.Global.系統語言字典[介面+"05ID"];
- 負責人.text = Main.Global.系統語言字典[介面+"06ID"];
- 負責人1.text = Main.Global.系統語言字典[介面+"06ID"];
- 工程地點.text = Main.Global.系統語言字典[介面+"07ID"];
- 地址.text = Main.Global.系統語言字典[介面+"08ID"];
- 地址1.text = Main.Global.系統語言字典[介面+"08ID"];
- 工程名稱.text = Main.Global.系統語言字典[介面+"09ID"];
-
- 公司名稱.text = Main.Global.系統語言字典[介面+"10ID"];
- 中.text = Main.Global.系統語言字典[介面+"11ID"];
- 英.text = Main.Global.系統語言字典[介面+"12ID"];
- 印.text = Main.Global.系統語言字典[介面+"13ID"];
- 簡.text = Main.Global.系統語言字典[介面+"29ID"];
- 選擇語言.text = Main.Global.系統語言字典[介面+"14ID"];
-
- 未折價前.text = Main.Global.系統語言字典[介面+"15ID"];
- 報價小計.text = Main.Global.系統語言字典[介面+"16ID"];
- 預估工資總成本.text = Main.Global.系統語言字典[介面+"17ID"];
- 預估材料總成本.text = Main.Global.系統語言字典[介面+"18ID"];
- 總成本.text = Main.Global.系統語言字典[介面+"19ID"];
- 總成本1.text = Main.Global.系統語言字典[介面+"19ID"];
- 預估工資總報價.text = Main.Global.系統語言字典[介面+"20ID"];
- 預估材料總報價.text = Main.Global.系統語言字典[介面+"21ID"];
- 總報價.text = Main.Global.系統語言字典[介面+"22ID"];
- 總報價1.text = Main.Global.系統語言字典[介面+"22ID"];
- 利潤比.text = Main.Global.系統語言字典[介面+"23ID"];
- 利潤比1.text = Main.Global.系統語言字典[介面+"23ID"];
- 利潤比2.text = Main.Global.系統語言字典[介面+"24ID"];
- 利潤比3.text = Main.Global.系統語言字典[介面+"25ID"];
- 預估利潤.text = Main.Global.系統語言字典[介面+"26ID"];
- 折讓金額.text = Main.Global.系統語言字典[介面+"27ID"];
- }
- }
- private void 初始化系統語言()
- {
- TextAsset txt = Resources.Load("Tran") as TextAsset;
- Main.Global.系統語言資料=txt.text.Split('\n');
- for (int i = 1; i<=Main.Global.系統語言資料.Length; i++)
- {
- try
- {
- string key = Main.Global.系統語言資料[i].ToString().Substring(0, 3)+Main.Global.系統語言資料[i].ToString().Substring(4, 2)+Main.Global.系統語言資料[i].ToString().Substring(7, 2);
- Main.Global.系統語言字典.Add(key, Main.Global.系統語言資料[i].ToString().Substring(10));
- }
- catch
- {
- // Debug.Log("No data");
- }
-
- }
- }
- private void DeleteCopies(List<GameObject> copyList)
- {
- foreach (GameObject copy in copyList)
- {
- Destroy(copy);
- }
- copyList.Clear();
- }
- }
|