CreateNewTableMTLF.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. using Uninpho.Tools.components;
  12. using Uninpho.DBOperation.Model;
  13. using DevExpress.XtraEditors;
  14. namespace Uninpho.Tools.components.MTLFF
  15. {
  16. public partial class CreateNewTableMTLF : DevExpress.XtraEditors.XtraForm
  17. {
  18. public CreateNewTableMTLF()
  19. {
  20. InitializeComponent();
  21. }
  22. List<T_daocha_account> daochaData = new List<T_daocha_account>();
  23. private void NewcancelBtn_Click(object sender, EventArgs e)
  24. {
  25. this.Close();
  26. }
  27. private void newCreateBtnSon_Click(object sender, EventArgs e)
  28. {
  29. MTLFFListFrom frm = new MTLFFListFrom();
  30. frm.StartPosition = FormStartPosition.CenterParent;
  31. ExcelTools.chezhan = zhanmingText.Text;
  32. ExcelTools.daocha = daochahaoText.Text;
  33. ExcelTools.zhecha = zhechahaoText.Text;
  34. ExcelTools.shejituhao = shejituhaoText.Text;
  35. ExcelTools.jianceren = jiancharenText.Text;
  36. ExcelTools.jianceshijian = jianchashijianText.DateTime.ToShortDateString();
  37. ExcelTools.xianluming = xianlumingText.Text;
  38. ExcelTools.filenameall = Application.StartupPath + "\\mtlf_temp\\新建道岔全面检查记录表.xlsx";
  39. frm.ShowDialog();
  40. //DataAnalysis.DACommon.DirectoryInit(Application.StartupPath + "\\mtlf_temp");
  41. //DataAnalysis.DACommon.FileCopy(Application.StartupPath + "\\mtlfdemo.xlsx", ExcelTools.filenameall);
  42. //ExcelTools.sheetControldemo.LoadDocument(ExcelTools.filenameall);
  43. //if (frm.ShowDialog() == DialogResult.OK)
  44. //{
  45. this.Close();
  46. //}
  47. }
  48. /// <summary>
  49. /// 加载模糊查询的数据
  50. /// </summary>
  51. private void CreateNewTableMTLF_Load(object sender, EventArgs e)
  52. {
  53. daochaData = DBOperation.Operation.DataAnalysisToPG.QueryDCTZALL();
  54. //整理线路名集合
  55. var listtgXLMALL = daochaData.GroupBy(c => c.Xlm).Select(c => c.First()).ToList();
  56. foreach (var item in listtgXLMALL)
  57. {
  58. xianlumingText.Properties.Items.Add(item.Xlm);
  59. }
  60. }
  61. /// <summary>
  62. /// 线路名查询
  63. /// </summary>
  64. private void xianlumingText_TextChanged(object sender, EventArgs e)
  65. {
  66. zhanmingText.Properties.Items.Clear();
  67. var isInputTrueXLM = daochaData.FindAll(delegate (T_daocha_account dc)
  68. {
  69. return dc.Xlm == xianlumingText.Text;
  70. });
  71. //线路名
  72. if (isInputTrueXLM.Count != 0)
  73. {
  74. var listtg = isInputTrueXLM.GroupBy(c => c.Czm).Select(c => c.First()).ToList();
  75. foreach (var item in listtg)
  76. {
  77. zhanmingText.Properties.Items.Add(item.Czm);
  78. }
  79. zhanmingText.Enabled = true;
  80. }
  81. else
  82. {
  83. zhanmingText.Enabled = false;
  84. }
  85. zhanmingText.Text = "";
  86. daochahaoText.Text = "";
  87. zhechahaoText.Text = "";
  88. shejituhaoText.Text = "";
  89. }
  90. private void zhanmingText_EditValueChanged(object sender, EventArgs e)
  91. {
  92. daochahaoText.Properties.Items.Clear();
  93. var isInputTrueZM = daochaData.FindAll(delegate (T_daocha_account dc)
  94. {
  95. return dc.Xlm == xianlumingText.Text && dc.Czm == zhanmingText.Text;
  96. });
  97. //线路名
  98. if (isInputTrueZM.Count != 0)
  99. {
  100. var listtg = isInputTrueZM.GroupBy(c => c.Dcbh).Select(c => c.First()).ToList();
  101. foreach (var item in listtg)
  102. {
  103. daochahaoText.Properties.Items.Add(item.Dcbh);
  104. }
  105. daochahaoText.Enabled = true;
  106. }
  107. else
  108. {
  109. daochahaoText.Enabled = false;
  110. }
  111. daochahaoText.Text = "";
  112. zhechahaoText.Text = "";
  113. shejituhaoText.Text = "";
  114. }
  115. private void daochahaoText_EditValueChanged(object sender, EventArgs e)
  116. {
  117. var isInputTrueDC = daochaData.FindAll(delegate (T_daocha_account dc)
  118. {
  119. return dc.Xlm == xianlumingText.Text && dc.Czm == zhanmingText.Text && dc.Dcbh == daochahaoText.Text;
  120. });
  121. zhechahaoText.Text = "";
  122. shejituhaoText.Text = "";
  123. //线路名
  124. if (isInputTrueDC.Count != 0)
  125. {
  126. var listtg = isInputTrueDC.GroupBy(c => c.Zch).Select(c => c.First()).ToList();
  127. zhechahaoText.Text = listtg[0].Zch.ToString();
  128. shejituhaoText.Text = listtg[0].Dcth.ToString();
  129. }
  130. }
  131. #region keyup事件
  132. private void xianlumingText_KeyUp(object sender, KeyEventArgs e)
  133. {
  134. canelMH(e, xianlumingText);
  135. }
  136. private void zhanmingText_KeyUp(object sender, KeyEventArgs e)
  137. {
  138. canelMH(e, zhanmingText);
  139. }
  140. private void daochahaoText_KeyUp(object sender, KeyEventArgs e)
  141. {
  142. canelMH(e, daochahaoText);
  143. }
  144. private void canelMH(KeyEventArgs e, ComboBoxEdit CB)
  145. {
  146. var asa = e.KeyValue;
  147. var asaaa = e.KeyCode;
  148. if (asa == 13)
  149. {
  150. CB.ClosePopup();
  151. }
  152. else
  153. {
  154. CB.ShowPopup();
  155. }
  156. }
  157. #endregion
  158. }
  159. }