static void Main(string[] args) { string str = "ù"; bool check = VnHelper.Detect(str); int a = 1; }
private async void LoadDtaFromExcel() { try { #region init isLoad = true; ExcelHelper excelHelper = new ExcelHelper(); #endregion #region reset totalLoad = 0; totalRest = 0; totalRestAffCalc = 0; totalDuplicate = 0; lbTotalLoad.Invoke(new MethodInvoker(delegate { lbTotalLoad.Text = totalLoad.ToString(); })); lbTotalrest.Invoke(new MethodInvoker(delegate { lbTotalrest.Text = totalRest.ToString(); })); lbTotalAftercalc.Invoke(new MethodInvoker(delegate { lbTotalAftercalc.Text = totalRestAffCalc.ToString(); })); lbTotalDuplicate.Invoke(new MethodInvoker(delegate { lbTotalDuplicate.Text = totalDuplicate.ToString(); })); ediFilesItems = new List <MemberWorkList>(); ediFilesItemsClone = new List <MemberWorkList>(); dgvEditFileImport.Invoke(new MethodInvoker(delegate { dgvEditFileImport.DataSource = ediFilesItems; })); dgvEditCalcXXX.Invoke(new MethodInvoker(delegate { dgvEditCalcXXX.DataSource = ediFilesItemsClone; })); #endregion //du lieu doc file ediFilesItems = excelHelper.ReadExcelMemberEorkList(tstxtPath.Text); #region 1.Loai bo dong trong List <MemberWorkList> editFiles = new List <MemberWorkList>(); if (ediFilesItems != null) { ediFilesItemsClone.Clear(); string WorkInternalNo = string.Empty; string INTERNAL_NO = string.Empty; int pos = 0; string TITLE2 = string.Empty; string TITLE3 = string.Empty; string name = string.Empty; string name3 = string.Empty; string[] arrayname = null; string text, text2; string[] arrWriterReal; for (int i = 0; i < ediFilesItems.Count; i++) { name = ediFilesItems[i].NAME; arrayname = name.Split(','); if (arrayname.Length != 2) { continue; } if (arrayname[1].Trim() == string.Empty) { name = arrayname[0].Trim(); name3 = name; } else { if (name == "TRAN THIEN, THANH TRẦN THIỆNTHANH") { int a = 1; } //TRAN THIEN, THANH TRẦN THIỆNTHANH //TRAN THIEN arrayname[0] = arrayname[0].Trim(); name = $"{arrayname[0]} "; //THANH TRẦN THIỆNTHANH arrayname[1] = arrayname[1].Trim(); name3 = arrayname[1]; //THANH:TRẦN:THIỆNTHANH arrayname = arrayname[1].Split(' '); arrayname[0] = arrayname[0].Trim(); //TRAN THIEN THANH name += arrayname[0]; //TRẦN THIỆNTHANH pos = name3.IndexOf(arrayname[0]); if (pos >= 0) { name3 = name3.Substring(pos + arrayname[0].Length, name3.Length - arrayname[0].Length - pos).Trim(); } #region nếu là tác giả việt if (name3.Length > 0) { text = name3.Replace(" ", ""); text2 = VnHelper.ConvertToUnSign(text); arrWriterReal = name.Split(' '); name3 = string.Empty; for (int k = 0; k < arrWriterReal.Length; k++) { pos = text2.IndexOf(arrWriterReal[k]); if (pos >= 0) { int x = text.Length; int x1 = text2.Length; name3 += text.Substring(pos, arrWriterReal[k].Length) + " "; text = text.Substring(arrWriterReal[k].Length, text.Length - arrWriterReal[k].Length); text2 = text2.Substring(arrWriterReal[k].Length, text2.Length - arrWriterReal[k].Length); } } } #endregion } #region general report: thuong dung if (ediFilesItems[i].INTERNAL_NO != string.Empty) { INTERNAL_NO = ediFilesItems[i].INTERNAL_NO; var x = (MemberWorkList)ediFilesItems[i].Clone(); pos = x.TITLE.Length / 2; TITLE2 = x.TITLE.Substring(0, pos).Trim(); TITLE3 = x.TITLE.Substring(pos, x.TITLE.Length - pos).Trim(); if (VnHelper.Detect(TITLE3) && TITLE2 == VnHelper.ConvertToUnSign(TITLE3)) { x.TITLE2 = TITLE2; x.TITLE3 = TITLE3; } else { x.TITLE2 = x.TITLE; x.TITLE3 = x.TITLE; } x.NAME2 = name; x.NAME3 = name3.Trim(); ediFilesItemsClone.Add(x); } else { var x = ediFilesItemsClone.Where(p => p.INTERNAL_NO == INTERNAL_NO).FirstOrDefault(); if (x != null) { if (x.NAME_TYPE != string.Empty) { x.NAME_TYPE += ", "; } x.NAME_TYPE += ediFilesItems[i].NAME_TYPE; if (x.ROLE != string.Empty) { x.ROLE += ", "; } x.ROLE += ediFilesItems[i].ROLE; if (x.SOCIETY != string.Empty) { x.SOCIETY += ", "; } x.SOCIETY += ediFilesItems[i].SOCIETY; if (x.NAME2 != string.Empty) { x.NAME2 += ", "; } x.NAME2 += name; if (x.NAME3 != string.Empty) { x.NAME3 += ", "; } x.NAME3 += name3.Trim(); } } #endregion } totalRest = ediFilesItemsClone.Count; lbTotalrest.Invoke(new MethodInvoker(delegate { lbTotalrest.Text = totalRest.ToString(); })); } else { ediFilesItemsClone.Clear(); } #endregion #region Hien thi du lieu goc //bindingSourceImport.DataSource = ediFilesItems; //bindingSourceEdit.DataSource = ediFilesItemsClone; if (ediFilesItems != null) { totalLoad = ediFilesItems.Count; lbTotalLoad.Invoke(new MethodInvoker(delegate { lbTotalLoad.Text = totalLoad.ToString(); })); dgvEditFileImport.Invoke(new MethodInvoker(delegate { dgvEditFileImport.DataSource = ediFilesItems; })); dgvEditCalcXXX.Invoke(new MethodInvoker(delegate { dgvEditCalcXXX.DataSource = ediFilesItemsClone; })); FilterData(); totalRestAffCalc = ediFilesItemsClone.Count; totalDuplicate = totalRest - totalRestAffCalc; lbTotalAftercalc.Invoke(new MethodInvoker(delegate { lbTotalAftercalc.Text = totalRestAffCalc.ToString(); })); lbTotalDuplicate.Invoke(new MethodInvoker(delegate { lbTotalDuplicate.Text = totalDuplicate.ToString(); })); } else { lbTotalLoad.Text = "0"; statusMain.Invoke(new MethodInvoker(delegate { lbInfo.Text = "Load data from Excel file be error!"; })); } #endregion isLoad = false; } catch (Exception ex) { isLoad = false; MessageBox.Show(ex.ToString()); } }