NationalStandardMethodTwo.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using OTSCLRINTERFACE;
  11. using System.Collections;
  12. using OTSSysMgrTools;
  13. namespace OTSIncAReportGB
  14. {
  15. public partial class NationalStandardMethodTwo : UserControl
  16. {
  17. #region 全局变量
  18. //设置数据表
  19. public DataTable m_dt_A = new DataTable();
  20. public DataTable m_dt_B = new DataTable();
  21. public DataTable m_dt_C = new DataTable();
  22. public DataTable m_dt_D = new DataTable();
  23. public DataTable m_dt_sulfide = new DataTable();
  24. public DataTable m_dt_DS = new DataTable();
  25. //底层相关,项目操作管理类
  26. CReportMgrClr m_ReportMgrClr = null;
  27. //获取从框架得到的底层计算结果,国标表A
  28. List<CGridDataClr> m_list_cgriddataclr_A = null;
  29. //获取从框架得到的底层计算结果,国标表B
  30. List<CGridDataClr> m_list_cgriddataclr_B = null;
  31. //获取从框架得到的底层计算结果,国标表C
  32. List<CGridDataClr> m_list_cgriddataclr_C = null;
  33. //获取从框架得到的底层计算结果,国标表D
  34. List<CGridDataClr> m_list_cgriddataclr_D = null;
  35. //获取从框架得到的底层计算结果,国标表D硫化物表
  36. List<CGridDataClr> m_list_cgriddataclr_sulfide = null;
  37. //获取从框架得到的底层计算结果,国标表DS
  38. List<CGridDataClr> m_list_cgriddataclr_DS = null;
  39. //定义一个组List
  40. List<CGridDataClr> m_list_ALLTwo = null;
  41. //接收底层数据
  42. public List<CGridDataClr> DataAll;
  43. //一个数据源包含几个列数的记录数
  44. private int m_oneresult_columnscount_A = 3;
  45. private int m_oneresult_columnscount_B = 3;
  46. private int m_oneresult_columnscount_C = 3;
  47. private int m_oneresult_columnscount_D = 3;
  48. private int m_oneresult_columnscount_sulfide = 3;
  49. private int m_oneresult_columnscount_DS = 3;
  50. #endregion
  51. #region 自定义方法
  52. private void SetDataGridViewStyleAll()
  53. {
  54. //用户不能调整标题的高度
  55. Gview_gzA.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  56. //用户不能调整 行高
  57. Gview_gzA.AllowUserToResizeRows = false;
  58. //改变行的高度;
  59. //Gview_gz.RowTemplate.Height = 20;
  60. //点击选择整行
  61. Gview_gzA.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  62. //居中显示
  63. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  64. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  65. Gview_gzA.DefaultCellStyle = dataGridViewCellStyle1;
  66. Gview_gzA.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  67. //再次重覆禁用拖动表头高度,居然有效果了
  68. Gview_gzA.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  69. //设置grid可以复制
  70. Gview_gzA.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
  71. }
  72. /// <summary>
  73. /// 设置DataGridView样式,B类表
  74. /// </summary>
  75. private void SetDataGridViewStyleB()
  76. {
  77. //用户不能调整标题的高度
  78. Gview_gzB.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  79. //用户不能调整 行高
  80. Gview_gzB.AllowUserToResizeRows = false;
  81. //改变行的高度;
  82. //Gview_gz.RowTemplate.Height = 20;
  83. //点击选择整行
  84. Gview_gzB.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  85. //居中显示
  86. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  87. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  88. Gview_gzB.DefaultCellStyle = dataGridViewCellStyle1;
  89. Gview_gzB.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  90. //再次重覆禁用拖动表头高度,居然有效果了
  91. Gview_gzB.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  92. //设置grid可以复制
  93. Gview_gzB.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
  94. //设置每列的宽度
  95. Gview_gzB.Columns[0].Width = 40;//第一列序号的宽度设置一下吧,要不太丑
  96. //设置序号列不排序
  97. Gview_gzB.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  98. //设置序号列不可以设置宽度
  99. Gview_gzB.Columns[0].Resizable = DataGridViewTriState.False;
  100. }
  101. /// <summary>
  102. /// 设置DataGridView样式,C类表
  103. /// </summary>
  104. private void SetDataGridViewStyleC()
  105. {
  106. //用户不能调整标题的高度
  107. Gview_gzC.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  108. //用户不能调整 行高
  109. Gview_gzC.AllowUserToResizeRows = false;
  110. //改变行的高度;
  111. //Gview_gz.RowTemplate.Height = 20;
  112. //点击选择整行
  113. Gview_gzC.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  114. //居中显示
  115. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  116. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  117. Gview_gzC.DefaultCellStyle = dataGridViewCellStyle1;
  118. Gview_gzC.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  119. //再次重覆禁用拖动表头高度,居然有效果了
  120. Gview_gzC.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  121. //设置grid可以复制
  122. Gview_gzC.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
  123. //设置每列的宽度
  124. Gview_gzC.Columns[0].Width = 40;//第一列序号的宽度设置一下吧,要不太丑
  125. //设置序号列不排序
  126. Gview_gzC.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  127. //设置序号列不可以设置宽度
  128. Gview_gzC.Columns[0].Resizable = DataGridViewTriState.False;
  129. }
  130. /// <summary>
  131. /// 设置DataGridView样式,D类表
  132. /// </summary>
  133. private void SetDataGridViewStyleD()
  134. {
  135. //用户不能调整标题的高度
  136. Gview_gzD.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  137. //用户不能调整 行高
  138. Gview_gzD.AllowUserToResizeRows = false;
  139. //改变行的高度;
  140. //Gview_gz.RowTemplate.Height = 20;
  141. //点击选择整行
  142. Gview_gzD.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  143. //居中显示
  144. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  145. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  146. Gview_gzD.DefaultCellStyle = dataGridViewCellStyle1;
  147. Gview_gzD.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  148. //再次重覆禁用拖动表头高度,居然有效果了
  149. Gview_gzD.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  150. //设置grid可以复制
  151. Gview_gzD.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
  152. //设置每列的宽度
  153. Gview_gzD.Columns[0].Width = 40;//第一列序号的宽度设置一下吧,要不太丑
  154. //设置序号列不排序
  155. Gview_gzD.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  156. //设置序号列不可以设置宽度
  157. Gview_gzD.Columns[0].Resizable = DataGridViewTriState.False;
  158. }
  159. /// <summary>
  160. /// 设置DataGridView样式,DS类表
  161. /// </summary>
  162. private void SetDataGridViewStyleDS()
  163. {
  164. //用户不能调整标题的高度
  165. Gview_gzDS.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  166. //用户不能调整 行高
  167. Gview_gzDS.AllowUserToResizeRows = false;
  168. //改变行的高度;
  169. //Gview_gz.RowTemplate.Height = 20;
  170. //点击选择整行
  171. Gview_gzDS.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  172. //居中显示
  173. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  174. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  175. Gview_gzDS.DefaultCellStyle = dataGridViewCellStyle1;
  176. Gview_gzDS.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  177. //再次重覆禁用拖动表头高度,居然有效果了
  178. Gview_gzDS.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  179. //设置grid可以复制
  180. Gview_gzDS.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
  181. //设置每列的宽度
  182. Gview_gzDS.Columns[0].Width = 40;//第一列序号的宽度设置一下吧,要不太丑
  183. //设置序号列不排序
  184. Gview_gzDS.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  185. //设置序号列不可以设置宽度
  186. Gview_gzDS.Columns[0].Resizable = DataGridViewTriState.False;
  187. }
  188. #endregion
  189. #region 窗体加载及初始化
  190. public NationalStandardMethodTwo()
  191. {
  192. InitializeComponent();
  193. }
  194. /// <summary>
  195. /// 国标报表,构造函数,接收A,B,C,D,DS五种结果,并进行显示
  196. /// </summary>
  197. /// <param name="in_sec"></param>
  198. /// <param name="in_Cotsreportprojfilemgrclr"></param>
  199. /// <param name="in_list_CGridDataClrAll"></param> //all 代表A、B、C、D、DS按顺序得表
  200. public string ColumnName;
  201. public string RowName;
  202. #region 国际化语言
  203. Language lan;
  204. Hashtable table;
  205. #endregion
  206. public NationalStandardMethodTwo(CReportMgrClr in_Cotsreportprojfilemgrclr, List<CGridDataClr> in_list_CGridDataClrAll)
  207. {
  208. DataAll = in_list_CGridDataClrAll;
  209. //获取报告项目类对象
  210. m_ReportMgrClr = in_Cotsreportprojfilemgrclr;
  211. m_list_cgriddataclr_A = in_list_CGridDataClrAll.GetRange(0, 1);
  212. m_list_cgriddataclr_B = in_list_CGridDataClrAll.GetRange(1, 1);
  213. m_list_cgriddataclr_C = in_list_CGridDataClrAll.GetRange(2, 1);
  214. m_list_cgriddataclr_D = in_list_CGridDataClrAll.GetRange(3, 1);
  215. m_list_cgriddataclr_sulfide = in_list_CGridDataClrAll.GetRange(4, 1);
  216. m_list_cgriddataclr_DS = in_list_CGridDataClrAll.GetRange(5, 1);
  217. m_list_ALLTwo = in_list_CGridDataClrAll;
  218. InitializeComponent();
  219. #region 国际化语言
  220. lan = new Language(this);
  221. table = lan.GetNameTable(this.Name);
  222. #endregion
  223. }
  224. private void NationalStandardMethodTwo_Load(object sender, EventArgs e)
  225. {
  226. //从底层结果类对象中,分解出数据保存到datatable中
  227. if (m_list_ALLTwo.Count > 7)
  228. {
  229. int SouseData = (m_ReportMgrClr.GetSmplMsrResultMgrs().Count) * 7;
  230. for (int g = 0; g < m_ReportMgrClr.GetSmplMsrResultMgrs().Count; g++)
  231. {
  232. for (int i = 0; i < 6; i++)
  233. {
  234. DataTable dt = new DataTable();
  235. DataColumn cc = new DataColumn();
  236. int q = g * 7 + i;
  237. dt = ChineseStandardABCD_GetDataTable_Total(DataAll.GetRange(q, 1), out m_oneresult_columnscount_A);
  238. DataGridView aa = new DataGridView();
  239. int start = 68;
  240. int end = 0;
  241. end = 150 * q;
  242. aa.Location = new Point(start, end);
  243. aa.Width = panel1.Width;
  244. aa.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
  245. aa.BackgroundColor = Color.White;
  246. panel1.Controls.Add(aa);
  247. aa.DataSource = dt;
  248. aa.Name = i.ToString();
  249. Label bb = new Label();
  250. int startLabel = 0;
  251. int endLabel = 0;
  252. endLabel = 150 * q;
  253. bb.Location = new Point(startLabel, endLabel);
  254. bb.Width = 75;
  255. for (int t = 0; t < SouseData; t++)
  256. {
  257. if (i == t * 6)
  258. {
  259. bb.Text = table["label1"].ToString();
  260. break;
  261. }
  262. if (i == t * 6 + 1)
  263. {
  264. bb.Text = table["label2"].ToString();
  265. }
  266. if (i == t * 6 + 2)
  267. {
  268. bb.Text = table["label3"].ToString();
  269. }
  270. if (i == t * 6 + 3)
  271. {
  272. bb.Text = table["label4"].ToString();
  273. }
  274. if (i == t * 6 + 4)
  275. {
  276. bb.Text = table["label5"].ToString();
  277. }
  278. if (i == t * 6 + 5)
  279. {
  280. bb.Text = table["label6"].ToString();
  281. }
  282. }
  283. bb.Font = new Font(bb.Font.Name, 12, FontStyle.Bold | FontStyle.Underline);
  284. panel1.Controls.Add(bb);
  285. }
  286. }
  287. Gview_gzA.Visible = false;
  288. Gview_gzB.Visible = false;
  289. Gview_gzC.Visible = false;
  290. Gview_gzD.Visible = false;
  291. sulfide.Visible = false;
  292. Gview_gzDS.Visible = false;
  293. label1.Visible = false;
  294. label2.Visible = false;
  295. label3.Visible = false;
  296. label4.Visible = false;
  297. label5.Visible = false;
  298. label6.Visible = false;
  299. Invalidate();
  300. }
  301. else
  302. {
  303. m_dt_A = ChineseStandardABCD_GetDataTable_Total(m_list_cgriddataclr_A, out m_oneresult_columnscount_A);
  304. m_dt_B = ChineseStandardABCD_GetDataTable_Total(m_list_cgriddataclr_B, out m_oneresult_columnscount_B);
  305. m_dt_C = ChineseStandardABCD_GetDataTable_Total(m_list_cgriddataclr_C, out m_oneresult_columnscount_C);
  306. m_dt_D = ChineseStandardABCD_GetDataTable_Total(m_list_cgriddataclr_D, out m_oneresult_columnscount_D);
  307. m_dt_sulfide = ChineseStandardABCD_GetDataTable_Total(m_list_cgriddataclr_sulfide, out m_oneresult_columnscount_sulfide);
  308. m_dt_DS = ChineseStandardABCD_GetDataTable_Total(m_list_cgriddataclr_DS, out m_oneresult_columnscount_DS);
  309. Gview_gzA.DataSource = m_dt_A;
  310. for (int i = 0; i < 13; i++)
  311. {
  312. Gview_gzA.Columns[i].Width = 68;
  313. }
  314. Gview_gzB.DataSource = m_dt_B;
  315. for (int i = 0; i < 13; i++)
  316. {
  317. Gview_gzB.Columns[i].Width = 68;
  318. }
  319. Gview_gzC.DataSource = m_dt_C;
  320. for (int i = 0; i < 13; i++)
  321. {
  322. Gview_gzC.Columns[i].Width = 68;
  323. }
  324. Gview_gzD.DataSource = m_dt_D;
  325. for (int i = 0; i < 13; i++)
  326. {
  327. Gview_gzD.Columns[i].Width = 68;
  328. }
  329. sulfide.DataSource = m_dt_sulfide;
  330. for (int i = 0; i < 13; i++)
  331. {
  332. sulfide.Columns[i].Width = 68;
  333. }
  334. Gview_gzDS.DataSource = m_dt_DS;
  335. Gview_gzA.Width = panel1.Width;
  336. Gview_gzB.Width = panel1.Width;
  337. Gview_gzC.Width = panel1.Width;
  338. Gview_gzD.Width = panel1.Width;
  339. sulfide.Width = panel1.Width;
  340. Gview_gzDS.Width = panel1.Width;
  341. }
  342. Invalidate();
  343. }
  344. #endregion
  345. #region 相关事件
  346. /// <summary>
  347. /// 复制选择区域,A
  348. /// </summary>
  349. public void CopySelected_A()
  350. {
  351. //复制选择区域
  352. object oo = Gview_gzA.GetClipboardContent();
  353. Clipboard.SetDataObject(Gview_gzA.GetClipboardContent());
  354. }
  355. /// <summary>
  356. /// 复制选择区域,B
  357. /// </summary>
  358. public void CopySelected_B()
  359. {
  360. //复制选择区域
  361. object oo = Gview_gzB.GetClipboardContent();
  362. Clipboard.SetDataObject(Gview_gzA.GetClipboardContent());
  363. }
  364. /// <summary>
  365. /// 复制选择区域,C
  366. /// </summary>
  367. public void CopySelected_C()
  368. {
  369. //复制选择区域
  370. object oo = Gview_gzC.GetClipboardContent();
  371. Clipboard.SetDataObject(Gview_gzA.GetClipboardContent());
  372. }
  373. /// <summary>
  374. /// 复制选择区域,D
  375. /// </summary>
  376. public void CopySelected_D()
  377. {
  378. //复制选择区域
  379. object oo = Gview_gzD.GetClipboardContent();
  380. Clipboard.SetDataObject(Gview_gzA.GetClipboardContent());
  381. }
  382. /// <summary>
  383. /// 复制选择区域,DS
  384. /// </summary>
  385. public void CopySelected_DS()
  386. {
  387. //复制选择区域
  388. object oo = Gview_gzDS.GetClipboardContent();
  389. Clipboard.SetDataObject(Gview_gzA.GetClipboardContent());
  390. }
  391. /// <summary>
  392. /// 复制所有,A
  393. /// </summary>
  394. public void CopyAll_A()
  395. {
  396. Gview_gzA.SelectAll();
  397. Clipboard.SetDataObject(Gview_gzA.GetClipboardContent());
  398. }
  399. /// <summary>
  400. /// 复制所有,B
  401. /// </summary>
  402. public void CopyAll_B()
  403. {
  404. Gview_gzB.SelectAll();
  405. Clipboard.SetDataObject(Gview_gzB.GetClipboardContent());
  406. }
  407. /// <summary>
  408. /// 复制所有,C
  409. /// </summary>
  410. public void CopyAll_C()
  411. {
  412. Gview_gzC.SelectAll();
  413. Clipboard.SetDataObject(Gview_gzC.GetClipboardContent());
  414. }
  415. /// <summary>
  416. /// 复制所有,D
  417. /// </summary>
  418. public void CopyAll_D()
  419. {
  420. Gview_gzD.SelectAll();
  421. Clipboard.SetDataObject(Gview_gzD.GetClipboardContent());
  422. }
  423. /// <summary>
  424. /// 复制所有,DS
  425. /// </summary>
  426. public void CopyAll_DS()
  427. {
  428. Gview_gzDS.SelectAll();
  429. Clipboard.SetDataObject(Gview_gzDS.GetClipboardContent());
  430. }
  431. private void Gview_gzA_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
  432. {
  433. //排序中
  434. if (this.Gview_gzA.Rows[e.RowIndex1].Tag != null && this.Gview_gzA.Rows[e.RowIndex1].Tag.ToString() == "统计行")
  435. {
  436. //ROW1>ROW2
  437. e.SortResult = 1;
  438. if (this.Gview_gzA.SortOrder == SortOrder.Descending)
  439. e.SortResult = -1;
  440. e.Handled = true;
  441. return;
  442. }
  443. if (this.Gview_gzA.Rows[e.RowIndex2].Tag != null && this.Gview_gzA.Rows[e.RowIndex2].Tag.ToString() == "统计行")
  444. {
  445. //ROW1<ROW2
  446. e.SortResult = -1;
  447. if (this.Gview_gzA.SortOrder == SortOrder.Descending)
  448. e.SortResult = 1;
  449. e.Handled = true;
  450. return;
  451. }
  452. }
  453. private void Gview_gzA_Sorted(object sender, EventArgs e)
  454. {
  455. //排序完成,重新设置序号
  456. for (int i = 0; i < Gview_gzA.Rows.Count; i++)
  457. {
  458. if (Gview_gzA.Rows[i].Tag != null && this.Gview_gzA.Rows[i].Tag.ToString() == "统计行")
  459. { }
  460. else
  461. {
  462. Gview_gzA.Rows[i].Cells[0].Value = i.ToString();
  463. }
  464. }
  465. }
  466. private void Gview_gzB_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
  467. {
  468. //排序中
  469. if (this.Gview_gzB.Rows[e.RowIndex1].Tag != null && this.Gview_gzB.Rows[e.RowIndex1].Tag.ToString() == "统计行")
  470. {
  471. //ROW1>ROW2
  472. e.SortResult = 1;
  473. if (this.Gview_gzB.SortOrder == SortOrder.Descending)
  474. e.SortResult = -1;
  475. e.Handled = true;
  476. return;
  477. }
  478. if (this.Gview_gzB.Rows[e.RowIndex2].Tag != null && this.Gview_gzB.Rows[e.RowIndex2].Tag.ToString() == "统计行")
  479. {
  480. //ROW1<ROW2
  481. e.SortResult = -1;
  482. if (this.Gview_gzB.SortOrder == SortOrder.Descending)
  483. e.SortResult = 1;
  484. e.Handled = true;
  485. return;
  486. }
  487. }
  488. private void Gview_gzB_Sorted(object sender, EventArgs e)
  489. {
  490. //排序完成,重新设置序号
  491. for (int i = 0; i < Gview_gzB.Rows.Count; i++)
  492. {
  493. if (Gview_gzB.Rows[i].Tag != null && this.Gview_gzB.Rows[i].Tag.ToString() == "统计行")
  494. { }
  495. else
  496. {
  497. Gview_gzB.Rows[i].Cells[0].Value = i.ToString();
  498. }
  499. }
  500. }
  501. private void Gview_gzC_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
  502. {
  503. //排序中
  504. if (this.Gview_gzC.Rows[e.RowIndex1].Tag != null && this.Gview_gzC.Rows[e.RowIndex1].Tag.ToString() == "统计行")
  505. {
  506. //ROW1>ROW2
  507. e.SortResult = 1;
  508. if (this.Gview_gzC.SortOrder == SortOrder.Descending)
  509. e.SortResult = -1;
  510. e.Handled = true;
  511. return;
  512. }
  513. if (this.Gview_gzC.Rows[e.RowIndex2].Tag != null && this.Gview_gzC.Rows[e.RowIndex2].Tag.ToString() == "统计行")
  514. {
  515. //ROW1<ROW2
  516. e.SortResult = -1;
  517. if (this.Gview_gzC.SortOrder == SortOrder.Descending)
  518. e.SortResult = 1;
  519. e.Handled = true;
  520. return;
  521. }
  522. }
  523. private void Gview_gzC_Sorted(object sender, EventArgs e)
  524. {
  525. //排序完成,重新设置序号
  526. for (int i = 0; i < Gview_gzC.Rows.Count; i++)
  527. {
  528. if (Gview_gzC.Rows[i].Tag != null && this.Gview_gzC.Rows[i].Tag.ToString() == "统计行")
  529. { }
  530. else
  531. {
  532. Gview_gzC.Rows[i].Cells[0].Value = i.ToString();
  533. }
  534. }
  535. }
  536. private void Gview_gzD_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
  537. {
  538. //排序中
  539. if (this.Gview_gzD.Rows[e.RowIndex1].Tag != null && this.Gview_gzD.Rows[e.RowIndex1].Tag.ToString() == "统计行")
  540. {
  541. //ROW1>ROW2
  542. e.SortResult = 1;
  543. if (this.Gview_gzD.SortOrder == SortOrder.Descending)
  544. e.SortResult = -1;
  545. e.Handled = true;
  546. return;
  547. }
  548. if (this.Gview_gzD.Rows[e.RowIndex2].Tag != null && this.Gview_gzD.Rows[e.RowIndex2].Tag.ToString() == "统计行")
  549. {
  550. //ROW1<ROW2
  551. e.SortResult = -1;
  552. if (this.Gview_gzD.SortOrder == SortOrder.Descending)
  553. e.SortResult = 1;
  554. e.Handled = true;
  555. return;
  556. }
  557. }
  558. private void Gview_gzD_Sorted(object sender, EventArgs e)
  559. {
  560. //排序完成,重新设置序号
  561. for (int i = 0; i < Gview_gzD.Rows.Count; i++)
  562. {
  563. if (Gview_gzD.Rows[i].Tag != null && this.Gview_gzD.Rows[i].Tag.ToString() == "统计行")
  564. { }
  565. else
  566. {
  567. Gview_gzD.Rows[i].Cells[0].Value = i.ToString();
  568. }
  569. }
  570. }
  571. private void Gview_gzDS_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
  572. {
  573. //排序中
  574. if (this.Gview_gzDS.Rows[e.RowIndex1].Tag != null && this.Gview_gzDS.Rows[e.RowIndex1].Tag.ToString() == "统计行")
  575. {
  576. //ROW1>ROW2
  577. e.SortResult = 1;
  578. if (this.Gview_gzDS.SortOrder == SortOrder.Descending)
  579. e.SortResult = -1;
  580. e.Handled = true;
  581. return;
  582. }
  583. if (this.Gview_gzDS.Rows[e.RowIndex2].Tag != null && this.Gview_gzDS.Rows[e.RowIndex2].Tag.ToString() == "统计行")
  584. {
  585. //ROW1<ROW2
  586. e.SortResult = -1;
  587. if (this.Gview_gzDS.SortOrder == SortOrder.Descending)
  588. e.SortResult = 1;
  589. e.Handled = true;
  590. return;
  591. }
  592. }
  593. private void Gview_gzDS_Sorted(object sender, EventArgs e)
  594. {
  595. //排序完成,重新设置序号
  596. for (int i = 0; i < Gview_gzDS.Rows.Count; i++)
  597. {
  598. if (Gview_gzDS.Rows[i].Tag != null && this.Gview_gzDS.Rows[i].Tag.ToString() == "统计行")
  599. { }
  600. else
  601. {
  602. Gview_gzDS.Rows[i].Cells[0].Value = i.ToString();
  603. }
  604. }
  605. }
  606. private void ToolStripMenuItem1_Click(object sender, EventArgs e)
  607. {
  608. //A,复制整个表
  609. CopyAll_A();
  610. }
  611. private void ToolStripMenuItem2_Click(object sender, EventArgs e)
  612. {
  613. //A,复制选择区域
  614. CopySelected_A();
  615. }
  616. private void toolStripMenuItem4_Click(object sender, EventArgs e)
  617. {
  618. //B,复制整个表
  619. CopyAll_B();
  620. }
  621. private void toolStripMenuItem5_Click(object sender, EventArgs e)
  622. {
  623. //B,复制选择区域
  624. CopySelected_B();
  625. }
  626. private void toolStripMenuItem7_Click(object sender, EventArgs e)
  627. {
  628. //C,复制整个表
  629. CopyAll_C();
  630. }
  631. private void toolStripMenuItem8_Click(object sender, EventArgs e)
  632. {
  633. //C,复制选择区域
  634. CopySelected_C();
  635. }
  636. private void toolStripMenuItem10_Click(object sender, EventArgs e)
  637. {
  638. //D,复制整个表
  639. CopyAll_D();
  640. }
  641. private void toolStripMenuItem11_Click(object sender, EventArgs e)
  642. {
  643. //D,复制选择区域
  644. CopySelected_D();
  645. }
  646. private void toolStripMenuItem13_Click(object sender, EventArgs e)
  647. {
  648. //DS,复制整个表
  649. CopyAll_DS();
  650. }
  651. private void toolStripMenuItem14_Click(object sender, EventArgs e)
  652. {
  653. //DS,复制选择区域
  654. CopySelected_DS();
  655. }
  656. #endregion
  657. #region 获取向导出模块提供的DataTable和GridView对象
  658. /// <summary>
  659. /// 获取到该模块输出后形成的DataTable,和GridView
  660. /// </summary>
  661. /// <param name="out_dt"></param>
  662. /// <param name="out_dg"></param>
  663. public void GetDataTableAndGridView(out DataTable out_dtA, out DataTable out_dtB, out DataTable out_dtC, out DataTable out_dtD, out DataTable out_dt_sulfide, out DataTable out_dtDS,
  664. out DataGridView out_dgA, out DataGridView out_dgB, out DataGridView out_dgC, out DataGridView out_dgD, out DataGridView out_dgsulfide, out DataGridView out_dgDS)
  665. {
  666. //从panel中找出前5个datagridview,然后进行输出
  667. foreach (Control ctl in this.panel1.Controls)
  668. {
  669. if (ctl.Name == "0")
  670. {
  671. this.Gview_gzA = (DataGridView)ctl;
  672. }
  673. if (ctl.Name == "1")
  674. {
  675. this.Gview_gzB = (DataGridView)ctl;
  676. }
  677. if (ctl.Name == "2")
  678. {
  679. this.Gview_gzC = (DataGridView)ctl;
  680. }
  681. if (ctl.Name == "3")
  682. {
  683. this.Gview_gzD = (DataGridView)ctl;
  684. }
  685. if (ctl.Name == "4")
  686. {
  687. this.sulfide = (DataGridView)ctl;
  688. }
  689. if (ctl.Name == "5")
  690. {
  691. this.Gview_gzDS = (DataGridView)ctl;
  692. }
  693. }
  694. out_dtA = m_dt_A;
  695. out_dgA = this.Gview_gzA;
  696. out_dtB = m_dt_B;
  697. out_dgB = this.Gview_gzB;
  698. out_dtC = m_dt_C;
  699. out_dgC = this.Gview_gzC;
  700. out_dtD = m_dt_D;
  701. out_dgD = this.Gview_gzD;
  702. out_dt_sulfide = m_dt_sulfide;
  703. out_dgsulfide = this.sulfide;
  704. out_dtDS = m_dt_DS;
  705. out_dgDS = this.Gview_gzDS;
  706. }
  707. #endregion
  708. #region clr加载数据部分
  709. public DataTable ChineseStandardABCD_GetDataTable_Total(List<CGridDataClr> in_list_cgriddataclr, out int oneresult_columncount)
  710. {
  711. oneresult_columncount = 1;//一个数据源的跨度,计算出一个数据源包含几个列
  712. //创建一个临时表
  713. DataTable ret_dt = new DataTable();
  714. //判断传入的数据对象是否为空
  715. if (in_list_cgriddataclr == null)
  716. {
  717. string str1 = "传入分解表格数据的CGridDataClr对象为空!";
  718. str1 = table["str1"].ToString();
  719. //log.Error("(OTSIncAReportGridsFun.ChineseStandardABCD_GetDataTable_Total)" + str1);
  720. return ret_dt;
  721. }
  722. #region 根据返回的结构创建DataTable的结构---------------------------------------------
  723. for (int i = 0; i < in_list_cgriddataclr.Count(); i++)
  724. {
  725. //分解结果内容
  726. List<CGridColumnClr> list_cgridcolumnclrs = new List<CGridColumnClr>();
  727. list_cgridcolumnclrs = in_list_cgriddataclr[i].GetGridColumnList(); //获取各列
  728. //单个数据源包含几个列的跨度
  729. if (oneresult_columncount < list_cgridcolumnclrs.Count())
  730. oneresult_columncount = list_cgridcolumnclrs.Count();
  731. if (in_list_cgriddataclr.Count > 1)
  732. {
  733. //创建DT的列,多个数据源,为每个字段带上索引号
  734. foreach (CGridColumnClr ls_cgridcolumnclr in list_cgridcolumnclrs)
  735. {
  736. string ls_fl_strName = ls_cgridcolumnclr.GetName();
  737. //通过获取到的列,创建表的列
  738. ret_dt.Columns.Add(ls_fl_strName + "(" + (i + 1).ToString() + ")");
  739. }
  740. }
  741. else
  742. {
  743. //创建DT的列,单个数据源,不带索引号
  744. foreach (CGridColumnClr ls_cgridcolumnclr in list_cgridcolumnclrs)
  745. {
  746. string ls_fl_strName = ls_cgridcolumnclr.GetName();
  747. //通过获取到的列,创建表的列
  748. ret_dt.Columns.Add(ls_fl_strName);
  749. }
  750. }
  751. }
  752. #endregion
  753. #region 再创建表的行------------------------------------------------------------------
  754. //取最大的rowlistcount,要不然,不知道这底层返回的数据居然还有2,2,3这样的行数据
  755. int maxrownumber = 0;
  756. for (int i = 0; i < in_list_cgriddataclr.Count(); i++)
  757. {
  758. //分解结果内容
  759. List<CGridColumnClr> list_cgridcolumnclrs = new List<CGridColumnClr>();
  760. list_cgridcolumnclrs = in_list_cgriddataclr[i].GetGridColumnList(); //获取各列
  761. //创建DT的行
  762. if (list_cgridcolumnclrs != null)
  763. {
  764. foreach (CGridColumnClr ls_cgridcolumnclr in list_cgridcolumnclrs)
  765. {
  766. if (maxrownumber < ls_cgridcolumnclr.GetRowList().Count())
  767. {
  768. maxrownumber = ls_cgridcolumnclr.GetRowList().Count();
  769. }
  770. }
  771. }
  772. }
  773. for (int k = 0; k < maxrownumber; k++)
  774. {
  775. DataRow dr = ret_dt.NewRow();
  776. ret_dt.Rows.Add(dr);
  777. }
  778. #endregion
  779. #region //再次重新分解,先分解列,然后将获取到的各行各列的数据,填充到相应的位置上---
  780. for (int i = 0; i < in_list_cgriddataclr.Count(); i++)
  781. {
  782. //分解结果内容
  783. List<CGridColumnClr> list_cgridcolumnclrs = new List<CGridColumnClr>();
  784. list_cgridcolumnclrs = in_list_cgriddataclr[i].GetGridColumnList(); //获取各列
  785. //再次重新分解,先分解列,然后将获取到的
  786. for (int k = 0; k < list_cgridcolumnclrs.Count(); k++)
  787. {
  788. string ls_fl_strName = list_cgridcolumnclrs[k].GetName();
  789. List<CGridRowClr> ls_list_cgridrowclr = new List<CGridRowClr>();
  790. ls_list_cgridrowclr = list_cgridcolumnclrs[k].GetRowList();
  791. for (int j = 0; j < ls_list_cgridrowclr.Count(); j++)
  792. {
  793. //先判断该行该单元格的数据类型
  794. string str_value = "";//因为显示只需要对字符串进行操作就可以了,所以将底层获取到的数据,除了颗粒类型外的都转成string
  795. switch (ls_list_cgridrowclr[j].GetDataType())
  796. {
  797. case 0:
  798. //string
  799. str_value = ls_list_cgridrowclr[j].GetStringValue();
  800. ret_dt.Rows[j][k + i * oneresult_columncount] = str_value;
  801. break;
  802. case 1:
  803. //该元素含量表没有需要显示的颗粒图像
  804. //ret_dt.Rows[j][k+i*oneresult_columncount] = GetBitmapByParticleList(ls_list_cgridrowclr[k].GetParticle());
  805. break;
  806. case 2:
  807. //int
  808. str_value = ls_list_cgridrowclr[j].GetIntValue().ToString();
  809. ret_dt.Rows[j][k + i * oneresult_columncount] = str_value;
  810. break;
  811. case 3:
  812. //float
  813. str_value = ls_list_cgridrowclr[j].GetDoubleValue().ToString("0.00");
  814. ret_dt.Rows[j][k + i * oneresult_columncount] = str_value;
  815. break;
  816. default:
  817. str_value = "";
  818. ret_dt.Rows[j][k + i * oneresult_columncount] = str_value;
  819. break;
  820. }
  821. }
  822. }
  823. }
  824. #endregion
  825. return ret_dt;
  826. }
  827. #endregion
  828. }
  829. }