OTSReport_Export.cs 114 KB

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