ChineseStandardABCDDS.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  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 ChineseStandardABCDDS : 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_DS = new DataTable();
  24. //底层相关,项目操作管理类
  25. COTSReportProjFileMgrClr m_COTSReportProjFileMgrClr = null;
  26. //日志类
  27. //public NSLogFunExport.CFunExportClass m_LogFunExport = null;
  28. //日志文件名
  29. const String m_csFileName = "OTSReportAppLog";
  30. //获取从框架得到的底层计算结果,国标表A
  31. List<CGridDataClr> m_list_cgriddataclr_A = null;
  32. //获取从框架得到的底层计算结果,国标表B
  33. List<CGridDataClr> m_list_cgriddataclr_B = null;
  34. //获取从框架得到的底层计算结果,国标表C
  35. List<CGridDataClr> m_list_cgriddataclr_C = null;
  36. //获取从框架得到的底层计算结果,国标表D
  37. List<CGridDataClr> m_list_cgriddataclr_D = null;
  38. //获取从框架得到的底层计算结果,国标表DS
  39. List<CGridDataClr> m_list_cgriddataclr_DS = null;
  40. //定义整个一组返回List
  41. List<CGridDataClr> m_list_ALL = null;
  42. //接收底层数据
  43. public List<CGridDataClr> DataAll;
  44. //一个数据源包含几个列数的记录数
  45. private int m_oneresult_columnscount_A = 3;
  46. private int m_oneresult_columnscount_B = 3;
  47. private int m_oneresult_columnscount_C = 3;
  48. private int m_oneresult_columnscount_D = 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_gzA.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  60. //居中显示
  61. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  62. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  63. Gview_gzA.DefaultCellStyle = dataGridViewCellStyle1;
  64. Gview_gzA.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  65. //再次重覆禁用拖动表头高度,居然有效果了
  66. Gview_gzA.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  67. //设置grid可以复制
  68. Gview_gzA.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
  69. }
  70. /// <summary>
  71. /// 设置DataGridView样式,B类表
  72. /// </summary>
  73. private void SetDataGridViewStyleB()
  74. {
  75. //用户不能调整标题的高度
  76. Gview_gzB.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  77. //用户不能调整 行高
  78. Gview_gzB.AllowUserToResizeRows = false;
  79. //点击选择整行
  80. Gview_gzB.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  81. //居中显示
  82. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  83. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  84. Gview_gzB.DefaultCellStyle = dataGridViewCellStyle1;
  85. Gview_gzB.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  86. //再次重覆禁用拖动表头高度,居然有效果了
  87. Gview_gzB.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  88. //设置grid可以复制
  89. Gview_gzB.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
  90. //设置每列的宽度
  91. Gview_gzB.Columns[0].Width = 40;//第一列序号的宽度设置一下吧,要不太丑
  92. //设置序号列不排序
  93. Gview_gzB.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  94. //设置序号列不可以设置宽度
  95. Gview_gzB.Columns[0].Resizable = DataGridViewTriState.False;
  96. }
  97. /// <summary>
  98. /// 设置DataGridView样式,C类表
  99. /// </summary>
  100. private void SetDataGridViewStyleC()
  101. {
  102. //用户不能调整标题的高度
  103. Gview_gzC.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  104. //用户不能调整 行高
  105. Gview_gzC.AllowUserToResizeRows = false;
  106. //点击选择整行
  107. Gview_gzC.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  108. //居中显示
  109. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  110. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  111. Gview_gzC.DefaultCellStyle = dataGridViewCellStyle1;
  112. Gview_gzC.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  113. //再次重覆禁用拖动表头高度,居然有效果了
  114. Gview_gzC.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  115. //设置grid可以复制
  116. Gview_gzC.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
  117. //设置每列的宽度
  118. Gview_gzC.Columns[0].Width = 40;//第一列序号的宽度设置一下吧,要不太丑
  119. //设置序号列不排序
  120. Gview_gzC.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  121. //设置序号列不可以设置宽度
  122. Gview_gzC.Columns[0].Resizable = DataGridViewTriState.False;
  123. }
  124. /// <summary>
  125. /// 设置DataGridView样式,D类表
  126. /// </summary>
  127. private void SetDataGridViewStyleD()
  128. {
  129. //用户不能调整标题的高度
  130. Gview_gzD.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  131. //用户不能调整 行高
  132. Gview_gzD.AllowUserToResizeRows = false;
  133. //改变行的高度;
  134. //Gview_gz.RowTemplate.Height = 20;
  135. //点击选择整行
  136. Gview_gzD.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  137. //居中显示
  138. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  139. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  140. Gview_gzD.DefaultCellStyle = dataGridViewCellStyle1;
  141. Gview_gzD.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  142. //再次重覆禁用拖动表头高度,居然有效果了
  143. Gview_gzD.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  144. //设置grid可以复制
  145. Gview_gzD.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
  146. //设置每列的宽度
  147. Gview_gzD.Columns[0].Width = 40;//第一列序号的宽度设置一下吧,要不太丑
  148. //设置序号列不排序
  149. Gview_gzD.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  150. //设置序号列不可以设置宽度
  151. Gview_gzD.Columns[0].Resizable = DataGridViewTriState.False;
  152. }
  153. /// <summary>
  154. /// 设置DataGridView样式,DS类表
  155. /// </summary>
  156. private void SetDataGridViewStyleDS()
  157. {
  158. //用户不能调整标题的高度
  159. Gview_gzDS.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  160. //用户不能调整 行高
  161. Gview_gzDS.AllowUserToResizeRows = false;
  162. //点击选择整行
  163. Gview_gzDS.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  164. //居中显示
  165. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
  166. dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  167. Gview_gzDS.DefaultCellStyle = dataGridViewCellStyle1;
  168. Gview_gzDS.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
  169. //再次重覆禁用拖动表头高度,居然有效果了
  170. Gview_gzDS.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
  171. //设置grid可以复制
  172. Gview_gzDS.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText;
  173. //设置每列的宽度
  174. Gview_gzDS.Columns[0].Width = 40;//第一列序号的宽度设置一下吧,要不太丑
  175. //设置序号列不排序
  176. Gview_gzDS.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
  177. //设置序号列不可以设置宽度
  178. Gview_gzDS.Columns[0].Resizable = DataGridViewTriState.False;
  179. }
  180. #endregion
  181. #region 窗体加载及初始化
  182. public ChineseStandardABCDDS()
  183. {
  184. InitializeComponent();
  185. }
  186. /// <summary>
  187. /// 国标报表,构造函数,接收A,B,C,D,DS五种结果,并进行显示
  188. /// </summary>
  189. /// <param name="in_sec"></param>
  190. /// <param name="in_Cotsreportprojfilemgrclr"></param>
  191. /// <param name="in_list_CGridDataClrAll"></param> //all 代表A、B、C、D、DS按顺序得表
  192. public string ColumnName;
  193. public string RowName;
  194. #region 国际化语言
  195. Language lan;
  196. Hashtable table;
  197. #endregion
  198. public ChineseStandardABCDDS( COTSReportProjFileMgrClr in_Cotsreportprojfilemgrclr, List<CGridDataClr> in_list_CGridDataClrAll)
  199. {
  200. DataAll = in_list_CGridDataClrAll;
  201. //初始化日志文件名称
  202. //m_LogFunExport = new NSLogFunExport.CFunExportClass();
  203. //m_LogFunExport.InitLog(m_csFileName);
  204. //获取报告项目类对象
  205. m_COTSReportProjFileMgrClr = in_Cotsreportprojfilemgrclr;
  206. m_list_cgriddataclr_A = in_list_CGridDataClrAll.GetRange(0, 1);
  207. m_list_cgriddataclr_B = in_list_CGridDataClrAll.GetRange(1, 1);
  208. m_list_cgriddataclr_C = in_list_CGridDataClrAll.GetRange(2, 1);
  209. m_list_cgriddataclr_D = in_list_CGridDataClrAll.GetRange(3, 1);
  210. m_list_cgriddataclr_DS = in_list_CGridDataClrAll.GetRange(4, 1);
  211. m_list_ALL = in_list_CGridDataClrAll;
  212. //初始化底层操作类
  213. // m_OTSIncAReportGridsFun = new OTSIncAReportGridsFun(m_COTSReportProjFileMgrClr, m_list_cgriddataclr_A);
  214. InitializeComponent();
  215. #region 国际化语言
  216. lan = new Language(this);
  217. table = lan.GetNameTable(this.Name);
  218. #endregion
  219. }
  220. private void ChineseStandardABCDDS_Load(object sender, EventArgs e)
  221. {
  222. //从底层结果类对象中,分解出数据保存到datatable中
  223. if (m_list_ALL.Count > 6)
  224. {
  225. int SouseData = (m_COTSReportProjFileMgrClr.GetSmplMsrResultMgrs().Count) * 5;
  226. for (int g = 0; g < m_COTSReportProjFileMgrClr.GetSmplMsrResultMgrs().Count; g++)
  227. {
  228. for (int i = 0; i < 5; i++)
  229. {
  230. DataTable dt = new DataTable();
  231. DataColumn cc = new DataColumn();
  232. int q = g * 6 + i;
  233. dt = ChineseStandardABCD_GetDataTable_Total(DataAll.GetRange(q, 1), out m_oneresult_columnscount_A);
  234. DataGridView aa = new DataGridView();
  235. int start = 40;
  236. int end = 0;
  237. end = 150 * q;
  238. aa.Location = new Point(start, end);
  239. aa.Width = panel1.Width;
  240. aa.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
  241. aa.BackgroundColor = Color.White;
  242. panel1.Controls.Add(aa);
  243. aa.DataSource = dt;
  244. aa.Name = i.ToString();
  245. Label bb = new Label();
  246. int startLabel = 0;
  247. int endLabel = 0;
  248. endLabel = 150 * q;
  249. bb.Location = new Point(startLabel, endLabel);
  250. bb.Width = 75;
  251. for (int t = 0; t < SouseData; t++)
  252. {
  253. if (i == t * 5)
  254. {
  255. bb.Text = table["label1"].ToString();
  256. break;
  257. }
  258. if (i == t * 5 + 1)
  259. {
  260. bb.Text = table["label2"].ToString();
  261. }
  262. if (i == t * 5 + 2)
  263. {
  264. bb.Text = table["label3"].ToString();
  265. }
  266. if (i == t * 5 + 3)
  267. {
  268. bb.Text = table["label4"].ToString();
  269. }
  270. if (i == t * 5 + 4)
  271. {
  272. bb.Text = table["label5"].ToString();
  273. }
  274. }
  275. bb.Font = new Font(bb.Font.Name, 12, FontStyle.Bold | FontStyle.Underline);
  276. panel1.Controls.Add(bb);
  277. }
  278. }
  279. Gview_gzA.Visible = false;
  280. Gview_gzB.Visible = false;
  281. Gview_gzC.Visible = false;
  282. Gview_gzD.Visible = false;
  283. Gview_gzDS.Visible = false;
  284. label1.Visible = false;
  285. label2.Visible = false;
  286. label3.Visible = false;
  287. label4.Visible = false;
  288. label5.Visible = false;
  289. Invalidate();
  290. }
  291. else
  292. {
  293. m_dt_A = ChineseStandardABCD_GetDataTable_Total(m_list_cgriddataclr_A, out m_oneresult_columnscount_A);
  294. m_dt_B = ChineseStandardABCD_GetDataTable_Total(m_list_cgriddataclr_B, out m_oneresult_columnscount_B);
  295. m_dt_C = ChineseStandardABCD_GetDataTable_Total(m_list_cgriddataclr_C, out m_oneresult_columnscount_C);
  296. m_dt_D = ChineseStandardABCD_GetDataTable_Total(m_list_cgriddataclr_D, out m_oneresult_columnscount_D);
  297. m_dt_DS = ChineseStandardABCD_GetDataTable_Total(m_list_cgriddataclr_DS, out m_oneresult_columnscount_DS);
  298. Gview_gzA.DataSource = m_dt_A;
  299. for (int i = 0; i < 13; i++)
  300. {
  301. Gview_gzA.Columns[i].Width = 68;
  302. }
  303. Gview_gzB.DataSource = m_dt_B;
  304. for (int i = 0; i < 13; i++)
  305. {
  306. Gview_gzB.Columns[i].Width = 68;
  307. }
  308. Gview_gzC.DataSource = m_dt_C;
  309. for (int i = 0; i < 13; i++)
  310. {
  311. Gview_gzC.Columns[i].Width = 68;
  312. }
  313. Gview_gzD.DataSource = m_dt_D;
  314. for (int i = 0; i < 13; i++)
  315. {
  316. Gview_gzD.Columns[i].Width = 68;
  317. }
  318. Gview_gzDS.DataSource = m_dt_DS;
  319. Gview_gzA.Width = panel1.Width;
  320. Gview_gzB.Width = panel1.Width;
  321. Gview_gzC.Width = panel1.Width;
  322. Gview_gzD.Width = panel1.Width;
  323. Gview_gzDS.Width = panel1.Width;
  324. }
  325. Invalidate();
  326. }
  327. #endregion
  328. #region 相关事件
  329. /// <summary>
  330. /// 复制选择区域,A
  331. /// </summary>
  332. public void CopySelected_A()
  333. {
  334. //复制选择区域
  335. object oo = Gview_gzA.GetClipboardContent();
  336. Clipboard.SetDataObject(Gview_gzA.GetClipboardContent());
  337. }
  338. /// <summary>
  339. /// 复制选择区域,B
  340. /// </summary>
  341. public void CopySelected_B()
  342. {
  343. //复制选择区域
  344. object oo = Gview_gzB.GetClipboardContent();
  345. Clipboard.SetDataObject(Gview_gzA.GetClipboardContent());
  346. }
  347. /// <summary>
  348. /// 复制选择区域,C
  349. /// </summary>
  350. public void CopySelected_C()
  351. {
  352. //复制选择区域
  353. object oo = Gview_gzC.GetClipboardContent();
  354. Clipboard.SetDataObject(Gview_gzA.GetClipboardContent());
  355. }
  356. /// <summary>
  357. /// 复制选择区域,D
  358. /// </summary>
  359. public void CopySelected_D()
  360. {
  361. //复制选择区域
  362. object oo = Gview_gzD.GetClipboardContent();
  363. Clipboard.SetDataObject(Gview_gzA.GetClipboardContent());
  364. }
  365. /// <summary>
  366. /// 复制选择区域,DS
  367. /// </summary>
  368. public void CopySelected_DS()
  369. {
  370. //复制选择区域
  371. object oo = Gview_gzDS.GetClipboardContent();
  372. Clipboard.SetDataObject(Gview_gzA.GetClipboardContent());
  373. }
  374. /// <summary>
  375. /// 复制所有,A
  376. /// </summary>
  377. public void CopyAll_A()
  378. {
  379. Gview_gzA.SelectAll();
  380. Clipboard.SetDataObject(Gview_gzA.GetClipboardContent());
  381. }
  382. /// <summary>
  383. /// 复制所有,B
  384. /// </summary>
  385. public void CopyAll_B()
  386. {
  387. Gview_gzB.SelectAll();
  388. Clipboard.SetDataObject(Gview_gzB.GetClipboardContent());
  389. }
  390. /// <summary>
  391. /// 复制所有,C
  392. /// </summary>
  393. public void CopyAll_C()
  394. {
  395. Gview_gzC.SelectAll();
  396. Clipboard.SetDataObject(Gview_gzC.GetClipboardContent());
  397. }
  398. /// <summary>
  399. /// 复制所有,D
  400. /// </summary>
  401. public void CopyAll_D()
  402. {
  403. Gview_gzD.SelectAll();
  404. Clipboard.SetDataObject(Gview_gzD.GetClipboardContent());
  405. }
  406. /// <summary>
  407. /// 复制所有,DS
  408. /// </summary>
  409. public void CopyAll_DS()
  410. {
  411. Gview_gzDS.SelectAll();
  412. Clipboard.SetDataObject(Gview_gzDS.GetClipboardContent());
  413. }
  414. private void ToolStripMenuItem1_Click(object sender, EventArgs e)
  415. {
  416. //A,复制整个表
  417. CopyAll_A();
  418. }
  419. private void ToolStripMenuItem2_Click(object sender, EventArgs e)
  420. {
  421. //A,复制选择区域
  422. CopySelected_A();
  423. }
  424. private void toolStripMenuItem4_Click(object sender, EventArgs e)
  425. {
  426. //B,复制整个表
  427. CopyAll_B();
  428. }
  429. private void toolStripMenuItem5_Click(object sender, EventArgs e)
  430. {
  431. //B,复制选择区域
  432. CopySelected_B();
  433. }
  434. private void toolStripMenuItem7_Click(object sender, EventArgs e)
  435. {
  436. //C,复制整个表
  437. CopyAll_C();
  438. }
  439. private void toolStripMenuItem8_Click(object sender, EventArgs e)
  440. {
  441. //C,复制选择区域
  442. CopySelected_C();
  443. }
  444. private void toolStripMenuItem10_Click(object sender, EventArgs e)
  445. {
  446. //D,复制整个表
  447. CopyAll_D();
  448. }
  449. private void toolStripMenuItem11_Click(object sender, EventArgs e)
  450. {
  451. //D,复制选择区域
  452. CopySelected_D();
  453. }
  454. private void toolStripMenuItem13_Click(object sender, EventArgs e)
  455. {
  456. //DS,复制整个表
  457. CopyAll_DS();
  458. }
  459. private void toolStripMenuItem14_Click(object sender, EventArgs e)
  460. {
  461. //DS,复制选择区域
  462. CopySelected_DS();
  463. }
  464. #endregion
  465. #region 获取向导出模块提供的DataTable和GridView对象
  466. /// <summary>
  467. /// 获取到该模块输出后形成的DataTable,和GridView
  468. /// </summary>
  469. /// <param name="out_dt"></param>
  470. /// <param name="out_dg"></param>
  471. public void GetDataTableAndGridView(out DataTable out_dtA, out DataTable out_dtB, out DataTable out_dtC, out DataTable out_dtD, out DataTable out_dtDS,
  472. out DataGridView out_dgA, out DataGridView out_dgB, out DataGridView out_dgC, out DataGridView out_dgD, out DataGridView out_dgDS)
  473. {
  474. //从panel中找出前5个datagridview,然后进行输出
  475. foreach (Control ctl in this.panel1.Controls)
  476. {
  477. if (ctl.Name == "0")
  478. {
  479. this.Gview_gzA = (DataGridView)ctl;
  480. }
  481. if (ctl.Name == "1")
  482. {
  483. this.Gview_gzB = (DataGridView)ctl;
  484. }
  485. if (ctl.Name == "2")
  486. {
  487. this.Gview_gzC = (DataGridView)ctl;
  488. }
  489. if (ctl.Name == "3")
  490. {
  491. this.Gview_gzD = (DataGridView)ctl;
  492. }
  493. if (ctl.Name == "4")
  494. {
  495. this.Gview_gzDS = (DataGridView)ctl;
  496. }
  497. }
  498. out_dtA = m_dt_A;
  499. out_dgA = this.Gview_gzA;
  500. out_dtB = m_dt_B;
  501. out_dgB = this.Gview_gzB;
  502. out_dtC = m_dt_C;
  503. out_dgC = this.Gview_gzC;
  504. out_dtD = m_dt_D;
  505. out_dgD = this.Gview_gzD;
  506. out_dtDS = m_dt_DS;
  507. out_dgDS = this.Gview_gzDS;
  508. }
  509. #endregion
  510. #region clr加载数据部分
  511. public DataTable ChineseStandardABCD_GetDataTable_Total(List<CGridDataClr> in_list_cgriddataclr, out int oneresult_columncount)
  512. {
  513. oneresult_columncount = 1;//一个数据源的跨度,计算出一个数据源包含几个列
  514. //创建一个临时表
  515. DataTable ret_dt = new DataTable();
  516. //判断传入的数据对象是否为空
  517. if (in_list_cgriddataclr == null)
  518. {
  519. string str1 = "传入分解表格数据的CGridDataClr对象为空!";
  520. str1 = table["str1"].ToString();
  521. //log.Error("(OTSIncAReportGridsFun.ChineseStandardABCD_GetDataTable_Total)" + str1);
  522. return ret_dt;
  523. }
  524. #region 根据返回的结构创建DataTable的结构---------------------------------------------
  525. for (int i = 0; i < in_list_cgriddataclr.Count(); i++)
  526. {
  527. //分解结果内容
  528. List<CGridColumnClr> list_cgridcolumnclrs = new List<CGridColumnClr>();
  529. list_cgridcolumnclrs = in_list_cgriddataclr[i].GetGridColumnList(); //获取各列
  530. //单个数据源包含几个列的跨度
  531. if (oneresult_columncount < list_cgridcolumnclrs.Count())
  532. oneresult_columncount = list_cgridcolumnclrs.Count();
  533. if (in_list_cgriddataclr.Count > 1)
  534. {
  535. //创建DT的列,多个数据源,为每个字段带上索引号
  536. foreach (CGridColumnClr ls_cgridcolumnclr in list_cgridcolumnclrs)
  537. {
  538. string ls_fl_strName = ls_cgridcolumnclr.GetName();
  539. //通过获取到的列,创建表的列
  540. ret_dt.Columns.Add(ls_fl_strName + "(" + (i + 1).ToString() + ")");
  541. }
  542. }
  543. else
  544. {
  545. //创建DT的列,单个数据源,不带索引号
  546. foreach (CGridColumnClr ls_cgridcolumnclr in list_cgridcolumnclrs)
  547. {
  548. string ls_fl_strName = ls_cgridcolumnclr.GetName();
  549. //通过获取到的列,创建表的列
  550. ret_dt.Columns.Add(ls_fl_strName);
  551. }
  552. }
  553. }
  554. #endregion
  555. #region 再创建表的行------------------------------------------------------------------
  556. //取最大的rowlistcount,要不然,不知道这底层返回的数据居然还有2,2,3这样的行数据
  557. int maxrownumber = 0;
  558. for (int i = 0; i < in_list_cgriddataclr.Count(); i++)
  559. {
  560. //分解结果内容
  561. List<CGridColumnClr> list_cgridcolumnclrs = new List<CGridColumnClr>();
  562. list_cgridcolumnclrs = in_list_cgriddataclr[i].GetGridColumnList(); //获取各列
  563. //创建DT的行
  564. if (list_cgridcolumnclrs != null)
  565. {
  566. foreach (CGridColumnClr ls_cgridcolumnclr in list_cgridcolumnclrs)
  567. {
  568. if (maxrownumber < ls_cgridcolumnclr.GetRowList().Count())
  569. {
  570. maxrownumber = ls_cgridcolumnclr.GetRowList().Count();
  571. }
  572. }
  573. }
  574. }
  575. for (int k = 0; k < maxrownumber; k++)
  576. {
  577. DataRow dr = ret_dt.NewRow();
  578. ret_dt.Rows.Add(dr);
  579. }
  580. #endregion
  581. #region //再次重新分解,先分解列,然后将获取到的各行各列的数据,填充到相应的位置上---
  582. for (int i = 0; i < in_list_cgriddataclr.Count(); i++)
  583. {
  584. //分解结果内容
  585. List<CGridColumnClr> list_cgridcolumnclrs = new List<CGridColumnClr>();
  586. list_cgridcolumnclrs = in_list_cgriddataclr[i].GetGridColumnList(); //获取各列
  587. //再次重新分解,先分解列,然后将获取到的
  588. for (int k = 0; k < list_cgridcolumnclrs.Count(); k++)
  589. {
  590. string ls_fl_strName = list_cgridcolumnclrs[k].GetName();
  591. List<CGridRowClr> ls_list_cgridrowclr = new List<CGridRowClr>();
  592. ls_list_cgridrowclr = list_cgridcolumnclrs[k].GetRowList();
  593. for (int j = 0; j < ls_list_cgridrowclr.Count(); j++)
  594. {
  595. //先判断该行该单元格的数据类型
  596. string str_value = "";//因为显示只需要对字符串进行操作就可以了,所以将底层获取到的数据,除了颗粒类型外的都转成string
  597. switch (ls_list_cgridrowclr[j].GetDataType())
  598. {
  599. case 0:
  600. //string
  601. str_value = ls_list_cgridrowclr[j].GetStringValue();
  602. ret_dt.Rows[j][k + i * oneresult_columncount] = str_value;
  603. break;
  604. case 1:
  605. //该元素含量表没有需要显示的颗粒图像
  606. //ret_dt.Rows[j][k+i*oneresult_columncount] = GetBitmapByParticleList(ls_list_cgridrowclr[k].GetParticle());
  607. break;
  608. case 2:
  609. //int
  610. str_value = ls_list_cgridrowclr[j].GetIntValue().ToString();
  611. ret_dt.Rows[j][k + i * oneresult_columncount] = str_value;
  612. break;
  613. case 3:
  614. //float
  615. str_value = ls_list_cgridrowclr[j].GetDoubleValue().ToString("0.00");
  616. ret_dt.Rows[j][k + i * oneresult_columncount] = str_value;
  617. break;
  618. default:
  619. str_value = "";
  620. ret_dt.Rows[j][k + i * oneresult_columncount] = str_value;
  621. break;
  622. }
  623. }
  624. }
  625. }
  626. #endregion
  627. return ret_dt;
  628. }
  629. #endregion
  630. }
  631. }