NationalStandardMethodTwo.cs 37 KB

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