NationalStandardMethodTwo.cs 37 KB

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