OTSReport_Export.cs 111 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398
  1. using OTSIncAReportApp.Controls;
  2. using OTSIncAReportApp.DataOperation.DataAccess;
  3. using OTSIncAReportApp.OTSSampleReportInfo;
  4. using OTSIncAReportApp.OTSTemplateDesigner;
  5. using OTSIncAReportApp.SysMgrTools;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Data;
  10. using System.Data.SQLite;
  11. using System.Diagnostics;
  12. using System.Drawing;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Windows.Forms;
  16. namespace OTSIncAReportApp
  17. {
  18. public partial class OTSReport_Export : Form
  19. {
  20. #region 全局变量
  21. public string m_thread_flag = "无"; //线程操作的标识
  22. public string m_str_tmpbitmappath = "d:\\1.bmp"; //存放临时图片 的路径名和文件名
  23. public string m_str_tmpbitmappath2 = "d:\\2.bmp";
  24. public string m_str_tmpdocxpath = "d:\\1.doc";
  25. public string m_strDBpath = ""; //报表模板数据库文件
  26. public string m_strDBpathGB = ""; //报告国标导出
  27. public string m_strDBpath_ParticleList = ""; //报表模板,颗粒列表数据库文件
  28. System.Collections.Hashtable table;
  29. public frmReportApp m_ReportApp = null; //报告项目总进程对象
  30. public string m_export_type = "Excel"; //导出文件的格式类型Excel,Word,Pdf
  31. Export_ReportTemplate m_export_reporttemplate;
  32. public string strPath = "./Config/ProData/ReportTemplateConfig.xml"; //报告模板设置文件的路径
  33. public string strPath2;
  34. public XmlConfigUtil xmlutil;
  35. public XmlConfigUtil xmlutil2;
  36. public MBSZClass m_mbszclass = null;
  37. #endregion
  38. #region 条件参数变量
  39. /// <summary>
  40. /// 选择的数据类型
  41. /// </summary>
  42. public string SJLX { get; set; }
  43. /// <summary>
  44. /// 尺寸计算方法
  45. /// </summary>
  46. public string CCJSFF { get; set; }
  47. /// <summary>
  48. /// 粒级表
  49. /// </summary>
  50. public string LJB { get; set; }
  51. /// <summary>
  52. /// 三元相图模板
  53. /// </summary>
  54. public string SYXTMB { get; set; }
  55. #endregion
  56. #region 模板设置类
  57. /// <summary>
  58. /// 模板设置类
  59. /// </summary>
  60. public class MBSZClass
  61. {
  62. public DZ M_DZ { get; set; }
  63. #region 属性
  64. /// <summary>
  65. /// 首页
  66. /// </summary>
  67. public SY M_SY { get; set; }
  68. /// <summary>
  69. /// 页眉页脚
  70. /// </summary>
  71. public YMYJ M_YMYJ { get; set; }
  72. /// <summary>
  73. /// 颗粒分析结果
  74. /// </summary>
  75. public KLFXJG M_KLFXJG { get; set; }
  76. /// <summary>
  77. /// 元素分析结果
  78. /// </summary>
  79. public YSFXJG M_YSFXJG { get; set; }
  80. /// <summary>
  81. /// 三元相图
  82. /// </summary>
  83. public SYXT M_SYXT { get; set; }
  84. /// <summary>
  85. /// 颗粒列表信息
  86. /// </summary>
  87. public KLLBXX M_KLLBXX { get; set; }
  88. #endregion
  89. #region 构造函数
  90. public MBSZClass()
  91. {
  92. M_SY = new SY();
  93. M_YMYJ = new YMYJ();
  94. M_KLFXJG = new KLFXJG();
  95. M_YSFXJG = new YSFXJG();
  96. M_YSFXJG.list_str_tb_yscf_ysxx = new List<string>();
  97. M_YSFXJG.list_str_tb_ysfx_xsys = new List<string>();
  98. M_SYXT = new SYXT();
  99. M_SYXT.list_lbv_syxt_mblb = new List<string>();
  100. M_SYXT.list_lbv_syxt_mblb_index = new List<int>();
  101. M_KLLBXX = new KLLBXX();
  102. M_KLLBXX.list_str_tb_lllb_sxys = new List<string>();
  103. M_DZ = new DZ();
  104. }
  105. #endregion
  106. public class DZ
  107. {
  108. public string route { get; set; }
  109. }
  110. #region 首页部份
  111. public class SY
  112. {
  113. /// <summary>
  114. /// 主标题
  115. /// </summary>
  116. public string str_tb_ZBT { get; set; }
  117. /// <summary>
  118. /// 副标题
  119. /// </summary>
  120. public string str_tb_FBT { get; set; }
  121. /// <summary>
  122. /// 样品编号
  123. /// </summary>
  124. public string str_tb_YPBH { get; set; }
  125. /// <summary>
  126. /// 参考标准
  127. /// </summary>
  128. public string str_tb_CKBZ { get; set; }
  129. /// <summary>
  130. /// 是否显示样品说明
  131. /// </summary>
  132. public bool b_ck_ypsm { get; set; }
  133. /// <summary>
  134. /// 是否显示结果概况
  135. /// </summary>
  136. public bool b_ck_jggk { get; set; }
  137. }
  138. #endregion
  139. #region 页眉页脚部份
  140. public class YMYJ
  141. {
  142. /// <summary>
  143. /// 页眉文本
  144. /// </summary>
  145. public string str_tb_ymwb { get; set; }
  146. /// <summary>
  147. /// 客户号
  148. /// </summary>
  149. public string str_tb_KHH { get; set; }
  150. /// <summary>
  151. /// 是否显示页码
  152. /// </summary>
  153. public bool b_ck_ym { get; set; }
  154. /// <summary>
  155. /// 页脚文本
  156. /// </summary>
  157. public string str_tb_yjwb { get; set; }
  158. }
  159. #endregion
  160. #region 颗粒分析结果部份
  161. public class KLFXJG
  162. {
  163. /// <summary>
  164. /// 是否显示颗粒尺寸分析结果表
  165. /// </summary>
  166. public bool b_ck_klcc_xsmk { get; set; }
  167. /// <summary>
  168. ///颗粒尺寸分析结果表 计算方式文本
  169. /// </summary>
  170. public string str_cb_klcc_jsfs { get; set; }
  171. /// <summary>
  172. ///颗粒尺寸分析结果表 计算方式索引
  173. /// </summary>
  174. public int index_cb_klcc_jsfs { get; set; }
  175. /// <summary>
  176. ///颗粒尺寸分析结果表 粒级表文本
  177. /// </summary>
  178. public string str_cb_klcc_ljb { get; set; }
  179. /// <summary>
  180. ///颗粒尺寸分析结果表 粒级表索引
  181. /// </summary>
  182. public int index_cb_klcc_ljb { get; set; }
  183. /// <summary>
  184. ///颗粒尺寸分析结果表 颗粒选择范围文本
  185. /// </summary>
  186. public string str_cb_klcc_klfw { get; set; }
  187. /// <summary>
  188. ///颗粒尺寸分析结果表 颗粒选择范围索引
  189. /// </summary>
  190. public int index_cb_klcc_klfw { get; set; }
  191. /// <summary>
  192. /// 夹杂物分类图 是否显示该模块
  193. /// </summary>
  194. public bool b_cb_jzwfl_xsmk { get; set; }
  195. /// <summary>
  196. ///夹杂物分类图 显示图形选择文本
  197. /// </summary>
  198. public string str_cb_jzwfl_xstx { get; set; }
  199. /// <summary>
  200. ///夹杂物分类图 显示图形 选择索引
  201. /// </summary>
  202. public int index_cb_jzwfl_xstx { get; set; }
  203. /// <summary>
  204. ///夹杂物分类图 计算方式 选择文本
  205. /// </summary>
  206. public string str_cb_jzwfl_jsfs { get; set; }
  207. /// <summary>
  208. ///夹杂物分类图 计算方式 选择索引
  209. /// </summary>
  210. public int index_cb_jzwfl_jsfs { get; set; }
  211. /// <summary>
  212. ///夹杂物分类图 粒级表 选择文本
  213. /// </summary>
  214. public string str_cb_jzwfl_ljb { get; set; }
  215. /// <summary>
  216. ///夹杂物分类图 粒级表 选择索引
  217. /// </summary>
  218. public int index_cb_jzwfl_ljb { get; set; }
  219. /// <summary>
  220. ///夹杂物分类图 颗粒范围 选择文本
  221. /// </summary>
  222. public string str_cb_jzwfl_klfw { get; set; }
  223. /// <summary>
  224. ///夹杂物分类图 颗粒范围 选择索引
  225. /// </summary>
  226. public int index_cb_jzwfl_klfw { get; set; }
  227. }
  228. #endregion
  229. #region 元素分析结果部份
  230. public class YSFXJG
  231. {
  232. /// <summary>
  233. /// 元素分析表 是否显示该模块
  234. /// </summary>
  235. public bool b_ck_ysfx_xsmk { get; set; }
  236. /// <summary>
  237. /// 元素分析表 计算方式 选择文本
  238. /// </summary>
  239. public string str_cb_yxfx_jsfs { get; set; }
  240. /// <summary>
  241. /// 元素分析表 计算方式 选择索引
  242. /// </summary>
  243. public int index_cb_yxfx_jsfs { get; set; }
  244. /// <summary>
  245. /// 元素分析表 颗粒范围 选择文本
  246. /// </summary>
  247. public string str_cb_ysfx_klfw { get; set; }
  248. /// <summary>
  249. /// 元素分析表 颗粒范围 选择索引
  250. /// </summary>
  251. public int index_cb_ysfx_klfw { get; set; }
  252. /// <summary>
  253. /// 元素分析表 显示元素显示文本
  254. /// </summary>
  255. public string str_tb_ysfx_xsys { get; set; }
  256. /// <summary>
  257. /// 元素分析表 显示元素拆分元素列表
  258. /// </summary>
  259. public List<string> list_str_tb_ysfx_xsys { get; set; }
  260. /// <summary>
  261. /// 元素成份图 是否显示该模块
  262. /// </summary>
  263. public bool b_ck_yscf_xsmk { get; set; }
  264. /// <summary>
  265. /// 元素成份图 显示图形 文本
  266. /// </summary>
  267. public string str_cb_yscf_xstx { get; set; }
  268. /// <summary>
  269. /// 元素成份图 显示图形 索引
  270. /// </summary>
  271. public int index_cb_yscf_xstx { get; set; }
  272. /// <summary>
  273. /// 元素成份图 计算方式 文本
  274. /// </summary>
  275. public string str_cb_yscf_jsfs { get; set; }
  276. /// <summary>
  277. /// 元素成份图 计算方式 索引
  278. /// </summary>
  279. public int index_cb_yscf_jsfs { get; set; }
  280. /// <summary>
  281. /// 元素成份图 颗粒范围 文本
  282. /// </summary>
  283. public string str_cb_yscf_klfw { get; set; }
  284. /// <summary>
  285. /// 元素成份图 颗粒范围 索引
  286. /// </summary>
  287. public int index_cb_yscf_klfw { get; set; }
  288. /// <summary>
  289. /// 元素成份图 元素信息
  290. /// </summary>
  291. public string str_tb_yscf_ysxx { get; set; }
  292. /// <summary>
  293. /// 元素成份图 元素信息列表拆分字符列表
  294. /// </summary>
  295. public List<string> list_str_tb_yscf_ysxx { get; set; }
  296. }
  297. #endregion
  298. #region 三元相图部份
  299. public class SYXT
  300. {
  301. /// <summary>
  302. /// 三元相图 是否显示该模块
  303. /// </summary>
  304. public bool b_ck_syxt_xsmk { get; set; }
  305. /// <summary>
  306. /// 计算方式 文本
  307. /// </summary>
  308. public string str_cb_syxt_jsfs { get; set; }
  309. /// <summary>
  310. /// 计算方式 索引
  311. /// </summary>
  312. public int index_cb_syxt_jsfs { get; set; }
  313. /// <summary>
  314. /// 颗粒范围 文本
  315. /// </summary>
  316. public string str_cb_syxt_klfw { get; set; }
  317. /// <summary>
  318. /// 颗粒范围 索引
  319. /// </summary>
  320. public int index_cb_syxt_klfw { get; set; }
  321. /// <summary>
  322. /// 粒级表信息 文本
  323. /// </summary>
  324. public string str_cb_syxt_ljb { get; set; }
  325. /// <summary>
  326. /// 粒级表信息 索引
  327. /// </summary>
  328. public int index_cb_syxt_ljb { get; set; }
  329. /// <summary>
  330. /// 每行显示数量 文本
  331. /// </summary>
  332. public string str_cb_syxt_mhxssl { get; set; }
  333. /// <summary>
  334. /// 每行显示数量 索引
  335. /// </summary>
  336. public int index_cb_syxt_mhxssl { get; set; }
  337. /// <summary>
  338. /// 三元相图模板集合列表
  339. /// </summary>
  340. public List<string> list_lbv_syxt_mblb { get; set; }
  341. /// <summary>
  342. /// 三元相图模板索引集合列表
  343. /// </summary>
  344. public List<int> list_lbv_syxt_mblb_index { get; set; }
  345. }
  346. #endregion
  347. #region 颗粒列表信息部份
  348. public class KLLBXX
  349. {
  350. /// <summary>
  351. /// 颗粒列表 是否显示该模块
  352. /// </summary>
  353. public bool b_ck_kllb_xsmk { get; set; }
  354. /// <summary>
  355. /// 颗粒列表 计算方式 文本
  356. /// </summary>
  357. public string str_cb_kllb_jsfs { get; set; }
  358. /// <summary>
  359. /// 颗粒列表 计算方式 索引
  360. /// </summary>
  361. public int index_cb_kllb_jsfs { get; set; }
  362. /// <summary>
  363. /// 颗粒列表 颗粒范围 文本
  364. /// </summary>
  365. public string str_cb_kllb_klfw { get; set; }
  366. /// <summary>
  367. /// 颗粒列表 颗粒范围 索引
  368. /// </summary>
  369. public int index_cb_kllb_klfw { get; set; }
  370. /// <summary>
  371. /// 颗粒列表 数量上限
  372. /// </summary>
  373. public int int_tb_kllb_ylsx { get; set; }
  374. /// <summary>
  375. /// 颗粒列表 显示元素
  376. /// </summary>
  377. public string str_tb_kllb_sxys { get; set; }
  378. /// <summary>
  379. /// 颗粒列表 显示元素拆分元素列表
  380. /// </summary>
  381. public List<string> list_str_tb_lllb_sxys { get; set; }
  382. /// <summary>
  383. /// 颗粒列表 是否显示原始图像
  384. /// </summary>
  385. public bool b_ck_kllb_ystx { get; set; }
  386. /// <summary>
  387. /// 颗粒列表 是否显示放大图像
  388. /// </summary>
  389. public bool b_ck_kllb_fdtx { get; set; }
  390. /// <summary>
  391. /// 颗粒列表 是否显示能谱信息
  392. /// </summary>
  393. public bool b_ck_kllb_npxx { get; set; }
  394. }
  395. #endregion
  396. }
  397. #endregion
  398. #region 窗体加载及构造函数
  399. public OTSReport_Export(frmReportApp ReportApp)
  400. {
  401. InitializeComponent();
  402. m_ReportApp = ReportApp;
  403. m_export_reporttemplate = new Export_ReportTemplate(this);
  404. //初始化xml类
  405. xmlutil = new XmlConfigUtil(strPath);
  406. m_mbszclass = new MBSZClass();
  407. //读取配置文件中的模板
  408. LoadMBSZClass();
  409. LoadRouteclass();
  410. #region 国际化语言
  411. Language lan = new Language(this);
  412. table = lan.GetNameTable(this.Name);
  413. #endregion
  414. }
  415. ///<summary>
  416. ///从配置文件中读取报告模板信息
  417. /// </summary>
  418. private void LoadRouteclass()
  419. {
  420. if (m_mbszclass.M_DZ.route == null)
  421. {
  422. strPath2 = strPath;
  423. m_mbszclass.M_DZ.route = strPath;
  424. }
  425. else
  426. if (m_mbszclass.M_DZ.route == "")
  427. {
  428. strPath2 = strPath;
  429. m_mbszclass.M_DZ.route = strPath;
  430. }
  431. else
  432. {
  433. strPath2 = m_mbszclass.M_DZ.route;
  434. }
  435. xmlutil2 = new XmlConfigUtil(strPath2);
  436. //首页
  437. m_mbszclass.M_SY.str_tb_ZBT = xmlutil2.Read("M_SY", "str_tb_ZBT");
  438. m_mbszclass.M_SY.str_tb_FBT = xmlutil2.Read("M_SY", "str_tb_FBT");
  439. m_mbszclass.M_SY.str_tb_YPBH = xmlutil2.Read("M_SY", "str_tb_YPBH");
  440. m_mbszclass.M_SY.str_tb_CKBZ = xmlutil2.Read("M_SY", "str_tb_CKBZ");
  441. m_mbszclass.M_SY.b_ck_ypsm = Convert.ToBoolean(xmlutil2.Read("M_SY", "b_ck_ypsm"));
  442. m_mbszclass.M_SY.b_ck_jggk = Convert.ToBoolean(xmlutil2.Read("M_SY", "b_ck_jggk"));
  443. //页眉页脚
  444. m_mbszclass.M_YMYJ.str_tb_ymwb = xmlutil2.Read("M_YMYJ", "str_tb_ymwb");
  445. m_mbszclass.M_YMYJ.str_tb_KHH = xmlutil2.Read("M_YMYJ", "str_tb_KHH");
  446. m_mbszclass.M_YMYJ.b_ck_ym = Convert.ToBoolean(xmlutil2.Read("M_YMYJ", "b_ck_ym"));
  447. m_mbszclass.M_YMYJ.str_tb_yjwb = xmlutil2.Read("M_YMYJ", "str_tb_yjwb");
  448. //颗粒分析结果
  449. m_mbszclass.M_KLFXJG.b_ck_klcc_xsmk = Convert.ToBoolean(xmlutil2.Read("M_KLFXJG", "b_ck_klcc_xsmk"));//是否显示模块
  450. m_mbszclass.M_KLFXJG.index_cb_klcc_jsfs = Convert.ToInt32(xmlutil2.Read("M_KLFXJG", "index_cb_klcc_jsfs"));//计算方式
  451. m_mbszclass.M_KLFXJG.index_cb_klcc_ljb = Convert.ToInt32(xmlutil2.Read("M_KLFXJG", "index_cb_klcc_ljb"));//粒级表
  452. m_mbszclass.M_KLFXJG.index_cb_klcc_klfw = Convert.ToInt32(xmlutil2.Read("M_KLFXJG", "index_cb_klcc_klfw"));//颗粒范围
  453. m_mbszclass.M_KLFXJG.b_cb_jzwfl_xsmk = Convert.ToBoolean(xmlutil2.Read("M_KLFXJG", "b_cb_jzwfl_xsmk"));//是否显示该模块
  454. m_mbszclass.M_KLFXJG.index_cb_jzwfl_xstx = Convert.ToInt32(xmlutil2.Read("M_KLFXJG", "index_cb_jzwfl_xstx"));//选择图像
  455. m_mbszclass.M_KLFXJG.index_cb_jzwfl_jsfs = Convert.ToInt32(xmlutil2.Read("M_KLFXJG", "index_cb_jzwfl_jsfs"));//计算方式
  456. m_mbszclass.M_KLFXJG.index_cb_jzwfl_ljb = Convert.ToInt32(xmlutil2.Read("M_KLFXJG", "index_cb_jzwfl_ljb"));//粒级表
  457. m_mbszclass.M_KLFXJG.index_cb_jzwfl_klfw = Convert.ToInt32(xmlutil2.Read("M_KLFXJG", "index_cb_jzwfl_klfw"));//颗粒范围
  458. //元素分析结果
  459. m_mbszclass.M_YSFXJG.b_ck_ysfx_xsmk = Convert.ToBoolean(xmlutil2.Read("M_YSFXJG", "b_ck_ysfx_xsmk")); //是否显示模块
  460. m_mbszclass.M_YSFXJG.index_cb_yxfx_jsfs = Convert.ToInt32(xmlutil2.Read("M_YSFXJG", "index_cb_yxfx_jsfs")); //计算方式
  461. m_mbszclass.M_YSFXJG.index_cb_ysfx_klfw = Convert.ToInt32(xmlutil2.Read("M_YSFXJG", "index_cb_ysfx_klfw")); //颗粒范围
  462. m_mbszclass.M_YSFXJG.str_tb_ysfx_xsys = xmlutil2.Read("M_YSFXJG", "str_tb_ysfx_xsys"); //显示元素
  463. m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys.Clear();
  464. for (int i = 0; i < 100; i++) //取得所有元素列表
  465. {
  466. string str = xmlutil2.Read("M_YSFXJG", "list_str_tb_ysfx_xsys", "YS" + i.ToString());
  467. if (str == null)
  468. {
  469. break;
  470. }
  471. else
  472. {
  473. m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys.Add(str);
  474. }
  475. }
  476. m_mbszclass.M_YSFXJG.b_ck_yscf_xsmk = Convert.ToBoolean(xmlutil2.Read("M_YSFXJG", "b_ck_yscf_xsmk")); //是否显示模块
  477. m_mbszclass.M_YSFXJG.index_cb_yscf_xstx = Convert.ToInt32(xmlutil2.Read("M_YSFXJG", "index_cb_yscf_xstx")); //显示图形
  478. m_mbszclass.M_YSFXJG.index_cb_yscf_jsfs = Convert.ToInt32(xmlutil2.Read("M_YSFXJG", "index_cb_yscf_jsfs")); //计算方式
  479. m_mbszclass.M_YSFXJG.index_cb_yscf_klfw = Convert.ToInt32(xmlutil2.Read("M_YSFXJG", "index_cb_yscf_klfw")); //颗粒范围
  480. m_mbszclass.M_YSFXJG.str_tb_yscf_ysxx = xmlutil2.Read("M_YSFXJG", "str_tb_yscf_ysxx"); //显示元素
  481. m_mbszclass.M_YSFXJG.list_str_tb_yscf_ysxx.Clear();
  482. for (int i = 0; i < 100; i++) //取得所有元素列表
  483. {
  484. string str = xmlutil2.Read("M_YSFXJG", "list_str_tb_yscf_ysxx", "YS" + i.ToString());
  485. if (str == null)
  486. {
  487. break;
  488. }
  489. else
  490. {
  491. m_mbszclass.M_YSFXJG.list_str_tb_yscf_ysxx.Add(str);
  492. }
  493. }
  494. //三元相图
  495. m_mbszclass.M_SYXT.b_ck_syxt_xsmk = Convert.ToBoolean(xmlutil2.Read("M_SYXT", "b_ck_syxt_xsmk")); //是否显示模块
  496. m_mbszclass.M_SYXT.index_cb_syxt_jsfs = Convert.ToInt32(xmlutil2.Read("M_SYXT", "index_cb_syxt_jsfs")); //计算方式
  497. m_mbszclass.M_SYXT.index_cb_syxt_klfw = Convert.ToInt32(xmlutil2.Read("M_SYXT", "index_cb_syxt_klfw")); //颗粒范围
  498. m_mbszclass.M_SYXT.str_cb_syxt_mhxssl = xmlutil2.Read("M_SYXT", "str_cb_syxt_mhxssl"); //每行显示数量
  499. m_mbszclass.M_SYXT.list_lbv_syxt_mblb.Clear();
  500. for (int i = 0; i < 100; i++) //取得所有模板列表
  501. {
  502. string str = xmlutil2.Read("M_SYXT", "list_lbv_syxt_mblb", "MB" + i.ToString());
  503. if (str == null)
  504. {
  505. break;
  506. }
  507. else
  508. {
  509. m_mbszclass.M_SYXT.list_lbv_syxt_mblb.Add(str);
  510. }
  511. }
  512. m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Clear();
  513. for (int i = 0; i < 100; i++) //取得所有模板列表 索引
  514. {
  515. string str = xmlutil2.Read("M_SYXT", "list_lbv_syxt_mblb_index", "MBIndex" + i.ToString());
  516. if (str == null)
  517. {
  518. break;
  519. }
  520. else
  521. {
  522. m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Add(Convert.ToInt32(str));
  523. }
  524. }
  525. //颗粒列表信息
  526. m_mbszclass.M_KLLBXX.b_ck_kllb_xsmk = Convert.ToBoolean(xmlutil2.Read("M_KLLBXX", "b_ck_kllb_xsmk")); //是否显示模块
  527. m_mbszclass.M_KLLBXX.index_cb_kllb_jsfs = Convert.ToInt32(xmlutil2.Read("M_KLLBXX", "index_cb_kllb_jsfs")); //计算方式
  528. m_mbszclass.M_KLLBXX.index_cb_kllb_klfw = Convert.ToInt32(xmlutil2.Read("M_KLLBXX", "index_cb_kllb_klfw")); //颗粒范围
  529. m_mbszclass.M_KLLBXX.int_tb_kllb_ylsx = Convert.ToInt32(xmlutil2.Read("M_KLLBXX", "int_tb_kllb_ylsx")); //数量上限
  530. m_mbszclass.M_KLLBXX.str_tb_kllb_sxys = xmlutil2.Read("M_KLLBXX", "str_tb_kllb_sxys"); //显示元素
  531. m_mbszclass.M_KLLBXX.list_str_tb_lllb_sxys.Clear();
  532. for (int i = 0; i < 100; i++) //取得所有元素列表
  533. {
  534. string str = xmlutil2.Read("M_KLLBXX", "list_str_tb_lllb_sxys", "YS" + i.ToString());
  535. if (str == null)
  536. {
  537. break;
  538. }
  539. else
  540. {
  541. m_mbszclass.M_KLLBXX.list_str_tb_lllb_sxys.Add(str);
  542. }
  543. }
  544. m_mbszclass.M_KLLBXX.b_ck_kllb_ystx = Convert.ToBoolean(xmlutil2.Read("M_KLLBXX", "b_ck_kllb_ystx")); //原始图像
  545. m_mbszclass.M_KLLBXX.b_ck_kllb_fdtx = Convert.ToBoolean(xmlutil2.Read("M_KLLBXX", "b_ck_kllb_fdtx")); //放大图像
  546. m_mbszclass.M_KLLBXX.b_ck_kllb_npxx = Convert.ToBoolean(xmlutil2.Read("M_KLLBXX", "b_ck_kllb_npxx")); //能谱图像
  547. }
  548. /// <summary>
  549. /// 从配置文件中读取报告模板路径
  550. /// </summary>
  551. private void LoadMBSZClass()
  552. {
  553. //文件路径
  554. m_mbszclass.M_DZ.route = xmlutil.Read("M_address", "Path");
  555. if (m_mbszclass.M_DZ.route == "")
  556. {
  557. tb_mblj.Text = strPath;
  558. m_mbszclass.M_DZ.route = strPath;
  559. }
  560. else
  561. if (File.Exists(m_mbszclass.M_DZ.route))
  562. {
  563. tb_mblj.Text = m_mbszclass.M_DZ.route;
  564. }
  565. else
  566. {
  567. tb_mblj.Text = strPath;
  568. m_mbszclass.M_DZ.route = strPath;
  569. }
  570. }
  571. /// <summary>
  572. /// 将报告模板信息保存到配置文件中
  573. /// </summary>
  574. private void SaveMBSClass()
  575. {
  576. //文件路径
  577. xmlutil.Write(m_mbszclass.M_DZ.route.ToString(), "M_address", "Path");
  578. }
  579. /// <summary>
  580. /// 传入,3个层级的xml结点标识,进行删除结点
  581. /// </summary>
  582. /// <param name="strnode_mk"></param>
  583. /// <param name="strnode_kj"></param>
  584. /// <param name="strnode_xh"></param>
  585. private void RemoveMBSZClassNode(string strnode_mk, string strnode_kj, string strnode_xh, int int_start)
  586. {
  587. for (int i = int_start; i < 1000; i++)
  588. {
  589. string strxh = i.ToString();
  590. if (null != xmlutil.Read(strnode_mk, strnode_kj, strnode_xh + strxh))
  591. {
  592. //删除该节点
  593. xmlutil.RemoveNode(strnode_mk, strnode_kj, strnode_xh + strxh);
  594. }
  595. else
  596. {
  597. break;
  598. }
  599. }
  600. }
  601. /// <summary>
  602. /// 加载报告模板选择项,数据源选项
  603. /// </summary>
  604. private void BindComboBox()
  605. {
  606. //加载数据源
  607. for (int i = 0; i < m_ReportApp.m_rstDataMgr.ResultFilesList.Count; i++)
  608. {
  609. cbo_sjy.Items.Add(m_ReportApp.m_rstDataMgr.ResultFilesList[i].FileName);
  610. }
  611. if (cbo_sjy.Items.Count > 0)
  612. cbo_sjy.SelectedIndex = 0;
  613. }
  614. private void OTSReport_Export_Load(object sender, EventArgs e)
  615. {
  616. //先获取D盘,如果没有,则再获取C盘
  617. string str_drivename = GetSecondDriveName();
  618. if (str_drivename == "")
  619. str_drivename = GetFirstDriveName();
  620. //初始化临时文件位置
  621. m_str_tmpbitmappath = str_drivename + "1.bmp";
  622. m_str_tmpbitmappath2 = str_drivename + "2.bmp";
  623. m_str_tmpdocxpath = str_drivename + "1.doc";
  624. //窗体加载时,初始化Combobox
  625. BindComboBox();
  626. //设置界面线程
  627. backgroundWorker2.WorkerReportsProgress = true;
  628. backgroundWorker2.WorkerSupportsCancellation = true;
  629. //确定报表进程db数据库的路径
  630. string strdbname = "ReportTemplateDB.db";
  631. m_strDBpath = m_ReportApp.m_rstDataMgr.ResultFilesList[cbo_sjy.SelectedIndex].FilePath;
  632. m_strDBpathGB = m_ReportApp.m_rstDataMgr.ResultFilesList[cbo_sjy.SelectedIndex].FilePath;
  633. m_strDBpath = m_strDBpath + "\\" + strdbname;
  634. m_strDBpathGB = m_strDBpathGB + "\\" + "ReportGBDB.db";
  635. string strdbparticlelistname = "ReportTemplateDBParticleList.db";
  636. m_strDBpath_ParticleList = m_ReportApp.m_rstDataMgr.ResultFilesList[cbo_sjy.SelectedIndex].FilePath;
  637. m_strDBpath_ParticleList = m_strDBpath_ParticleList + "\\" + strdbparticlelistname;
  638. }
  639. #endregion
  640. #region 自定义方法
  641. /// <summary>
  642. /// 传入完整的路径及文件名,和需要的扩展名,返回文件加上需要的扩展名
  643. /// </summary>
  644. /// <param name="in_str"></param>
  645. /// <param name="in_extename"></param>
  646. /// <returns></returns>
  647. public string GetFileExteName(string in_str, string in_extename)
  648. {
  649. string ret_str = in_str.Substring(0, in_str.IndexOf('.'));
  650. ret_str = ret_str + in_extename;
  651. return ret_str;
  652. }
  653. /// <summary>
  654. /// 获取第一个磁盘盘符的名称
  655. /// </summary>
  656. /// <returns></returns>
  657. public string GetFirstDriveName()
  658. {
  659. System.IO.DriveInfo[] ls_driveinfo = System.IO.DriveInfo.GetDrives();
  660. if (ls_driveinfo.Count() > 0)
  661. return ls_driveinfo[0].Name;
  662. return "";
  663. }
  664. /// <summary>
  665. /// 获取第二个磁盘盘符的名称,因为有时c盘不会给予读写的权限,所以要用到这个
  666. /// </summary>
  667. /// <returns></returns>
  668. private string GetSecondDriveName()
  669. {
  670. System.IO.DriveInfo[] ls_driveinfo = System.IO.DriveInfo.GetDrives();
  671. if (ls_driveinfo.Count() > 1)
  672. return ls_driveinfo[1].Name;
  673. return "";
  674. }
  675. /// <summary>
  676. /// 将文本追加到RictBox的尾部上
  677. /// </summary>
  678. public void WriteRictBox(string in_str)
  679. {
  680. //追加到rictbox尾部
  681. richTextBox1.AppendText("[" + DateTime.Now.Hour.ToString() + ":"
  682. + DateTime.Now.Minute.ToString() + ":"
  683. + DateTime.Now.Second.ToString() + "]"
  684. + in_str + Environment.NewLine);
  685. richTextBox1.SelectionColor = GetRandomColor30(30);
  686. richTextBox1.ScrollToCaret();
  687. }
  688. /// <summary>
  689. /// 重载输出文本,带有可以指定颜色
  690. /// </summary>
  691. /// <param name="in_str"></param>
  692. /// <param name="in_c"></param>
  693. public void WriteRictBox(string in_str, Color in_c)
  694. {
  695. //追加到rictbox尾部
  696. richTextBox1.AppendText("[" + DateTime.Now.Hour.ToString() + ":"
  697. + DateTime.Now.Minute.ToString() + ":"
  698. + DateTime.Now.Second.ToString() + "]"
  699. + in_str + Environment.NewLine);
  700. richTextBox1.SelectionColor = in_c;
  701. richTextBox1.ScrollToCaret();
  702. }
  703. /// <summary>
  704. /// 根据传入的颜色,及传入Size的大小,返回一个该色的bitmap对象
  705. /// </summary>
  706. /// <param name="in_c"></param>
  707. /// <returns></returns>
  708. public Bitmap GetBitmapByColor(Color in_c, Size in_z)
  709. {
  710. Bitmap bmp = new Bitmap(in_z.Width, in_z.Height); //这里给104是为了左边和右边空出2个像素,剩余的100就是百分比的值
  711. Graphics g = Graphics.FromImage(bmp);
  712. g.Clear(Color.White);
  713. SolidBrush drawBrush = new SolidBrush(Color.Black);
  714. g.FillRectangle(new SolidBrush(in_c), 0, 0, in_z.Width, in_z.Height);
  715. return bmp;
  716. }
  717. /// <summary>
  718. /// [颜色:16进制转成RGB]
  719. /// </summary>
  720. /// <param name="strColor">设置16进制颜色 [返回RGB]</param>
  721. /// <returns></returns>
  722. public System.Drawing.Color colorHx16toRGB(string strHxColor)
  723. {
  724. try
  725. {
  726. if (strHxColor.Length == 0)
  727. {//如果为空
  728. return System.Drawing.Color.FromArgb(0, 0, 0);//设为黑色
  729. }
  730. else
  731. {//转换颜色
  732. if (strHxColor.IndexOf('#') > -1)
  733. {
  734. //如果颜色格式是 #0000FF 格式的
  735. return System.Drawing.Color.FromArgb(System.Int32.Parse(strHxColor.Substring(1, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(3, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(5, 2), System.Globalization.NumberStyles.AllowHexSpecifier));
  736. }
  737. else
  738. {
  739. //如果颜色格式是 0000FF 格式的
  740. return System.Drawing.Color.FromArgb(System.Int32.Parse(strHxColor.Substring(0, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(2, 2), System.Globalization.NumberStyles.AllowHexSpecifier), System.Int32.Parse(strHxColor.Substring(4, 2), System.Globalization.NumberStyles.AllowHexSpecifier));
  741. }
  742. }
  743. }
  744. catch
  745. {//设为黑色
  746. return System.Drawing.Color.FromArgb(0, 0, 0);
  747. }
  748. }
  749. /// <summary>
  750. /// [颜色:RGB转成16进制]专为输出Excel表头格式而定制,其它地方不要使用该方法,或修改返回加#号,例#000000FF
  751. /// </summary>
  752. /// <param name="R">红 int</param>
  753. /// <param name="G">绿 int</param>
  754. /// <param name="B">蓝 int</param>
  755. /// <returns></returns>
  756. public string colorRGBtoHx16ForExcel(Color color)
  757. {
  758. if (color.IsEmpty)
  759. return "000000";
  760. return String.Format("{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B);
  761. }
  762. /// <summary>
  763. /// 将RGB颜色转成整数
  764. /// </summary>
  765. /// <param name="color"></param>
  766. /// <returns></returns>
  767. public int ParseRGB(Color color)
  768. {
  769. return (int)(((int)color.B << 16) | (ushort)(((ushort)color.G << 8) | color.R));
  770. }
  771. /// <summary>
  772. /// 从指定的几种颜色中进行随机颜色,传入30个颜色的范围,越大颜色越多
  773. /// </summary>
  774. /// <returns></returns>
  775. public Color GetRandomColor30(int i_randomrange)
  776. {
  777. Random r = new Random();
  778. int n = r.Next(0, i_randomrange);
  779. Color ret_color;
  780. switch (n)
  781. {
  782. case 1:
  783. ret_color = Color.Aqua;
  784. break;
  785. case 2:
  786. ret_color = Color.Black;
  787. break;
  788. case 3:
  789. ret_color = Color.Blue;
  790. break;
  791. case 4:
  792. ret_color = Color.BlueViolet;
  793. break;
  794. case 5:
  795. ret_color = Color.Brown;
  796. break;
  797. case 6:
  798. ret_color = Color.BurlyWood;
  799. break;
  800. case 7:
  801. ret_color = Color.CadetBlue;
  802. break;
  803. case 8:
  804. ret_color = Color.CadetBlue;
  805. break;
  806. case 9:
  807. ret_color = Color.CornflowerBlue;
  808. break;
  809. case 10:
  810. ret_color = Color.DarkBlue;
  811. break;
  812. case 11:
  813. ret_color = Color.Gray;
  814. break;
  815. case 12:
  816. ret_color = Color.Indigo;
  817. break;
  818. case 13:
  819. ret_color = Color.LightSlateGray;
  820. break;
  821. case 14:
  822. ret_color = Color.Magenta;
  823. break;
  824. case 15:
  825. ret_color = Color.Maroon;
  826. break;
  827. case 16:
  828. ret_color = Color.MediumBlue;
  829. break;
  830. case 17:
  831. ret_color = Color.MediumOrchid;
  832. break;
  833. case 18:
  834. ret_color = Color.MidnightBlue;
  835. break;
  836. case 19:
  837. ret_color = Color.Navy;
  838. break;
  839. case 20:
  840. ret_color = Color.Olive;
  841. break;
  842. case 21:
  843. ret_color = Color.PaleVioletRed;
  844. break;
  845. case 22:
  846. ret_color = Color.Peru;
  847. break;
  848. case 23:
  849. ret_color = Color.Purple;
  850. break;
  851. case 24:
  852. ret_color = Color.Red;
  853. break;
  854. case 25:
  855. ret_color = Color.RosyBrown;
  856. break;
  857. case 26:
  858. ret_color = Color.RoyalBlue;
  859. break;
  860. case 27:
  861. ret_color = Color.SaddleBrown;
  862. break;
  863. case 28:
  864. ret_color = Color.SeaGreen;
  865. break;
  866. case 29:
  867. ret_color = Color.Teal;
  868. break;
  869. case 30:
  870. ret_color = Color.Tomato;
  871. break;
  872. case 31:
  873. ret_color = Color.YellowGreen;
  874. break;
  875. default:
  876. ret_color = Color.Black;
  877. break;
  878. }
  879. return ret_color;
  880. }
  881. /// <summary>
  882. /// 打开报表模板进程
  883. /// </summary>
  884. private void OpenOTSINcAreportTemplateAPP()
  885. {
  886. //----------------------------------
  887. //共传4个参数
  888. //参数1:是需要打开db数据库的路径
  889. //参数2:是打开报表模板xml文件的路径
  890. //参数3:是要执行查看报表的类型,输出主报表,还是输出颗粒列表
  891. //参数4:打开主报表时是是指定夹杂物的数量,打开颗粒列表时,是颗粒列表显示的范围如,0-50,50-100
  892. //参数5:是要执行查看报表的类型,输出主报表时,指定读取的标记帧图图像范围,如0-50,50-100,输出颗粒列表时无用
  893. //----------------------------------
  894. //Process[] processes = Process.GetProcesses();
  895. //foreach (Process proc in processes)
  896. //{
  897. // if (proc.ProcessName == "OTSIncAReportTemplate")
  898. // {
  899. // proc.Kill();-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  900. // proc.WaitForExit();
  901. // break;
  902. // }
  903. //}
  904. ProcessStartInfo process = new ProcessStartInfo();
  905. process.FileName = "ReportTemplateExe\\OTSIncAReportTemplate.exe";//打开app的路径
  906. string arg1 = m_strDBpath.Replace(" ", "^");//参数1,是需要打开db数据库的路径
  907. string arg2 = tb_mblj.Text.Trim().Replace(" ", "^");//参数2,是模板文件的路径
  908. string arg3 = "MainReport";//主体报表
  909. string arg4 = "100";//夹杂物数量
  910. string arg5 = "0-100";//打开的标记帧图图像数量
  911. process.Arguments = string.Format("{0} {1} {2} {3} {4}", arg1, arg2, arg3, arg4, arg5); //多个参数用空格隔开
  912. process.WindowStyle = ProcessWindowStyle.Normal;
  913. Process.Start(process);
  914. }
  915. /// <summary>
  916. /// 打开报表模板进程,颗粒列表
  917. /// </summary>
  918. public void OpenOTSINcAreportTemplateAPP_ParticleList(string arg4)
  919. {
  920. //----------------------------------
  921. //共传4个参数
  922. //参数1:是需要打开db数据库的路径
  923. //参数2:是打开报表模板xml文件的路径
  924. //参数3:是要执行查看报表的类型,输出主报表,还是输出颗粒列表
  925. //参数4:打开主报表时是是指定夹杂物的数量,打开颗粒列表时,是颗粒列表显示的范围如,0-50,50-100
  926. //参数5:是要执行查看报表的类型,输出主报表时,指定读取的标记帧图图像范围,如0-50,50-100,输出颗粒列表时无用
  927. //----------------------------------
  928. ProcessStartInfo process = new ProcessStartInfo();
  929. process.FileName = "ReportTemplateExe\\OTSIncAReportTemplate.exe";//打开app的路径
  930. string arg1 = m_strDBpath_ParticleList.Replace(" ", "^");//参数1,是需要打开db数据库的路径
  931. string arg2 = tb_mblj.Text.Trim().Replace(" ", "^");//参数2,是模板文件的路径
  932. string arg3 = "ParticleListReport";//颗粒列表
  933. //string arg4 = "";//夹杂物数量,从多少到多少
  934. string arg5 = "0";//在打开颗粒列表时,传的标记帧图图像数量参数暂不用
  935. process.Arguments = string.Format("{0} {1} {2} {3} {4}", arg1, arg2, arg3, arg4, arg5); //多个参数用空格隔开
  936. process.WindowStyle = ProcessWindowStyle.Normal;
  937. Process.Start(process);
  938. }
  939. #endregion
  940. #region 窗体控件事件
  941. private void OTSReport_Export_FormClosing(object sender, FormClosingEventArgs e)
  942. {
  943. if (backgroundWorker2.IsBusy == true)
  944. {
  945. //导出线程正在工作中,不让退出该界面
  946. MessageBox.Show(table["messagebox1"].ToString(), table["messagebox2"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
  947. //然后取消关闭窗体的事件
  948. e.Cancel = true;
  949. }
  950. }
  951. private void btn_preview_Click(object sender, EventArgs e)
  952. {
  953. //为防止重复打开报告后,显示数据库占用错误,先确保报告模板进程已关闭
  954. Process[] processes = Process.GetProcesses();
  955. foreach (Process proc in processes)
  956. {
  957. if (proc.ProcessName == "OTSIncAReportTemplate")
  958. {
  959. DialogResult dr = MessageBox.Show(table["messagebox3"].ToString(), table["messagebox4"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
  960. if (dr == DialogResult.OK)
  961. {
  962. return;
  963. }
  964. }
  965. }
  966. //调用模板设计器,预览
  967. //判断该测量结果文件目录中是否已经有数据库文件,有的话,直接打开,没有则进行导出数据库然后再打开
  968. if (File.Exists(m_strDBpath))
  969. {
  970. DialogResult dr = MessageBox.Show(table["messagebox5"].ToString(), table["messagebox6"].ToString(), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
  971. if (dr == DialogResult.Yes)
  972. {
  973. WriteRictBox(table["messagebox7"].ToString());
  974. //存在则直接打开报表
  975. OpenOTSINcAreportTemplateAPP();
  976. return;
  977. }
  978. if (dr == DialogResult.No)
  979. {
  980. //GoTo Here;
  981. //不干预,跳转到下面执行导出操作
  982. }
  983. if (dr == DialogResult.Cancel)
  984. {
  985. //取消,返回
  986. return;
  987. }
  988. }
  989. //重新导出报表数据
  990. m_ReportApp.m_ChartsWindow.Activate();
  991. WriteRictBox(table["rictbox1"].ToString());
  992. progressBar1.Value = 0;
  993. //预览
  994. if (backgroundWorker2.IsBusy != true)
  995. {
  996. // 启动异步操作
  997. backgroundWorker2.RunWorkerAsync();
  998. }
  999. }
  1000. private void button3_Click(object sender, EventArgs e)
  1001. {
  1002. if (File.Exists(tb_lj.Text.Trim()))
  1003. {
  1004. //打开刚才导出的文件
  1005. System.Diagnostics.Process.Start(tb_lj.Text.Trim());
  1006. }
  1007. else
  1008. {
  1009. WriteRictBox(table["rictbox2"].ToString() + tb_lj.Text.Trim() + table["rictbox3"].ToString());
  1010. }
  1011. }
  1012. private void button2_Click(object sender, EventArgs e)
  1013. {
  1014. //退出
  1015. this.Close();
  1016. }
  1017. private void btn_openfilepath_Click(object sender, EventArgs e)
  1018. {
  1019. LoadControlsToXml();
  1020. SaveMBSClass();
  1021. }
  1022. private void btn_selectPath_Click(object sender, EventArgs e)
  1023. {
  1024. //选择保存文件路径对话框
  1025. SaveFileDialog saveFileDialog1 = new SaveFileDialog();
  1026. //获取默认操作的数据源名,用来当做保存的文件名
  1027. saveFileDialog1.FileName = m_ReportApp.m_rstDataMgr.GetSampleName();
  1028. saveFileDialog1.Filter = "Excel (*.xls)|*.xls|Word (*.doc)|*.doc|PDF (*.pdf)|*.pdf";
  1029. saveFileDialog1.FilterIndex = 1;
  1030. saveFileDialog1.RestoreDirectory = true;
  1031. if (saveFileDialog1.ShowDialog() == DialogResult.OK)
  1032. {
  1033. if (saveFileDialog1.FilterIndex == 1)
  1034. {
  1035. //选择输出Excel
  1036. m_export_type = "Excel";
  1037. }
  1038. if (saveFileDialog1.FilterIndex == 2)
  1039. {
  1040. //选择输出Word
  1041. m_export_type = "Word";
  1042. }
  1043. if (saveFileDialog1.FilterIndex == 3)
  1044. {
  1045. //选择输出PDF
  1046. m_export_type = "PDF";
  1047. }
  1048. tb_lj.Text = saveFileDialog1.FileName;
  1049. }
  1050. }
  1051. //调用编辑模板窗体
  1052. private void btn_TempDes_Click(object sender, EventArgs e)
  1053. {
  1054. //预览设置
  1055. OTSReport_TemplateDesignerRM OtsTemDRM = new OTSReport_TemplateDesignerRM(this);
  1056. if (OtsTemDRM.ShowDialog() == DialogResult.Yes)
  1057. {
  1058. //如果用户点击确定,则将m_mbszclass,模板设置类的内容存到文件中。
  1059. // m_mbszclass.M_DZ.route = tb_mblj.Text;
  1060. m_mbszclass.M_DZ.route = tb_mblj.Text;
  1061. SaveMBSClass();
  1062. }
  1063. }
  1064. #endregion
  1065. #region 将报表数据保存到数据库中
  1066. /// <summary>
  1067. /// 将报表数据保存到数据库中
  1068. /// </summary>
  1069. private void SaveReportTemplateDBFile()
  1070. {
  1071. File.Delete(m_strDBpath);//测试时删除数据库文件,为防止第二次打开报告提示数据库占用,挪到方法开始处
  1072. SqlHelper.CreateNewDatabase(m_strDBpath);
  1073. SqlHelper sh = new SqlHelper("data source='" + m_strDBpath + "'");
  1074. //开始事务
  1075. SQLiteTransaction tr = sh.BeginTranscation();
  1076. //数据库过程
  1077. try
  1078. {
  1079. //创建表 ResultGrid
  1080. string[] strcolumns_ResultGrid = { "CLJGMC", "YXSJ", "SCZS", "FLFA", "YJCTZ", "SCMJ", "CKBZ" };
  1081. string[] strcoltypes_ResultGrid = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1082. sh.CreateTable("ResultGrid", strcolumns_ResultGrid, strcoltypes_ResultGrid);
  1083. //创建表 Largest_frame
  1084. string[] strcolumns_Largest_frame = { "pid", "Size", "Width", "Class", "ColName1", "ColName2", "ColName3", "ColName4", "ColName5", "ColName6",
  1085. "ColVal1", "ColVal2", "ColVal3", "ColVal4", "ColVal5", "ColVal6" ,"FieldId","p1"};
  1086. string[] strcoltypes_Largest_frame = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" ,
  1087. "INT","BLOB"};
  1088. sh.CreateTable("Largest_frame", strcolumns_Largest_frame, strcoltypes_Largest_frame);
  1089. //创建表 Largest20
  1090. string[] strcolumns_Largest20 = { "pid", "Size", "Width", "Class", "ColName1", "ColName2", "ColName3", "ColName4", "ColName5", "ColName6",
  1091. "ColVal1", "ColVal2", "ColVal3", "ColVal4", "ColVal5", "ColVal6" ,"p1" ,"p2" ,"p3"};
  1092. string[] strcoltypes_Largest20 = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" ,
  1093. "BLOB","BLOB","BLOB"};
  1094. sh.CreateTable("Largest20", strcolumns_Largest20, strcoltypes_Largest20);
  1095. //创建表 Largest2new
  1096. string[] strcolumns_Largest2new = { "pid", "Size", "Width", "Class", "ColName1", "ColName2", "ColName3", "ColName4", "ColName5", "ColName6",
  1097. "ColVal1", "ColVal2", "ColVal3", "ColVal4", "ColVal5", "ColVal6" ,"p1"};
  1098. string[] strcoltypes_Largest2new = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" ,
  1099. "BLOB"};
  1100. sh.CreateTable("Largest2new", strcolumns_Largest2new, strcoltypes_Largest2new);
  1101. //创建表 field_dt
  1102. string[] strcolumns_field_dt = { "FieldId", "FieldImg" };
  1103. string[] strcoltypes_field_dt = { "INT", "BLOB" };
  1104. sh.CreateTable("field_dt", strcolumns_field_dt, strcoltypes_field_dt);
  1105. //创建表 ElementName
  1106. string[] strcolumns_ElementName = { "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9","e10","e11","e12","e13","e14" };
  1107. string[] strcoltypes_ElementName = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1108. sh.CreateTable("ElementName", strcolumns_ElementName, strcoltypes_ElementName);
  1109. //创建表 ElementValue
  1110. string[] strcolumns_ElementValue = { "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9","e10","e11","e12","e13","e14", "PName", "Count" , "AllElements" };
  1111. string[] strcoltypes_ElementValue = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1112. sh.CreateTable("ElementValue", strcolumns_ElementValue, strcoltypes_ElementValue);
  1113. //创建表 PartSize
  1114. string[] strcolumns_PartSize = { "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9" };
  1115. string[] strcoltypes_PartSize = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1116. sh.CreateTable("PartSize", strcolumns_PartSize, strcoltypes_PartSize);
  1117. //创建表 Particel
  1118. string[] strcolumns_Particel = { "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "SName", "total" };
  1119. string[] strcoltypes_Particel = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1120. sh.CreateTable("Particel", strcolumns_Particel, strcoltypes_Particel);
  1121. //创建表 PicKL
  1122. string[] strcolumns_PicKL = { "pict" };
  1123. string[] strcoltypes_PicKL = { "BLOB" };
  1124. sh.CreateTable("PicKL", strcolumns_PicKL, strcoltypes_PicKL);
  1125. //创建表 夹杂物面积比
  1126. string[] strcolumns_PicInclusionAreaRatio = { "pict" };
  1127. string[] strcoltypes_PicInclusionAreaRatio = { "BLOB" };
  1128. sh.CreateTable("PicInclusionAreaRatio", strcolumns_PicKL, strcoltypes_PicKL);
  1129. //创建表 PicYS
  1130. string[] strcolumns_PicYS = { "pict" };
  1131. string[] strcoltypes_PicYS = { "BLOB" };
  1132. sh.CreateTable("PicYS", strcolumns_PicYS, strcoltypes_PicYS);
  1133. //创建表 PicSYXT2T
  1134. string[] strcolumns_PicSYXT2T = { "pict", "pict2" };
  1135. string[] strcoltypes_PicSYXT2T = { "BLOB", "BLOB" };
  1136. sh.CreateTable("PicSYXT2T", strcolumns_PicSYXT2T, strcoltypes_PicSYXT2T);
  1137. //创建表 PicSYXT3T
  1138. string[] strcolumns_PicSYXT3T = { "pict", "pict2", "pict3" };
  1139. string[] strcoltypes_PicSYXT3T = { "BLOB", "BLOB", "BLOB" };
  1140. sh.CreateTable("PicSYXT3T", strcolumns_PicSYXT3T, strcoltypes_PicSYXT3T);
  1141. //创建 颗粒面积比表
  1142. string[] strcolums_AreaRatio = { "c1", "c2", "c3", "c4", "c5" };
  1143. string[] strcoltypes_AreaRatio = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1144. sh.CreateTable("AreaRatio", strcolums_AreaRatio, strcoltypes_AreaRatio);
  1145. //将数据插入到数据库中
  1146. List<DataTable> list_dt = m_export_reporttemplate.m_list_dt;
  1147. DataTable ls_AreaRatio = list_dt.Where(aa => aa.TableName.Contains("InclusionAreaRatio")).ToList()[0];
  1148. for (int i = 0; i < ls_AreaRatio.Rows.Count; i++)
  1149. {
  1150. string ls_sqlstr = "insert into AreaRatio (c1, c2, c3, c4, c5) values('"
  1151. + ls_AreaRatio.Rows[i][0].ToString() + "','"
  1152. + ls_AreaRatio.Rows[i][1].ToString() + "','"
  1153. + ls_AreaRatio.Rows[i][2].ToString() + "','"
  1154. + ls_AreaRatio.Rows[i][3].ToString() + "','"
  1155. + ls_AreaRatio.Rows[i][4].ToString() + "')";
  1156. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1157. }
  1158. DataTable ls_resultgrid = list_dt.Where(aa => aa.TableName.Contains("ResultGrid")).ToList()[0];
  1159. for (int i = 0; i < ls_resultgrid.Rows.Count; i++)
  1160. {
  1161. string ls_sqlstr = "insert into ResultGrid (CLJGMC, YXSJ, SCZS, FLFA, YJCTZ, SCMJ, CKBZ) values('"
  1162. + ls_resultgrid.Rows[i][0].ToString() + "','"
  1163. + ls_resultgrid.Rows[i][1].ToString() + "','"
  1164. + ls_resultgrid.Rows[i][2].ToString() + "','"
  1165. + ls_resultgrid.Rows[i][3].ToString() + "','"
  1166. + ls_resultgrid.Rows[i][4].ToString() + "','"
  1167. + ls_resultgrid.Rows[i][5].ToString() + "','"
  1168. + ls_resultgrid.Rows[i][6].ToString() + "')";
  1169. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1170. }
  1171. //插入 Largest_frame
  1172. DataTable ls_Largest_frame = list_dt.Where(aa => aa.TableName.Contains("Largest_frame")).ToList()[0];
  1173. for (int i = 0; i < ls_Largest_frame.Rows.Count; i++)
  1174. {
  1175. if (ls_Largest_frame.Rows[i][17] == null)
  1176. {
  1177. continue;
  1178. }
  1179. if (ls_Largest_frame.Rows[i][17] == DBNull.Value)
  1180. {
  1181. continue;
  1182. }
  1183. string ls_sqlstr = "insert into Largest_frame (pid, Size, Width, Class, ColName1, ColName2, ColName3, ColName4, ColName5, ColName6,ColVal1, ColVal2, ColVal3, ColVal4, ColVal5, ColVal6 ,FieldID,p1) values('"
  1184. + ls_Largest_frame.Rows[i][0].ToString() + "','"
  1185. + ls_Largest_frame.Rows[i][1].ToString() + "','"
  1186. + ls_Largest_frame.Rows[i][2].ToString() + "','"
  1187. + ls_Largest_frame.Rows[i][3].ToString() + "','"
  1188. + ls_Largest_frame.Rows[i][4].ToString() + "','"
  1189. + ls_Largest_frame.Rows[i][5].ToString() + "','"
  1190. + ls_Largest_frame.Rows[i][6].ToString() + "','"
  1191. + ls_Largest_frame.Rows[i][7].ToString() + "','"
  1192. + ls_Largest_frame.Rows[i][8].ToString() + "','"
  1193. + ls_Largest_frame.Rows[i][9].ToString() + "','"
  1194. + ls_Largest_frame.Rows[i][10].ToString() + "','"
  1195. + ls_Largest_frame.Rows[i][11].ToString() + "','"
  1196. + ls_Largest_frame.Rows[i][12].ToString() + "','"
  1197. + ls_Largest_frame.Rows[i][13].ToString() + "','"
  1198. + ls_Largest_frame.Rows[i][14].ToString() + "','"
  1199. + ls_Largest_frame.Rows[i][15].ToString() + "',"
  1200. + ls_Largest_frame.Rows[i][16].ToString() + ",:p1)";
  1201. byte[] byte_p1 = (byte[])ls_Largest_frame.Rows[i][17];
  1202. int iresult = sh.ExecuteQuery(ls_sqlstr, "p1", byte_p1, tr);
  1203. }
  1204. //插入 Largest20
  1205. DataTable ls_Largest20 = list_dt.Where(aa => aa.TableName.Contains("Largest20")).ToList()[0];
  1206. for (int i = 0; i < ls_Largest20.Rows.Count; i++)
  1207. {
  1208. if (ls_Largest20.Rows[i][16] == null)
  1209. {
  1210. continue;
  1211. }
  1212. if (ls_Largest20.Rows[i][16] == DBNull.Value)
  1213. {
  1214. continue;
  1215. }
  1216. string ls_sqlstr = "insert into Largest20 (pid, Size, Width, Class, ColName1, ColName2, ColName3, ColName4, ColName5, ColName6,ColVal1, ColVal2, ColVal3, ColVal4, ColVal5, ColVal6 ,p1,p2,p3) values('"
  1217. + ls_Largest20.Rows[i][0].ToString() + "','"
  1218. + ls_Largest20.Rows[i][1].ToString() + "','"
  1219. + ls_Largest20.Rows[i][2].ToString() + "','"
  1220. + ls_Largest20.Rows[i][3].ToString() + "','"
  1221. + ls_Largest20.Rows[i][4].ToString() + "','"
  1222. + ls_Largest20.Rows[i][5].ToString() + "','"
  1223. + ls_Largest20.Rows[i][6].ToString() + "','"
  1224. + ls_Largest20.Rows[i][7].ToString() + "','"
  1225. + ls_Largest20.Rows[i][8].ToString() + "','"
  1226. + ls_Largest20.Rows[i][9].ToString() + "','"
  1227. + ls_Largest20.Rows[i][10].ToString() + "','"
  1228. + ls_Largest20.Rows[i][11].ToString() + "','"
  1229. + ls_Largest20.Rows[i][12].ToString() + "','"
  1230. + ls_Largest20.Rows[i][13].ToString() + "','"
  1231. + ls_Largest20.Rows[i][14].ToString() + "','"
  1232. + ls_Largest20.Rows[i][15].ToString() + "',:p1,:p2,:p3)";
  1233. byte[] byte_p1 = (byte[])ls_Largest20.Rows[i][16];
  1234. byte[] byte_p2 = (byte[])ls_Largest20.Rows[i][17];
  1235. byte[] byte_p3 = (byte[])ls_Largest20.Rows[i][18];
  1236. int iresult = sh.ExecuteQuery(ls_sqlstr, "p1", byte_p1, "p2", byte_p2, "p3", byte_p3, tr);
  1237. }
  1238. //-----------------------------------------------------------------------------------------------------------------------------------
  1239. ////插入标记帧部份,进行特殊处理,从硬盘中拿现已经生成好的标记图像,进行加载,然后转成byte数组,存入到数据库中 ////准备存放标记图的文件夹
  1240. string m_strFieldPath_Mark = m_ReportApp.m_rstDataMgr.ResultFilesList[m_ReportApp.m_rstDataMgr.GetWorkingResult()].FilePath + "\\FIELD_FILES_MARK\\";
  1241. //插入 field_dt
  1242. DataTable ls_field_dt = list_dt.Where(aa => aa.TableName.Contains("field_dt")).ToList()[0];
  1243. for (int i = 0; i < ls_field_dt.Rows.Count; i++)
  1244. {
  1245. string ls_sqlstr = "insert into field_dt (FieldId,FieldImg) values(" + ls_field_dt.Rows[i]["FieldId"] + ",:pict)";
  1246. string str_fieldid = ls_field_dt.Rows[i][0].ToString();
  1247. //从生成的FIELD_FIES_MARK文件夹中加载图像并转成byte数组,保存到数据库,节省内存
  1248. Bitmap ls_bp_mark = new Bitmap(m_strFieldPath_Mark + str_fieldid + ".bmp");
  1249. MemoryStream newms_fieldmark = new MemoryStream();
  1250. ls_bp_mark.Save(newms_fieldmark, System.Drawing.Imaging.ImageFormat.Bmp);
  1251. newms_fieldmark.Seek(0, SeekOrigin.Begin);
  1252. byte[] newarr_field_mrak = new byte[newms_fieldmark.Length];
  1253. newms_fieldmark.Read(newarr_field_mrak, 0, newarr_field_mrak.Length);
  1254. int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", newarr_field_mrak, tr);
  1255. newms_fieldmark.Dispose();
  1256. newms_fieldmark = null;
  1257. ls_bp_mark.Dispose();
  1258. ls_bp_mark = null;
  1259. GC.Collect();
  1260. GC.WaitForPendingFinalizers();
  1261. }
  1262. //-----------------------------------------------------------------------------------------------------------------
  1263. //插入 ElementName
  1264. DataTable ls_ElementName = list_dt.Where(aa => aa.TableName.Contains("ElementName")).ToList()[0];
  1265. for (int i = 0; i < ls_ElementName.Rows.Count; i++)
  1266. {
  1267. string ls_sqlstr = "insert into ElementName (e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14 ) values('"
  1268. + ls_ElementName.Rows[i][0].ToString() + "','"
  1269. + ls_ElementName.Rows[i][1].ToString() + "','"
  1270. + ls_ElementName.Rows[i][2].ToString() + "','"
  1271. + ls_ElementName.Rows[i][3].ToString() + "','"
  1272. + ls_ElementName.Rows[i][4].ToString() + "','"
  1273. + ls_ElementName.Rows[i][5].ToString() + "','"
  1274. + ls_ElementName.Rows[i][6].ToString() + "','"
  1275. + ls_ElementName.Rows[i][7].ToString() + "','"
  1276. + ls_ElementName.Rows[i][8].ToString() + "','"
  1277. + ls_ElementName.Rows[i][9].ToString() + "','"
  1278. + ls_ElementName.Rows[i][10].ToString() + "','"
  1279. + ls_ElementName.Rows[i][11].ToString() + "','"
  1280. + ls_ElementName.Rows[i][12].ToString() + "','"
  1281. + ls_ElementName.Rows[i][13].ToString() + "')";
  1282. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1283. }
  1284. //插入 ElementValue
  1285. DataTable ls_ElementValue = list_dt.Where(aa => aa.TableName.Contains("ElementValue")).ToList()[0];
  1286. for (int i = 0; i < ls_ElementValue.Rows.Count; i++)
  1287. {
  1288. string ls_sqlstr = "insert into ElementValue (e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14,PName,Count,AllElements ) values('"
  1289. + ls_ElementValue.Rows[i][0].ToString() + "','"
  1290. + ls_ElementValue.Rows[i][1].ToString() + "','"
  1291. + ls_ElementValue.Rows[i][2].ToString() + "','"
  1292. + ls_ElementValue.Rows[i][3].ToString() + "','"
  1293. + ls_ElementValue.Rows[i][4].ToString() + "','"
  1294. + ls_ElementValue.Rows[i][5].ToString() + "','"
  1295. + ls_ElementValue.Rows[i][6].ToString() + "','"
  1296. + ls_ElementValue.Rows[i][7].ToString() + "','"
  1297. + ls_ElementValue.Rows[i][8].ToString() + "','"
  1298. + ls_ElementValue.Rows[i][9].ToString() + "','"
  1299. + ls_ElementValue.Rows[i][10].ToString() + "','"
  1300. + ls_ElementValue.Rows[i][11].ToString() + "','"
  1301. + ls_ElementValue.Rows[i][12].ToString() + "','"
  1302. + ls_ElementValue.Rows[i][13].ToString() + "','"
  1303. + ls_ElementValue.Rows[i][14].ToString() + "','"
  1304. + ls_ElementValue.Rows[i][15].ToString() + "','"
  1305. + ls_ElementValue.Rows[i][16].ToString() + "')";
  1306. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1307. }
  1308. //插入 PartSize
  1309. DataTable ls_PartSize = list_dt.Where(aa => aa.TableName.Contains("PartSize")).ToList()[0];
  1310. for (int i = 0; i < ls_PartSize.Rows.Count; i++)
  1311. {
  1312. string ls_sqlstr = "insert into PartSize (c1, c2, c3, c4, c5, c6, c7, c8, c9 ) values('"
  1313. + ls_PartSize.Rows[i][0].ToString() + "','"
  1314. + ls_PartSize.Rows[i][1].ToString() + "','"
  1315. + ls_PartSize.Rows[i][2].ToString() + "','"
  1316. + ls_PartSize.Rows[i][3].ToString() + "','"
  1317. + ls_PartSize.Rows[i][4].ToString() + "','"
  1318. + ls_PartSize.Rows[i][5].ToString() + "','"
  1319. + ls_PartSize.Rows[i][6].ToString() + "','"
  1320. + ls_PartSize.Rows[i][7].ToString() + "','"
  1321. + ls_PartSize.Rows[i][8].ToString() + "')";
  1322. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1323. }
  1324. //插入 Particel
  1325. DataTable ls_Particel = list_dt.Where(aa => aa.TableName.Contains("Particel")).ToList()[0];
  1326. for (int i = 0; i < ls_Particel.Rows.Count; i++)
  1327. {
  1328. string ls_sqlstr = "insert into Particel (c1, c2, c3, c4, c5, c6, c7, c8, c9,SName,total ) values('"
  1329. + ls_Particel.Rows[i][0].ToString() + "','"
  1330. + ls_Particel.Rows[i][1].ToString() + "','"
  1331. + ls_Particel.Rows[i][2].ToString() + "','"
  1332. + ls_Particel.Rows[i][3].ToString() + "','"
  1333. + ls_Particel.Rows[i][4].ToString() + "','"
  1334. + ls_Particel.Rows[i][5].ToString() + "','"
  1335. + ls_Particel.Rows[i][6].ToString() + "','"
  1336. + ls_Particel.Rows[i][7].ToString() + "','"
  1337. + ls_Particel.Rows[i][8].ToString() + "','"
  1338. + ls_Particel.Rows[i][9].ToString() + "','"
  1339. + ls_Particel.Rows[i][10].ToString() + "')";
  1340. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1341. }
  1342. //插入 PicKL
  1343. DataTable ls_PicKL = list_dt.Where(aa => aa.TableName.Contains("PicKL")).ToList()[0];
  1344. for (int i = 0; i < ls_PicKL.Rows.Count; i++)
  1345. {
  1346. if (ls_PicKL.Rows[i][0] == null)
  1347. {
  1348. continue;
  1349. }
  1350. if (ls_PicKL.Rows[i][0] == DBNull.Value)
  1351. {
  1352. continue;
  1353. }
  1354. string ls_sqlstr = "insert into PicKL (pict) values(:pict)";
  1355. byte[] byte_p1 = (byte[])ls_PicKL.Rows[i][0];
  1356. int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", byte_p1, tr);
  1357. }
  1358. //插入 Pic_InclusionAreaRatio
  1359. DataTable ls_PicInclusionAreaRatio = list_dt.Where(aa => aa.TableName.Contains("Pic_InclusionAreaRatio")).ToList()[0];
  1360. for (int i = 0; i < ls_PicInclusionAreaRatio.Rows.Count; i++)
  1361. {
  1362. if (ls_PicInclusionAreaRatio.Rows[i][0] == null)
  1363. {
  1364. continue;
  1365. }
  1366. if (ls_PicInclusionAreaRatio.Rows[i][0] == DBNull.Value)
  1367. {
  1368. continue;
  1369. }
  1370. string ls_sqlstr = "insert into PicInclusionAreaRatio (pict) values(:pict)";
  1371. byte[] byte_p1 = (byte[])ls_PicInclusionAreaRatio.Rows[i][0];
  1372. int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", byte_p1, tr);
  1373. }
  1374. //插入 PicYS
  1375. DataTable ls_PicYS = list_dt.Where(aa => aa.TableName.Contains("PicYS")).ToList()[0];
  1376. for (int i = 0; i < ls_PicYS.Rows.Count; i++)
  1377. {
  1378. if (ls_PicYS.Rows[i][0] == null)
  1379. {
  1380. continue;
  1381. }
  1382. if (ls_PicYS.Rows[i][0] == DBNull.Value)
  1383. {
  1384. continue;
  1385. }
  1386. string ls_sqlstr = "insert into PicYS (pict) values(:pict)";
  1387. byte[] byte_p1 = (byte[])ls_PicYS.Rows[i][0];
  1388. int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", byte_p1, tr);
  1389. }
  1390. //插入 PicSYXT2T
  1391. DataTable ls_PicSYXT2T = list_dt.Where(aa => aa.TableName.Contains("PicSYXT2T")).ToList()[0];
  1392. for (int i = 0; i < ls_PicSYXT2T.Rows.Count; i++)
  1393. {
  1394. if (ls_PicSYXT2T.Rows[i][0] == null)
  1395. {
  1396. continue;
  1397. }
  1398. if (ls_PicSYXT2T.Rows[i][0] == DBNull.Value)
  1399. {
  1400. continue;
  1401. }
  1402. string ls_sqlstr = "insert into PicSYXT2T (pict,pict2) values(:pict,:pict2)";
  1403. byte[] byte_p1 = (byte[])ls_PicSYXT2T.Rows[i][0];
  1404. byte[] byte_p2 = (byte[])ls_PicSYXT2T.Rows[i][1];
  1405. int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", byte_p1, "pict2", byte_p2, tr);
  1406. }
  1407. //插入 PicSYXT3T
  1408. DataTable ls_PicSYXT3T = list_dt.Where(aa => aa.TableName.Contains("PicSYXT3T")).ToList()[0];
  1409. for (int i = 0; i < ls_PicSYXT3T.Rows.Count; i++)
  1410. {
  1411. if (ls_PicSYXT3T.Rows[i][0] == null)
  1412. {
  1413. continue;
  1414. }
  1415. if (ls_PicSYXT3T.Rows[i][0] == DBNull.Value)
  1416. {
  1417. continue;
  1418. }
  1419. string ls_sqlstr = "insert into PicSYXT3T (pict,pict2,pict3) values(:pict,:pict2,:pict3)";
  1420. byte[] byte_p1 = (byte[])ls_PicSYXT3T.Rows[i][0];
  1421. byte[] byte_p2 = (byte[])ls_PicSYXT3T.Rows[i][1];
  1422. byte[] byte_p3 = (byte[])ls_PicSYXT3T.Rows[i][2];
  1423. int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", byte_p1, "pict2", byte_p2, "pict3", byte_p3, tr);
  1424. }
  1425. //事务提交
  1426. sh.TranscationCommit(tr);
  1427. }
  1428. catch (Exception ee)
  1429. {
  1430. //回滚
  1431. sh.TranscationRollback(tr);
  1432. }
  1433. finally
  1434. {
  1435. //最后关闭连接
  1436. tr.Dispose();
  1437. tr = null;
  1438. sh.CloseConnection();
  1439. }
  1440. }
  1441. #endregion
  1442. #region 导出工作线程部份
  1443. private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
  1444. {
  1445. BackgroundWorker worker = sender as BackgroundWorker;
  1446. //主任务的实现
  1447. #region //获取模板设置的导出的内容-------------------------------------------------
  1448. //获取报告模板设置内容
  1449. worker.ReportProgress(0, table["rictbox4"].ToString());
  1450. System.Threading.Thread.Sleep(1);
  1451. //更新进度
  1452. worker.ReportProgress(5);
  1453. #endregion //设置模板导出内容结束--------------------------------------------------------
  1454. int processvalue = 12;//各功能模块从进度条为15时开始依次调用
  1455. #region //依次循环调用各功能模块-------------------------------------------------------------
  1456. int i_zz = 0;//增值
  1457. i_zz = 80 / 9;
  1458. //首先将测量结果信息表导出,在表头------------------------------------------------
  1459. worker.ReportProgress(0, table["rictbox5"].ToString());
  1460. worker.ReportProgress(0, table["rictbox6"].ToString());
  1461. //更新进度条
  1462. processvalue = processvalue + 1;
  1463. worker.ReportProgress(processvalue);
  1464. lock (m_thread_flag)
  1465. m_thread_flag = table["rictbox7"].ToString();
  1466. while (m_thread_flag == table["rictbox7"].ToString())
  1467. {
  1468. System.Threading.Thread.Sleep(500);
  1469. }
  1470. worker.ReportProgress(0, table["rictbox8"].ToString());
  1471. //-------------------------------------------------------------------------
  1472. //调用输出,颗粒列表----------------------------------------
  1473. worker.ReportProgress(0, table["rictbox9"].ToString());
  1474. worker.ReportProgress(0, table["rictbox10"].ToString());
  1475. //更新进度条
  1476. processvalue = processvalue + i_zz;
  1477. worker.ReportProgress(processvalue);
  1478. lock (m_thread_flag)
  1479. m_thread_flag = table["rictbox7"].ToString();
  1480. while (m_thread_flag == table["rictbox7"].ToString())
  1481. {
  1482. System.Threading.Thread.Sleep(500);
  1483. }
  1484. worker.ReportProgress(0, table["rictbox14"].ToString());
  1485. //调用输出,平均元素含量表---------------------------------------
  1486. worker.ReportProgress(0, table["rictbox15"].ToString());
  1487. worker.ReportProgress(0, table["rictbox16"].ToString());
  1488. //更新进度条
  1489. processvalue = processvalue + i_zz;
  1490. worker.ReportProgress(processvalue);
  1491. lock (m_thread_flag)
  1492. m_thread_flag = table["rictbox7"].ToString();
  1493. while (m_thread_flag == table["rictbox7"].ToString())
  1494. {
  1495. System.Threading.Thread.Sleep(500);
  1496. }
  1497. worker.ReportProgress(0, table["rictbox17"].ToString());
  1498. //调用输出,颗粒尺寸表--------------------------------------
  1499. worker.ReportProgress(0, table["rictbox19"].ToString());
  1500. worker.ReportProgress(0, table["rictbox20"].ToString());
  1501. //更新进度条
  1502. processvalue = processvalue + i_zz;
  1503. worker.ReportProgress(processvalue);
  1504. lock (m_thread_flag)
  1505. m_thread_flag = table["rictbox7"].ToString();
  1506. while (m_thread_flag == table["rictbox7"].ToString())
  1507. {
  1508. System.Threading.Thread.Sleep(500);
  1509. }
  1510. worker.ReportProgress(0, table["rictbox21"].ToString());
  1511. //调用,颗粒成份图------------------------------------------------
  1512. worker.ReportProgress(0, table["rictbox23"].ToString());
  1513. worker.ReportProgress(0, table["rictbox24"].ToString());
  1514. //更新进度条
  1515. processvalue = processvalue + i_zz;
  1516. worker.ReportProgress(processvalue);
  1517. lock (m_thread_flag)
  1518. m_thread_flag = table["rictbox7"].ToString();
  1519. while (m_thread_flag == table["rictbox7"].ToString())
  1520. {
  1521. System.Threading.Thread.Sleep(500);
  1522. }
  1523. worker.ReportProgress(0, table["rictbox25"].ToString());
  1524. //调用,元素成份图---------------------------------------------
  1525. worker.ReportProgress(0, table["rictbox27"].ToString());
  1526. worker.ReportProgress(0, table["rictbox28"].ToString());
  1527. //更新进度条
  1528. processvalue = processvalue + i_zz;
  1529. worker.ReportProgress(processvalue);
  1530. lock (m_thread_flag)
  1531. m_thread_flag = table["rictbox7"].ToString();
  1532. while (m_thread_flag == table["rictbox7"].ToString())
  1533. {
  1534. System.Threading.Thread.Sleep(500);
  1535. }
  1536. worker.ReportProgress(0, table["rictbox29"].ToString());
  1537. //调用,三元相图----------------------------------------------
  1538. worker.ReportProgress(0, table["rictbox31"].ToString());
  1539. worker.ReportProgress(0, table["rictbox32"].ToString());
  1540. //更新进度条
  1541. processvalue = processvalue + i_zz;
  1542. worker.ReportProgress(processvalue);
  1543. lock (m_thread_flag)
  1544. m_thread_flag = table["rictbox7"].ToString();
  1545. while (m_thread_flag == table["rictbox7"].ToString())
  1546. {
  1547. System.Threading.Thread.Sleep(500);
  1548. }
  1549. worker.ReportProgress(0, table["rictbox33"].ToString());
  1550. //生成,模板临时数据库文件----------------------------------------------
  1551. worker.ReportProgress(0, table["rictbox35"].ToString());
  1552. worker.ReportProgress(0, table["rictbox36"].ToString());
  1553. //更新进度条
  1554. processvalue = processvalue + i_zz;
  1555. worker.ReportProgress(processvalue);
  1556. lock (m_thread_flag)
  1557. m_thread_flag = table["rictbox7"].ToString();
  1558. while (m_thread_flag == table["rictbox7"].ToString())
  1559. {
  1560. System.Threading.Thread.Sleep(500);
  1561. }
  1562. worker.ReportProgress(0, table["rictbox37"].ToString());
  1563. #endregion 依将循环调用各功能模块结束-------------------------------------------------------
  1564. }
  1565. private string AnalyticGraphics(int a_Indexes)
  1566. {
  1567. if (a_Indexes == 0)
  1568. return "pie";//饼图
  1569. else if (a_Indexes == 1)
  1570. return "radius";//圈图
  1571. else if (a_Indexes == 2)
  1572. return "bar";//柱状图
  1573. else if (a_Indexes == 3)
  1574. return "line";//线状图
  1575. else return "stack";//堆叠图
  1576. }
  1577. private void backgroundWorker2_ProgressChanged(object sender, ProgressChangedEventArgs e)
  1578. {
  1579. string strNill = table["rictbox40"].ToString();
  1580. BackgroundWorker worker = sender as BackgroundWorker;
  1581. //更新进度条的进度
  1582. if (e.UserState != null)
  1583. {
  1584. string ls_str = (string)e.UserState;
  1585. WriteRictBox((string)e.UserState);
  1586. string s= AnalyticGraphics(m_mbszclass.M_KLFXJG.index_cb_jzwfl_xstx);
  1587. if (ls_str.IndexOf(table["rictbox12"].ToString()) > -1)
  1588. {
  1589. if (ls_str.IndexOf(table["rictbox11"].ToString()) > -1)
  1590. {
  1591. m_export_reporttemplate.InsertReportTemplateTable_ResultGrid();
  1592. lock (m_thread_flag)
  1593. m_thread_flag = strNill;
  1594. }
  1595. if (ls_str.IndexOf(table["rictbox13"].ToString()) > -1)
  1596. {
  1597. m_export_reporttemplate.InsertReportTemplateTable_ParticlesGridDevidePage();
  1598. lock (m_thread_flag)
  1599. m_thread_flag = strNill;
  1600. }
  1601. if (ls_str.IndexOf(table["rictbox18"].ToString()) > -1)
  1602. {
  1603. m_export_reporttemplate.InsertReportTemplateTable_ElementCompositionAvgGrid();
  1604. m_export_reporttemplate.InsertReportTemplateChart_InclusionAreaRatio("pie");
  1605. lock (m_thread_flag)
  1606. m_thread_flag = strNill;
  1607. }
  1608. if (ls_str.IndexOf(table["rictbox22"].ToString()) > -1)
  1609. {
  1610. m_export_reporttemplate.InsertReportTemplateTable_ParticleSizeGrid();
  1611. lock (m_thread_flag)
  1612. m_thread_flag = strNill;
  1613. }
  1614. if (ls_str.IndexOf(table["rictbox26"].ToString()) > -1)
  1615. {
  1616. m_export_reporttemplate.InsertReportTemplateChart_ParticlesCompositionChart(AnalyticGraphics(m_mbszclass.M_KLFXJG.index_cb_jzwfl_xstx));
  1617. lock (m_thread_flag)
  1618. m_thread_flag = strNill;
  1619. }
  1620. if (ls_str.IndexOf(table["rictbox30"].ToString()) > -1)
  1621. {
  1622. m_export_reporttemplate.InsertReportTemplateChart_ElementCompositionChart(AnalyticGraphics(m_mbszclass.M_YSFXJG.index_cb_yscf_xstx));
  1623. lock (m_thread_flag)
  1624. m_thread_flag = strNill;
  1625. }
  1626. if (ls_str.IndexOf(table["rictbox34"].ToString()) > -1)
  1627. {
  1628. m_export_reporttemplate.InsertReportTemplateChart_Trianglediagram();
  1629. lock (m_thread_flag)
  1630. m_thread_flag = strNill;
  1631. }
  1632. if (ls_str.IndexOf(table["rictbox38"].ToString()) > -1)
  1633. {
  1634. //导出到数据库文件中
  1635. SaveReportTemplateDBFile();
  1636. lock (m_thread_flag)
  1637. m_thread_flag = strNill;
  1638. }
  1639. }
  1640. }
  1641. else
  1642. {
  1643. progressBar1.Value = e.ProgressPercentage;
  1644. WriteRictBox(table["rictbox39"].ToString() + e.ProgressPercentage.ToString() + "%");
  1645. }
  1646. }
  1647. private void backgroundWorker2_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
  1648. {
  1649. WriteRictBox(table["rictbox41"].ToString() + m_export_reporttemplate.m_list_dt.Count.ToString() + table["rictbox42"].ToString(), Color.Red);
  1650. //处理结束后,再将button的状态更新回去
  1651. progressBar1.Value = 100;
  1652. WriteRictBox("-----------------"+ table["rictbox43"].ToString() + "--------------------", Color.Red);
  1653. MemoryManagementClass.FlushMemory();
  1654. //导出完成,打开报表
  1655. OpenOTSINcAreportTemplateAPP();
  1656. m_ReportApp.m_conditionChoose.ShowsTheDefaultPic();
  1657. this.Close();
  1658. }
  1659. #endregion
  1660. #region 读取文件
  1661. private void LoadControlsToXml()
  1662. {
  1663. string path = string.Empty;
  1664. OpenFileDialog Load = new OpenFileDialog();
  1665. Load.Filter = "XML File|*.xml";
  1666. Load.InitialDirectory = @System.Windows.Forms.Application.StartupPath + "\\Config\\ProData";
  1667. if (Load.ShowDialog() == DialogResult.OK)
  1668. path = Load.FileName;//赋值目录
  1669. if (path != string.Empty)
  1670. {
  1671. tb_mblj.Text = path;
  1672. m_mbszclass.M_DZ.route = path;
  1673. OTSIncAReportApp.Controls.XmlConfigUtil xmlutil = new OTSIncAReportApp.Controls.XmlConfigUtil(path);
  1674. //首页
  1675. m_mbszclass.M_SY.str_tb_ZBT = xmlutil.Read("M_SY", "str_tb_ZBT");
  1676. m_mbszclass.M_SY.str_tb_FBT = xmlutil.Read("M_SY", "str_tb_FBT");
  1677. m_mbszclass.M_SY.str_tb_YPBH = xmlutil.Read("M_SY", "str_tb_YPBH");
  1678. m_mbszclass.M_SY.str_tb_CKBZ = xmlutil.Read("M_SY", "str_tb_CKBZ");
  1679. m_mbszclass.M_SY.b_ck_ypsm = Convert.ToBoolean(xmlutil.Read("M_SY", "b_ck_ypsm"));
  1680. m_mbszclass.M_SY.b_ck_jggk = Convert.ToBoolean(xmlutil.Read("M_SY", "b_ck_jggk"));
  1681. //页眉页脚
  1682. m_mbszclass.M_YMYJ.str_tb_ymwb = xmlutil.Read("M_YMYJ", "str_tb_ymwb");
  1683. m_mbszclass.M_YMYJ.str_tb_KHH = xmlutil.Read("M_YMYJ", "str_tb_KHH");
  1684. m_mbszclass.M_YMYJ.b_ck_ym = Convert.ToBoolean(xmlutil.Read("M_YMYJ", "b_ck_ym"));
  1685. m_mbszclass.M_YMYJ.str_tb_yjwb = xmlutil.Read("M_YMYJ", "str_tb_yjwb");
  1686. //颗粒分析结果
  1687. m_mbszclass.M_KLFXJG.b_ck_klcc_xsmk = Convert.ToBoolean(xmlutil.Read("M_KLFXJG", "b_ck_klcc_xsmk"));//是否显示模块
  1688. m_mbszclass.M_KLFXJG.index_cb_klcc_jsfs = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_klcc_jsfs"));//计算方式
  1689. m_mbszclass.M_KLFXJG.index_cb_klcc_ljb = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_klcc_ljb"));//粒级表
  1690. m_mbszclass.M_KLFXJG.index_cb_klcc_klfw = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_klcc_klfw"));//颗粒范围
  1691. m_mbszclass.M_KLFXJG.b_cb_jzwfl_xsmk = Convert.ToBoolean(xmlutil.Read("M_KLFXJG", "b_cb_jzwfl_xsmk"));//是否显示该模块
  1692. m_mbszclass.M_KLFXJG.index_cb_jzwfl_xstx = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_jzwfl_xstx"));//选择图像
  1693. m_mbszclass.M_KLFXJG.index_cb_jzwfl_jsfs = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_jzwfl_jsfs"));//计算方式
  1694. m_mbszclass.M_KLFXJG.index_cb_jzwfl_ljb = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_jzwfl_ljb"));//粒级表
  1695. m_mbszclass.M_KLFXJG.index_cb_jzwfl_klfw = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_jzwfl_klfw"));//颗粒范围
  1696. //元素分析结果
  1697. m_mbszclass.M_YSFXJG.b_ck_ysfx_xsmk = Convert.ToBoolean(xmlutil.Read("M_YSFXJG", "b_ck_ysfx_xsmk")); //是否显示模块
  1698. m_mbszclass.M_YSFXJG.index_cb_yxfx_jsfs = Convert.ToInt32(xmlutil.Read("M_YSFXJG", "index_cb_yxfx_jsfs")); //计算方式
  1699. m_mbszclass.M_YSFXJG.index_cb_ysfx_klfw = Convert.ToInt32(xmlutil.Read("M_YSFXJG", "index_cb_ysfx_klfw")); //颗粒范围
  1700. m_mbszclass.M_YSFXJG.str_tb_ysfx_xsys = xmlutil.Read("M_YSFXJG", "str_tb_ysfx_xsys"); //显示元素
  1701. m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys.Clear();
  1702. for (int i = 0; i < 100; i++) //取得所有元素列表
  1703. {
  1704. string str = xmlutil.Read("M_YSFXJG", "list_str_tb_ysfx_xsys", "YS" + i.ToString());
  1705. if (str == null)
  1706. {
  1707. break;
  1708. }
  1709. else
  1710. {
  1711. m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys.Add(str);
  1712. }
  1713. }
  1714. m_mbszclass.M_YSFXJG.b_ck_yscf_xsmk = Convert.ToBoolean(xmlutil.Read("M_YSFXJG", "b_ck_yscf_xsmk")); //是否显示模块
  1715. m_mbszclass.M_YSFXJG.index_cb_yscf_xstx = Convert.ToInt32(xmlutil.Read("M_YSFXJG", "index_cb_yscf_xstx")); //显示图形
  1716. m_mbszclass.M_YSFXJG.index_cb_yscf_jsfs = Convert.ToInt32(xmlutil.Read("M_YSFXJG", "index_cb_yscf_jsfs")); //计算方式
  1717. m_mbszclass.M_YSFXJG.index_cb_yscf_klfw = Convert.ToInt32(xmlutil.Read("M_YSFXJG", "index_cb_yscf_klfw")); //颗粒范围
  1718. m_mbszclass.M_YSFXJG.str_tb_yscf_ysxx = xmlutil.Read("M_YSFXJG", "str_tb_yscf_ysxx"); //显示元素
  1719. m_mbszclass.M_YSFXJG.list_str_tb_yscf_ysxx.Clear();
  1720. for (int i = 0; i < 100; i++) //取得所有元素列表
  1721. {
  1722. string str = xmlutil.Read("M_YSFXJG", "list_str_tb_yscf_ysxx", "YS" + i.ToString());
  1723. if (str == null)
  1724. {
  1725. break;
  1726. }
  1727. else
  1728. {
  1729. m_mbszclass.M_YSFXJG.list_str_tb_yscf_ysxx.Add(str);
  1730. }
  1731. }
  1732. //三元相图
  1733. m_mbszclass.M_SYXT.b_ck_syxt_xsmk = Convert.ToBoolean(xmlutil.Read("M_SYXT", "b_ck_syxt_xsmk")); //是否显示模块
  1734. m_mbszclass.M_SYXT.index_cb_syxt_jsfs = Convert.ToInt32(xmlutil.Read("M_SYXT", "index_cb_syxt_jsfs")); //计算方式
  1735. m_mbszclass.M_SYXT.index_cb_syxt_klfw = Convert.ToInt32(xmlutil.Read("M_SYXT", "index_cb_syxt_klfw")); //颗粒范围
  1736. m_mbszclass.M_SYXT.str_cb_syxt_mhxssl = xmlutil.Read("M_SYXT", "str_cb_syxt_mhxssl"); //每行显示数量
  1737. m_mbszclass.M_SYXT.list_lbv_syxt_mblb.Clear();
  1738. for (int i = 0; i < 100; i++) //取得所有模板列表
  1739. {
  1740. string str = xmlutil.Read("M_SYXT", "list_lbv_syxt_mblb", "MB" + i.ToString());
  1741. if (str == null)
  1742. {
  1743. break;
  1744. }
  1745. else
  1746. {
  1747. m_mbszclass.M_SYXT.list_lbv_syxt_mblb.Add(str);
  1748. }
  1749. }
  1750. m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Clear();
  1751. for (int i = 0; i < 100; i++) //取得所有模板列表 索引
  1752. {
  1753. string str = xmlutil.Read("M_SYXT", "list_lbv_syxt_mblb_index", "MBIndex" + i.ToString());
  1754. if (str == null)
  1755. {
  1756. break;
  1757. }
  1758. else
  1759. {
  1760. m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Add(Convert.ToInt32(str));
  1761. }
  1762. }
  1763. //颗粒列表信息
  1764. m_mbszclass.M_KLLBXX.b_ck_kllb_xsmk = Convert.ToBoolean(xmlutil.Read("M_KLLBXX", "b_ck_kllb_xsmk")); //是否显示模块
  1765. m_mbszclass.M_KLLBXX.index_cb_kllb_jsfs = Convert.ToInt32(xmlutil.Read("M_KLLBXX", "index_cb_kllb_jsfs")); //计算方式
  1766. m_mbszclass.M_KLLBXX.index_cb_kllb_klfw = Convert.ToInt32(xmlutil.Read("M_KLLBXX", "index_cb_kllb_klfw")); //颗粒范围
  1767. m_mbszclass.M_KLLBXX.int_tb_kllb_ylsx = Convert.ToInt32(xmlutil.Read("M_KLLBXX", "int_tb_kllb_ylsx")); //数量上限
  1768. m_mbszclass.M_KLLBXX.str_tb_kllb_sxys = xmlutil.Read("M_KLLBXX", "str_tb_kllb_sxys"); //显示元素
  1769. m_mbszclass.M_KLLBXX.list_str_tb_lllb_sxys.Clear();
  1770. for (int i = 0; i < 100; i++) //取得所有元素列表
  1771. {
  1772. string str = xmlutil.Read("M_KLLBXX", "list_str_tb_lllb_sxys", "YS" + i.ToString());
  1773. if (str == null)
  1774. {
  1775. break;
  1776. }
  1777. else
  1778. {
  1779. m_mbszclass.M_KLLBXX.list_str_tb_lllb_sxys.Add(str);
  1780. }
  1781. }
  1782. m_mbszclass.M_KLLBXX.b_ck_kllb_ystx = Convert.ToBoolean(xmlutil.Read("M_KLLBXX", "b_ck_kllb_ystx")); //原始图像
  1783. m_mbszclass.M_KLLBXX.b_ck_kllb_fdtx = Convert.ToBoolean(xmlutil.Read("M_KLLBXX", "b_ck_kllb_fdtx")); //放大图像
  1784. m_mbszclass.M_KLLBXX.b_ck_kllb_npxx = Convert.ToBoolean(xmlutil.Read("M_KLLBXX", "b_ck_kllb_npxx")); //能谱图像
  1785. }
  1786. }
  1787. #endregion
  1788. private void button7_Click(object sender, EventArgs e)
  1789. {
  1790. //为防止重复打开报告后,显示数据库占用错误,先确保报告模板进程已关闭
  1791. Process[] processes = Process.GetProcesses();
  1792. foreach (Process proc in processes)
  1793. {
  1794. if (proc.ProcessName == "OTSIncAReportTemplate")
  1795. {
  1796. DialogResult dr = MessageBox.Show(table["rictbox44"].ToString(), table["rictbox45"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1797. if (dr == DialogResult.OK)
  1798. {
  1799. return;
  1800. }
  1801. }
  1802. }
  1803. //通过底层CLR运算,获取国标参数信息
  1804. string resultfile = m_ReportApp.m_rstDataMgr.ResultFilesList[m_ReportApp.m_rstDataMgr.GetWorkingResult()].FilePath + "\\"
  1805. + m_ReportApp.m_rstDataMgr.ResultFilesList[m_ReportApp.m_rstDataMgr.GetWorkingResult()].FileName;
  1806. m_ReportApp.m_rstDataMgr.m_ReportMgr.AddASmplMsrResultMgr(resultfile);
  1807. OTSCLRINTERFACE.CPropParamClr clr_prop = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetPropertyParamTable();
  1808. List<DataTable> GB1 = m_export_reporttemplate.InsertReportTemplateTable_ChineseStandardABCDDS(clr_prop);
  1809. List<DataTable> GB2 = m_export_reporttemplate.InsertReportTemplateTable_NationalStandardMethodTwo(clr_prop);
  1810. DataTable ResultGrid = m_export_reporttemplate.InsertReportTemplateTable_ResultGrid();
  1811. SaveReportGBTemplateDBFile(GB1, GB2, ResultGrid);//将国标信息存储到数据库中
  1812. OpenOTSINcAreportGBTemplateAPP();//打开报告模板程序
  1813. m_ReportApp.m_conditionChoose.ShowsTheDefaultPic();
  1814. this.Close();
  1815. }
  1816. /// <summary>
  1817. /// 将国标数据保存至DB数据中
  1818. /// </summary>
  1819. private void SaveReportGBTemplateDBFile(List<DataTable> GB1, List<DataTable> GB2, DataTable ResultGrid)
  1820. {
  1821. File.Delete(m_strDBpathGB);//测试时删除数据库文件,为防止第二次打开报告提示数据库占用,挪到方法开始处
  1822. SqlHelper.CreateNewDatabase(m_strDBpathGB);
  1823. SqlHelper sh = new SqlHelper("data source='" + m_strDBpathGB + "'");
  1824. //开始事务
  1825. SQLiteTransaction tr = sh.BeginTranscation();
  1826. try
  1827. {
  1828. //创建表 ResultGrid
  1829. string[] strcolumns_ResultGrid = { "CLJGMC", "YXSJ", "SCZS", "FLFA", "YJCTZ", "SCMJ", "CKBZ" };
  1830. string[] strcoltypes_ResultGrid = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1831. sh.CreateTable("ResultGrid", strcolumns_ResultGrid, strcoltypes_ResultGrid);
  1832. //创建表 GB1_A
  1833. string[] strcolumns_GB1_A = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1834. string[] strcoltypes_GB1_A = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1835. sh.CreateTable("GB1_A", strcolumns_GB1_A, strcoltypes_GB1_A);
  1836. //创建表 GB1_B
  1837. string[] strcolumns_GB1_B = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1838. string[] strcoltypes_GB1_B = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1839. sh.CreateTable("GB1_B", strcolumns_GB1_B, strcoltypes_GB1_B);
  1840. //创建表 GB1_C
  1841. string[] strcolumns_GB1_C = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1842. string[] strcoltypes_GB1_C = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1843. sh.CreateTable("GB1_C", strcolumns_GB1_C, strcoltypes_GB1_C);
  1844. //创建表 GB1_D
  1845. string[] strcolumns_GB1_D = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1846. string[] strcoltypes_GB1_D = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1847. sh.CreateTable("GB1_D", strcolumns_GB1_D, strcoltypes_GB1_D);
  1848. //创建表 GB1_DS
  1849. string[] strcolumns_GB1_DS = { "No", "Area", "MaxFeret", "X", "Y", "Grade" };
  1850. string[] strcoltypes_GB1_DS = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1851. sh.CreateTable("GB1_DS", strcolumns_GB1_DS, strcoltypes_GB1_DS);
  1852. //创建表 GB2_A
  1853. string[] strcolumns_GB2_A = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1854. string[] strcoltypes_GB2_A = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1855. sh.CreateTable("GB2_A", strcolumns_GB2_A, strcoltypes_GB2_A);
  1856. //创建表 GB2_B
  1857. string[] strcolumns_GB2_B = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1858. string[] strcoltypes_GB2_B = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1859. sh.CreateTable("GB2_B", strcolumns_GB2_B, strcoltypes_GB2_B);
  1860. //创建表 GB2_C
  1861. string[] strcolumns_GB2_C = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1862. string[] strcoltypes_GB2_C = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1863. sh.CreateTable("GB2_C", strcolumns_GB2_C, strcoltypes_GB2_C);
  1864. //创建表 GB2_D
  1865. string[] strcolumns_GB2_D = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1866. string[] strcoltypes_GB2_D = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1867. sh.CreateTable("GB2_D", strcolumns_GB2_D, strcoltypes_GB2_D);
  1868. //创建表 GB2_D_sulfide
  1869. string[] strcolumns_GB2_D_sulfide = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1870. string[] strcoltypes_GB2_D_sulfide = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1871. sh.CreateTable("GB2_D_sulfide", strcolumns_GB2_D_sulfide, strcoltypes_GB2_D_sulfide);
  1872. //创建表 GB2_DS
  1873. string[] strcolumns_GB2_DS = { "No", "Area", "MaxFeret", "X", "Y", "Grade" };
  1874. string[] strcoltypes_GB2_DS = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1875. sh.CreateTable("GB2_DS", strcolumns_GB2_DS, strcoltypes_GB2_DS);
  1876. for (int i = 0; i < ResultGrid.Rows.Count; i++)
  1877. {
  1878. string ls_sqlstr = "insert into ResultGrid (CLJGMC, YXSJ, SCZS, FLFA, YJCTZ, SCMJ, CKBZ) values('"
  1879. + ResultGrid.Rows[i][0].ToString() + "','"
  1880. + ResultGrid.Rows[i][1].ToString() + "','"
  1881. + ResultGrid.Rows[i][2].ToString() + "','"
  1882. + ResultGrid.Rows[i][3].ToString() + "','"
  1883. + ResultGrid.Rows[i][4].ToString() + "','"
  1884. + ResultGrid.Rows[i][5].ToString() + "','"
  1885. + ResultGrid.Rows[i][6].ToString() + "')";
  1886. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1887. }
  1888. //插入 GB1_A
  1889. for (int i = 0; i < GB1[0].Rows.Count; i++)
  1890. {
  1891. string ls_sqlstr = "insert into GB1_A (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  1892. + GB1[0].Rows[i][0].ToString() + "','"
  1893. + GB1[0].Rows[i][1].ToString() + "','"
  1894. + GB1[0].Rows[i][2].ToString() + "','"
  1895. + GB1[0].Rows[i][3].ToString() + "','"
  1896. + GB1[0].Rows[i][4].ToString() + "','"
  1897. + GB1[0].Rows[i][5].ToString() + "','"
  1898. + GB1[0].Rows[i][6].ToString() + "','"
  1899. + GB1[0].Rows[i][7].ToString() + "','"
  1900. + GB1[0].Rows[i][8].ToString() + "','"
  1901. + GB1[0].Rows[i][9].ToString() + "','"
  1902. + GB1[0].Rows[i][10].ToString() + "','"
  1903. + GB1[0].Rows[i][11].ToString() + "','"
  1904. + GB1[0].Rows[i][12].ToString() + "')";
  1905. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1906. }
  1907. //插入 GB1_B
  1908. for (int i = 0; i < GB1[1].Rows.Count; i++)
  1909. {
  1910. string ls_sqlstr = "insert into GB1_B (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  1911. + GB1[1].Rows[i][0].ToString() + "','"
  1912. + GB1[1].Rows[i][1].ToString() + "','"
  1913. + GB1[1].Rows[i][2].ToString() + "','"
  1914. + GB1[1].Rows[i][3].ToString() + "','"
  1915. + GB1[1].Rows[i][4].ToString() + "','"
  1916. + GB1[1].Rows[i][5].ToString() + "','"
  1917. + GB1[1].Rows[i][6].ToString() + "','"
  1918. + GB1[1].Rows[i][7].ToString() + "','"
  1919. + GB1[1].Rows[i][8].ToString() + "','"
  1920. + GB1[1].Rows[i][9].ToString() + "','"
  1921. + GB1[1].Rows[i][10].ToString() + "','"
  1922. + GB1[1].Rows[i][11].ToString() + "','"
  1923. + GB1[1].Rows[i][12].ToString() + "')";
  1924. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1925. }
  1926. //插入 GB1_C
  1927. for (int i = 0; i < GB1[2].Rows.Count; i++)
  1928. {
  1929. string ls_sqlstr = "insert into GB1_C (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  1930. + GB1[2].Rows[i][0].ToString() + "','"
  1931. + GB1[2].Rows[i][1].ToString() + "','"
  1932. + GB1[2].Rows[i][2].ToString() + "','"
  1933. + GB1[2].Rows[i][3].ToString() + "','"
  1934. + GB1[2].Rows[i][4].ToString() + "','"
  1935. + GB1[2].Rows[i][5].ToString() + "','"
  1936. + GB1[2].Rows[i][6].ToString() + "','"
  1937. + GB1[2].Rows[i][7].ToString() + "','"
  1938. + GB1[2].Rows[i][8].ToString() + "','"
  1939. + GB1[2].Rows[i][9].ToString() + "','"
  1940. + GB1[2].Rows[i][10].ToString() + "','"
  1941. + GB1[2].Rows[i][11].ToString() + "','"
  1942. + GB1[2].Rows[i][12].ToString() + "')";
  1943. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1944. }
  1945. //插入 GB1_D
  1946. for (int i = 0; i < GB1[3].Rows.Count; i++)
  1947. {
  1948. string ls_sqlstr = "insert into GB1_D (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  1949. + GB1[3].Rows[i][0].ToString() + "','"
  1950. + GB1[3].Rows[i][1].ToString() + "','"
  1951. + GB1[3].Rows[i][2].ToString() + "','"
  1952. + GB1[3].Rows[i][3].ToString() + "','"
  1953. + GB1[3].Rows[i][4].ToString() + "','"
  1954. + GB1[3].Rows[i][5].ToString() + "','"
  1955. + GB1[3].Rows[i][6].ToString() + "','"
  1956. + GB1[3].Rows[i][7].ToString() + "','"
  1957. + GB1[3].Rows[i][8].ToString() + "','"
  1958. + GB1[3].Rows[i][9].ToString() + "','"
  1959. + GB1[3].Rows[i][10].ToString() + "','"
  1960. + GB1[3].Rows[i][11].ToString() + "','"
  1961. + GB1[3].Rows[i][12].ToString() + "')";
  1962. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1963. }
  1964. //插入 GB1_DS
  1965. for (int i = 0; i < GB1[4].Rows.Count; i++)
  1966. {
  1967. string ls_sqlstr = "insert into GB1_DS (No, Area, MaxFeret, X, Y, Grade ) values('"
  1968. + GB1[4].Rows[i][0].ToString() + "','"
  1969. + GB1[4].Rows[i][1].ToString() + "','"
  1970. + GB1[4].Rows[i][2].ToString() + "','"
  1971. + GB1[4].Rows[i][3].ToString() + "','"
  1972. + GB1[4].Rows[i][4].ToString() + "','"
  1973. + GB1[4].Rows[i][5].ToString() + "')";
  1974. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1975. }
  1976. //插入 GB2_A
  1977. for (int i = 0; i < GB2[0].Rows.Count; i++)
  1978. {
  1979. string ls_sqlstr = "insert into GB2_A (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  1980. + GB2[0].Rows[i][0].ToString() + "','"
  1981. + GB2[0].Rows[i][1].ToString() + "','"
  1982. + GB2[0].Rows[i][2].ToString() + "','"
  1983. + GB2[0].Rows[i][3].ToString() + "','"
  1984. + GB2[0].Rows[i][4].ToString() + "','"
  1985. + GB2[0].Rows[i][5].ToString() + "','"
  1986. + GB2[0].Rows[i][6].ToString() + "','"
  1987. + GB2[0].Rows[i][7].ToString() + "','"
  1988. + GB2[0].Rows[i][8].ToString() + "','"
  1989. + GB2[0].Rows[i][9].ToString() + "','"
  1990. + GB2[0].Rows[i][10].ToString() + "','"
  1991. + GB2[0].Rows[i][11].ToString() + "','"
  1992. + GB2[0].Rows[i][12].ToString() + "')";
  1993. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1994. }
  1995. //插入 GB2_B
  1996. for (int i = 0; i < GB2[1].Rows.Count; i++)
  1997. {
  1998. string ls_sqlstr = "insert into GB2_B (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  1999. + GB2[1].Rows[i][0].ToString() + "','"
  2000. + GB2[1].Rows[i][1].ToString() + "','"
  2001. + GB2[1].Rows[i][2].ToString() + "','"
  2002. + GB2[1].Rows[i][3].ToString() + "','"
  2003. + GB2[1].Rows[i][4].ToString() + "','"
  2004. + GB2[1].Rows[i][5].ToString() + "','"
  2005. + GB2[1].Rows[i][6].ToString() + "','"
  2006. + GB2[1].Rows[i][7].ToString() + "','"
  2007. + GB2[1].Rows[i][8].ToString() + "','"
  2008. + GB2[1].Rows[i][9].ToString() + "','"
  2009. + GB2[1].Rows[i][10].ToString() + "','"
  2010. + GB2[1].Rows[i][11].ToString() + "','"
  2011. + GB2[1].Rows[i][12].ToString() + "')";
  2012. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2013. }
  2014. //插入 GB2_C
  2015. for (int i = 0; i < GB2[2].Rows.Count; i++)
  2016. {
  2017. string ls_sqlstr = "insert into GB2_C (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  2018. + GB2[2].Rows[i][0].ToString() + "','"
  2019. + GB2[2].Rows[i][1].ToString() + "','"
  2020. + GB2[2].Rows[i][2].ToString() + "','"
  2021. + GB2[2].Rows[i][3].ToString() + "','"
  2022. + GB2[2].Rows[i][4].ToString() + "','"
  2023. + GB2[2].Rows[i][5].ToString() + "','"
  2024. + GB2[2].Rows[i][6].ToString() + "','"
  2025. + GB2[2].Rows[i][7].ToString() + "','"
  2026. + GB2[2].Rows[i][8].ToString() + "','"
  2027. + GB2[2].Rows[i][9].ToString() + "','"
  2028. + GB2[2].Rows[i][10].ToString() + "','"
  2029. + GB2[2].Rows[i][11].ToString() + "','"
  2030. + GB2[2].Rows[i][12].ToString() + "')";
  2031. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2032. }
  2033. //插入 GB1_D
  2034. for (int i = 0; i < GB2[3].Rows.Count; i++)
  2035. {
  2036. string ls_sqlstr = "insert into GB2_D (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  2037. + GB2[3].Rows[i][0].ToString() + "','"
  2038. + GB2[3].Rows[i][1].ToString() + "','"
  2039. + GB2[3].Rows[i][2].ToString() + "','"
  2040. + GB2[3].Rows[i][3].ToString() + "','"
  2041. + GB2[3].Rows[i][4].ToString() + "','"
  2042. + GB2[3].Rows[i][5].ToString() + "','"
  2043. + GB2[3].Rows[i][6].ToString() + "','"
  2044. + GB2[3].Rows[i][7].ToString() + "','"
  2045. + GB2[3].Rows[i][8].ToString() + "','"
  2046. + GB2[3].Rows[i][9].ToString() + "','"
  2047. + GB2[3].Rows[i][10].ToString() + "','"
  2048. + GB2[3].Rows[i][11].ToString() + "','"
  2049. + GB2[3].Rows[i][12].ToString() + "')";
  2050. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2051. }
  2052. //插入 GB2_D_sulfide
  2053. for (int i = 0; i < GB2[4].Rows.Count; i++)
  2054. {
  2055. string ls_sqlstr = "insert into GB2_D_sulfide (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  2056. + GB2[4].Rows[i][0].ToString() + "','"
  2057. + GB2[4].Rows[i][1].ToString() + "','"
  2058. + GB2[4].Rows[i][2].ToString() + "','"
  2059. + GB2[4].Rows[i][3].ToString() + "','"
  2060. + GB2[4].Rows[i][4].ToString() + "','"
  2061. + GB2[4].Rows[i][5].ToString() + "','"
  2062. + GB2[4].Rows[i][6].ToString() + "','"
  2063. + GB2[4].Rows[i][7].ToString() + "','"
  2064. + GB2[4].Rows[i][8].ToString() + "','"
  2065. + GB2[4].Rows[i][9].ToString() + "','"
  2066. + GB2[4].Rows[i][10].ToString() + "','"
  2067. + GB2[4].Rows[i][11].ToString() + "','"
  2068. + GB2[4].Rows[i][12].ToString() + "')";
  2069. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2070. }
  2071. //插入 GB1_DS
  2072. for (int i = 0; i < GB2[5].Rows.Count; i++)
  2073. {
  2074. string ls_sqlstr = "insert into GB2_DS (No, Area, MaxFeret, X, Y, Grade ) values('"
  2075. + GB1[5].Rows[i][0].ToString() + "','"
  2076. + GB1[5].Rows[i][1].ToString() + "','"
  2077. + GB1[5].Rows[i][2].ToString() + "','"
  2078. + GB1[5].Rows[i][3].ToString() + "','"
  2079. + GB1[5].Rows[i][4].ToString() + "','"
  2080. + GB1[5].Rows[i][5].ToString() + "')";
  2081. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2082. }
  2083. //事务提交
  2084. sh.TranscationCommit(tr);
  2085. }
  2086. catch (Exception ee)
  2087. {
  2088. //回滚
  2089. sh.TranscationRollback(tr);
  2090. }
  2091. finally
  2092. {
  2093. //最后关闭连接
  2094. tr.Dispose();
  2095. tr = null;
  2096. sh.CloseConnection();
  2097. }
  2098. }
  2099. /// <summary>
  2100. /// 打开国标导出
  2101. /// </summary>
  2102. private void OpenOTSINcAreportGBTemplateAPP()
  2103. {
  2104. ProcessStartInfo process = new ProcessStartInfo();
  2105. process.FileName = "ReportTemplateExe\\OTSIncAReportTemplate.exe";//打开app的路径
  2106. string arg1 = m_strDBpathGB.Replace(" ", "^");//参数1,是需要打开db数据库的路径
  2107. string arg2 = tb_mblj.Text.Trim().Replace(" ", "^");//参数2,是模板文件的路径
  2108. string arg3 = "GBReport";//主体报表
  2109. string arg4 = "100";//夹杂物数量
  2110. string arg5 = "0-100";//打开的标记帧图图像数量
  2111. process.Arguments = string.Format("{0} {1} {2} {3} {4}", arg1, arg2, arg3, arg4, arg5); //多个参数用空格隔开
  2112. process.WindowStyle = ProcessWindowStyle.Normal;
  2113. Process.Start(process);
  2114. }
  2115. private void OTSReport_Export_FormClosed(object sender, FormClosedEventArgs e)
  2116. {
  2117. }
  2118. }
  2119. }