jiancecheShowClass.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7. using DevExpress.XtraEditors;
  8. using DevExpress.XtraGrid.Views.Grid;
  9. using DevExpress.XtraGrid;
  10. using System.IO;
  11. using Uninpho.DBOperation.Operation;
  12. using Uninpho.DBOperation.Model;
  13. namespace Uninpho.Tools.components.DataAnalysis
  14. {
  15. /// <summary>
  16. /// 读取检测车信息
  17. /// </summary>
  18. class jiancecheShowClass
  19. {
  20. /// <summary>
  21. /// combobox显示函数
  22. /// </summary>
  23. /// <param name="isLoad">是否更新检测车信息</param>
  24. /// <param name="box">需要更新的ComboBoxEdit</param>
  25. public static void comboboxShowMain(bool isLoad,ref ComboBoxEdit box01, ref ComboBoxEdit box02)
  26. {
  27. List<string> res = new List<string>();
  28. string[] arr = new string[] { "轨检车"};//,"CRH2C-2061","CRH2C-2068","CRH2C-2150","CRH2J-0205","CRH5J-0501","CRH380AJ-0201",
  29. // "CRH380AJ-0202","CRH380AJ-0203","CRH380AJ-2808","CRH380AJ-2818","CRH380AM-0204","CRH380BJ-0301","CRH380BJ-A-0504"
  30. foreach (var item in arr)
  31. {
  32. res.Add(item);
  33. }
  34. string jccxxpath = Application.StartupPath+ "\\检测车信息.txt";
  35. if (isLoad)
  36. {
  37. var dialog = new OpenFileDialog();
  38. dialog.Multiselect = false;
  39. dialog.Title = "请选择检测车信息文件";
  40. dialog.Filter = "txt文件(*.txt)|*.txt";
  41. if (dialog.ShowDialog() == DialogResult.OK)
  42. {
  43. DACommon.FileCopy(dialog.FileName, jccxxpath);
  44. XtraMessageBox.Show("检测车信息更新成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  45. }
  46. }
  47. if (File.Exists(jccxxpath))
  48. {
  49. res.Clear();
  50. //读txt文件
  51. StreamReader SR = new StreamReader(jccxxpath);
  52. while (!SR.EndOfStream)
  53. {
  54. res.Add(SR.ReadLine().Trim());
  55. }
  56. }
  57. DACommon.jccList = res;
  58. box01.Properties.Items.Clear();
  59. box02.Properties.Items.Clear();
  60. foreach (var item in res)
  61. {
  62. box01.Properties.Items.Add(item);
  63. box02.Properties.Items.Add(item);
  64. }
  65. box01.Text = box01.Properties.Items[0].ToString();
  66. box02.Text = box01.Properties.Items[0].ToString();
  67. }
  68. /// <summary>
  69. /// 更新数据库中检测车信息
  70. /// </summary>
  71. /// <param name="GC1">几何GridControl</param>
  72. /// <param name="GC2">轮轨力GridControl</param>
  73. /// <param name="cbeJH">几何combox</param>
  74. /// <param name="GVJH">几何gridview</param>
  75. /// <param name="cbeLGL">轮轨力combox</param>
  76. /// <param name="GVLGL">轮轨力gridview</param>
  77. /// <param name="tabname">当前tab名</param>
  78. /// <param name="iswhat">执行删除还是更新检测车?true为更新、false为删除数据</param>
  79. public static void updataJccxx2PG(bool iswhat,ref GridControl GC1,ref GridControl GC2,ref ComboBoxEdit cbeJH,ref GridView GVJH, ref ComboBoxEdit cbeLGL, ref GridView GVLGL, string tabname)
  80. {
  81. if (tabname == "xtraTabPageLGL")
  82. {
  83. updataJccxx2PGFun(ref cbeLGL, ref GVLGL, iswhat);
  84. //List<T_file_account> daochaLists = DataAnalysisToPG.getfile("mat") as List<T_file_account>;
  85. //GC2.DataSource = daochaLists;
  86. }
  87. else if (tabname == "xtraTabPageJH")
  88. {
  89. updataJccxx2PGFun(ref cbeJH, ref GVJH, iswhat);
  90. //List<T_file_account> daochaLists = DataAnalysisToPG.getfile("geo") as List<T_file_account>;
  91. //GC1.DataSource = daochaLists;
  92. }
  93. }
  94. private static void updataJccxx2PGFun(ref ComboBoxEdit cbe, ref GridView GV,bool iswhat)
  95. {
  96. try
  97. {
  98. var row = GV.GetSelectedRows();
  99. if (row.Length == 0)
  100. {
  101. XtraMessageBox.Show("请先选择文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  102. }
  103. else
  104. {
  105. if (iswhat)
  106. {
  107. foreach (var i in row)
  108. {
  109. var va1 = GV.GetRowCellValue(i, "Id").ToString();
  110. var hz = GV.GetRowCellValue(i, "Yswjm").ToString();
  111. T_file_account tarr = new T_file_account()
  112. {
  113. Id = Convert.ToInt32(va1),
  114. Jccxx = cbe.SelectedItem.ToString(),
  115. Yswjm = hz
  116. };
  117. DataAnalysisToPG.UpdataToPG(tarr);
  118. GV.SetRowCellValue(i, "Jccxx", "轨检车"); // "轨检车" cbe.SelectedItem.ToString()
  119. }
  120. XtraMessageBox.Show("已修所选文件正检测车信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  121. }
  122. else
  123. {
  124. if (XtraMessageBox.Show("是否删除所选?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
  125. {
  126. for (int i = row.Length - 1; i >= 0; i--)
  127. {
  128. var va1 = GV.GetRowCellValue(row[i], "Id").ToString();
  129. var hz = GV.GetRowCellValue(row[i], "Yswjm").ToString();
  130. T_file_account tarr = new T_file_account()
  131. {
  132. Id = Convert.ToInt32(va1),
  133. Jccxx = cbe.SelectedItem.ToString(),
  134. Yswjm = hz
  135. };
  136. DataAnalysisToPG.DelToPG(tarr);
  137. GV.DeleteRow(row[i]);
  138. }
  139. //if (Path.GetExtension(hz) == ".geo")
  140. //{
  141. // List<T_jihefenxi_account> whichupdata = (List<T_jihefenxi_account>)DataAnalysisToPG.QueryToPGByName(hz);
  142. // DataAnalysisToPG.DelToPGJHBX(whichupdata);
  143. // DataAnalysisToPG.DelToPGJH(tarr);
  144. //}
  145. //else
  146. //{
  147. // List<T_lunguili_account> whichupdata = (List<T_lunguili_account>)DataAnalysisToPG.QueryToPGByNameL(hz);
  148. // DataAnalysisToPG.DelToPGLGLBX(whichupdata);
  149. // DataAnalysisToPG.DelToPGLGL(tarr);
  150. //}
  151. XtraMessageBox.Show("删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  152. }
  153. }
  154. }
  155. }
  156. catch (Exception)
  157. {
  158. if (iswhat)
  159. {
  160. XtraMessageBox.Show("修正检测车信息失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  161. }
  162. else
  163. {
  164. XtraMessageBox.Show("删除失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  165. }
  166. throw;
  167. }
  168. }
  169. }
  170. }