OTSReport_Export.cs 114 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505
  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.resultFilesList.Count; i++)
  715. {
  716. cbo_sjy.Items.Add(m_ReportApp.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.resultFilesList[cbo_sjy.SelectedIndex].FilePath;
  739. m_strDBpathGB = m_ReportApp.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.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 button4_Click(object sender, EventArgs e)
  1059. {
  1060. }
  1061. private void btn_preview_Click(object sender, EventArgs e)
  1062. {
  1063. //为防止重复打开报告后,显示数据库占用错误,先确保报告模板进程已关闭
  1064. Process[] processes = Process.GetProcesses();
  1065. foreach (Process proc in processes)
  1066. {
  1067. if (proc.ProcessName == "OTSIncAReportTemplate")
  1068. {
  1069. DialogResult dr = MessageBox.Show("报告已打开,请先关闭!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1070. if (dr == DialogResult.OK)
  1071. {
  1072. return;
  1073. }
  1074. }
  1075. }
  1076. //调用模板设计器,预览
  1077. //判断该测量结果文件目录中是否已经有数据库文件,有的话,直接打开,没有则进行导出数据库然后再打开
  1078. if (File.Exists(m_strDBpath))
  1079. {
  1080. DialogResult dr = MessageBox.Show("[Yes]直接打开报表,[No]重新生成报表,[Cancal]取消操作", "报表已有生成数据,请选择操作", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
  1081. if (dr == DialogResult.Yes)
  1082. {
  1083. WriteRictBox("报表模板数据库文件已存在,直接打开-----------");
  1084. //存在则直接打开报表
  1085. OpenOTSINcAreportTemplateAPP();
  1086. return;
  1087. }
  1088. if (dr == DialogResult.No)
  1089. {
  1090. //GoTo Here;
  1091. //不干预,跳转到下面执行导出操作
  1092. }
  1093. if (dr == DialogResult.Cancel)
  1094. {
  1095. //取消,返回
  1096. return;
  1097. }
  1098. }
  1099. //重新导出报表数据
  1100. m_ReportApp.m_CChartsWindow.Activate();
  1101. WriteRictBox("开始执行导出操作-----------");
  1102. progressBar1.Value = 0;
  1103. //预览
  1104. if (backgroundWorker2.IsBusy != true)
  1105. {
  1106. // 启动异步操作
  1107. backgroundWorker2.RunWorkerAsync();
  1108. }
  1109. }
  1110. private void button3_Click(object sender, EventArgs e)
  1111. {
  1112. if (File.Exists(tb_lj.Text.Trim()))
  1113. {
  1114. //打开刚才导出的文件
  1115. System.Diagnostics.Process.Start(tb_lj.Text.Trim());
  1116. }
  1117. else
  1118. {
  1119. WriteRictBox("未找到文件" + tb_lj.Text.Trim() + ",是否未导出?");
  1120. }
  1121. }
  1122. private void button2_Click(object sender, EventArgs e)
  1123. {
  1124. //退出
  1125. this.Close();
  1126. }
  1127. private void btn_openfilepath_Click(object sender, EventArgs e)
  1128. {
  1129. LoadControlsToXml();
  1130. SaveMBSClass();
  1131. }
  1132. private void button1_Click(object sender, EventArgs e)
  1133. {
  1134. }
  1135. private void button6_Click(object sender, EventArgs e)
  1136. {
  1137. }
  1138. private void btn_selectPath_Click(object sender, EventArgs e)
  1139. {
  1140. //选择保存文件路径对话框
  1141. SaveFileDialog saveFileDialog1 = new SaveFileDialog();
  1142. //获取默认操作的数据源名,用来当做保存的文件名
  1143. saveFileDialog1.FileName = m_ReportApp.m_DataMgrFun.GetSampleName();
  1144. saveFileDialog1.Filter = "Excel (*.xls)|*.xls|Word (*.doc)|*.doc|PDF (*.pdf)|*.pdf";
  1145. saveFileDialog1.FilterIndex = 1;
  1146. saveFileDialog1.RestoreDirectory = true;
  1147. if (saveFileDialog1.ShowDialog() == DialogResult.OK)
  1148. {
  1149. if (saveFileDialog1.FilterIndex == 1)
  1150. {
  1151. //选择输出Excel
  1152. m_export_type = "Excel";
  1153. }
  1154. if (saveFileDialog1.FilterIndex == 2)
  1155. {
  1156. //选择输出Word
  1157. m_export_type = "Word";
  1158. }
  1159. if (saveFileDialog1.FilterIndex == 3)
  1160. {
  1161. //选择输出PDF
  1162. m_export_type = "PDF";
  1163. }
  1164. tb_lj.Text = saveFileDialog1.FileName;
  1165. }
  1166. }
  1167. //调用编辑模板窗体
  1168. private void btn_TempDes_Click(object sender, EventArgs e)
  1169. {
  1170. //预览设置
  1171. OTSReport_TemplateDesignerRM OtsTemDRM = new OTSReport_TemplateDesignerRM(this);
  1172. if (OtsTemDRM.ShowDialog() == DialogResult.Yes)
  1173. {
  1174. //如果用户点击确定,则将m_mbszclass,模板设置类的内容存到文件中。
  1175. // m_mbszclass.M_DZ.route = tb_mblj.Text;
  1176. m_mbszclass.M_DZ.route = tb_mblj.Text;
  1177. SaveMBSClass();
  1178. }
  1179. }
  1180. #endregion
  1181. #region 将报表数据保存到数据库中
  1182. /// <summary>
  1183. /// 将报表数据保存到数据库中
  1184. /// </summary>
  1185. private void SaveReportTemplateDBFile()
  1186. {
  1187. File.Delete(m_strDBpath);//测试时删除数据库文件,为防止第二次打开报告提示数据库占用,挪到方法开始处
  1188. SqlHelper.CreateNewDatabase(m_strDBpath);
  1189. SqlHelper sh = new SqlHelper("data source='" + m_strDBpath + "'");
  1190. //开始事务
  1191. SQLiteTransaction tr = sh.BeginTranscation();
  1192. //数据库过程
  1193. try
  1194. {
  1195. //创建表 ResultGrid
  1196. string[] strcolumns_ResultGrid = { "CLJGMC", "YXSJ", "SCZS", "FLFA", "YJCTZ", "SCMJ", "CKBZ" };
  1197. string[] strcoltypes_ResultGrid = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1198. sh.CreateTable("ResultGrid", strcolumns_ResultGrid, strcoltypes_ResultGrid);
  1199. //创建表 Largest_frame
  1200. string[] strcolumns_Largest_frame = { "pid", "Size", "Width", "Class", "ColName1", "ColName2", "ColName3", "ColName4", "ColName5", "ColName6",
  1201. "ColVal1", "ColVal2", "ColVal3", "ColVal4", "ColVal5", "ColVal6" ,"FieldId","p1"};
  1202. string[] strcoltypes_Largest_frame = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" ,
  1203. "INT","BLOB"};
  1204. sh.CreateTable("Largest_frame", strcolumns_Largest_frame, strcoltypes_Largest_frame);
  1205. //创建表 Largest20
  1206. string[] strcolumns_Largest20 = { "pid", "Size", "Width", "Class", "ColName1", "ColName2", "ColName3", "ColName4", "ColName5", "ColName6",
  1207. "ColVal1", "ColVal2", "ColVal3", "ColVal4", "ColVal5", "ColVal6" ,"p1" ,"p2" ,"p3"};
  1208. string[] strcoltypes_Largest20 = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" ,
  1209. "BLOB","BLOB","BLOB"};
  1210. sh.CreateTable("Largest20", strcolumns_Largest20, strcoltypes_Largest20);
  1211. //创建表 Largest2new
  1212. string[] strcolumns_Largest2new = { "pid", "Size", "Width", "Class", "ColName1", "ColName2", "ColName3", "ColName4", "ColName5", "ColName6",
  1213. "ColVal1", "ColVal2", "ColVal3", "ColVal4", "ColVal5", "ColVal6" ,"p1"};
  1214. string[] strcoltypes_Largest2new = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" ,
  1215. "BLOB"};
  1216. sh.CreateTable("Largest2new", strcolumns_Largest2new, strcoltypes_Largest2new);
  1217. //创建表 field_dt
  1218. string[] strcolumns_field_dt = { "FieldId", "FieldImg" };
  1219. string[] strcoltypes_field_dt = { "INT", "BLOB" };
  1220. sh.CreateTable("field_dt", strcolumns_field_dt, strcoltypes_field_dt);
  1221. //创建表 ElementName
  1222. string[] strcolumns_ElementName = { "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9","e10","e11","e12","e13","e14" };
  1223. string[] strcoltypes_ElementName = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1224. sh.CreateTable("ElementName", strcolumns_ElementName, strcoltypes_ElementName);
  1225. //创建表 ElementValue
  1226. string[] strcolumns_ElementValue = { "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9","e10","e11","e12","e13","e14", "PName", "Count" , "AllElements" };
  1227. string[] strcoltypes_ElementValue = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1228. sh.CreateTable("ElementValue", strcolumns_ElementValue, strcoltypes_ElementValue);
  1229. //创建表 PartSize
  1230. string[] strcolumns_PartSize = { "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9" };
  1231. string[] strcoltypes_PartSize = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1232. sh.CreateTable("PartSize", strcolumns_PartSize, strcoltypes_PartSize);
  1233. //创建表 Particel
  1234. string[] strcolumns_Particel = { "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "SName", "total" };
  1235. string[] strcoltypes_Particel = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1236. sh.CreateTable("Particel", strcolumns_Particel, strcoltypes_Particel);
  1237. //创建表 PicKL
  1238. string[] strcolumns_PicKL = { "pict" };
  1239. string[] strcoltypes_PicKL = { "BLOB" };
  1240. sh.CreateTable("PicKL", strcolumns_PicKL, strcoltypes_PicKL);
  1241. //创建表 PicYS
  1242. string[] strcolumns_PicYS = { "pict" };
  1243. string[] strcoltypes_PicYS = { "BLOB" };
  1244. sh.CreateTable("PicYS", strcolumns_PicYS, strcoltypes_PicYS);
  1245. //创建表 PicSYXT2T
  1246. string[] strcolumns_PicSYXT2T = { "pict", "pict2" };
  1247. string[] strcoltypes_PicSYXT2T = { "BLOB", "BLOB" };
  1248. sh.CreateTable("PicSYXT2T", strcolumns_PicSYXT2T, strcoltypes_PicSYXT2T);
  1249. //创建表 PicSYXT3T
  1250. string[] strcolumns_PicSYXT3T = { "pict", "pict2", "pict3" };
  1251. string[] strcoltypes_PicSYXT3T = { "BLOB", "BLOB", "BLOB" };
  1252. sh.CreateTable("PicSYXT3T", strcolumns_PicSYXT3T, strcoltypes_PicSYXT3T);
  1253. //将数据插入到数据库中
  1254. List<DataTable> list_dt = m_export_reporttemplate.m_list_dt;
  1255. DataTable ls_resultgrid = list_dt.Where(aa => aa.TableName.Contains("ResultGrid")).ToList()[0];
  1256. for (int i = 0; i < ls_resultgrid.Rows.Count; i++)
  1257. {
  1258. string ls_sqlstr = "insert into ResultGrid (CLJGMC, YXSJ, SCZS, FLFA, YJCTZ, SCMJ, CKBZ) values('"
  1259. + ls_resultgrid.Rows[i][0].ToString() + "','"
  1260. + ls_resultgrid.Rows[i][1].ToString() + "','"
  1261. + ls_resultgrid.Rows[i][2].ToString() + "','"
  1262. + ls_resultgrid.Rows[i][3].ToString() + "','"
  1263. + ls_resultgrid.Rows[i][4].ToString() + "','"
  1264. + ls_resultgrid.Rows[i][5].ToString() + "','"
  1265. + ls_resultgrid.Rows[i][6].ToString() + "')";
  1266. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1267. }
  1268. //插入 Largest_frame
  1269. DataTable ls_Largest_frame = list_dt.Where(aa => aa.TableName.Contains("Largest_frame")).ToList()[0];
  1270. for (int i = 0; i < ls_Largest_frame.Rows.Count; i++)
  1271. {
  1272. if (ls_Largest_frame.Rows[i][17] == null)
  1273. {
  1274. continue;
  1275. }
  1276. if (ls_Largest_frame.Rows[i][17] == DBNull.Value)
  1277. {
  1278. continue;
  1279. }
  1280. 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('"
  1281. + ls_Largest_frame.Rows[i][0].ToString() + "','"
  1282. + ls_Largest_frame.Rows[i][1].ToString() + "','"
  1283. + ls_Largest_frame.Rows[i][2].ToString() + "','"
  1284. + ls_Largest_frame.Rows[i][3].ToString() + "','"
  1285. + ls_Largest_frame.Rows[i][4].ToString() + "','"
  1286. + ls_Largest_frame.Rows[i][5].ToString() + "','"
  1287. + ls_Largest_frame.Rows[i][6].ToString() + "','"
  1288. + ls_Largest_frame.Rows[i][7].ToString() + "','"
  1289. + ls_Largest_frame.Rows[i][8].ToString() + "','"
  1290. + ls_Largest_frame.Rows[i][9].ToString() + "','"
  1291. + ls_Largest_frame.Rows[i][10].ToString() + "','"
  1292. + ls_Largest_frame.Rows[i][11].ToString() + "','"
  1293. + ls_Largest_frame.Rows[i][12].ToString() + "','"
  1294. + ls_Largest_frame.Rows[i][13].ToString() + "','"
  1295. + ls_Largest_frame.Rows[i][14].ToString() + "','"
  1296. + ls_Largest_frame.Rows[i][15].ToString() + "',"
  1297. + ls_Largest_frame.Rows[i][16].ToString() + ",:p1)";
  1298. byte[] byte_p1 = (byte[])ls_Largest_frame.Rows[i][17];
  1299. int iresult = sh.ExecuteQuery(ls_sqlstr, "p1", byte_p1, tr);
  1300. }
  1301. //插入 Largest20
  1302. DataTable ls_Largest20 = list_dt.Where(aa => aa.TableName.Contains("Largest20")).ToList()[0];
  1303. for (int i = 0; i < ls_Largest20.Rows.Count; i++)
  1304. {
  1305. if (ls_Largest20.Rows[i][16] == null)
  1306. {
  1307. continue;
  1308. }
  1309. if (ls_Largest20.Rows[i][16] == DBNull.Value)
  1310. {
  1311. continue;
  1312. }
  1313. 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('"
  1314. + ls_Largest20.Rows[i][0].ToString() + "','"
  1315. + ls_Largest20.Rows[i][1].ToString() + "','"
  1316. + ls_Largest20.Rows[i][2].ToString() + "','"
  1317. + ls_Largest20.Rows[i][3].ToString() + "','"
  1318. + ls_Largest20.Rows[i][4].ToString() + "','"
  1319. + ls_Largest20.Rows[i][5].ToString() + "','"
  1320. + ls_Largest20.Rows[i][6].ToString() + "','"
  1321. + ls_Largest20.Rows[i][7].ToString() + "','"
  1322. + ls_Largest20.Rows[i][8].ToString() + "','"
  1323. + ls_Largest20.Rows[i][9].ToString() + "','"
  1324. + ls_Largest20.Rows[i][10].ToString() + "','"
  1325. + ls_Largest20.Rows[i][11].ToString() + "','"
  1326. + ls_Largest20.Rows[i][12].ToString() + "','"
  1327. + ls_Largest20.Rows[i][13].ToString() + "','"
  1328. + ls_Largest20.Rows[i][14].ToString() + "','"
  1329. + ls_Largest20.Rows[i][15].ToString() + "',:p1,:p2,:p3)";
  1330. byte[] byte_p1 = (byte[])ls_Largest20.Rows[i][16];
  1331. byte[] byte_p2 = (byte[])ls_Largest20.Rows[i][17];
  1332. byte[] byte_p3 = (byte[])ls_Largest20.Rows[i][18];
  1333. int iresult = sh.ExecuteQuery(ls_sqlstr, "p1", byte_p1, "p2", byte_p2, "p3", byte_p3, tr);
  1334. }
  1335. //-----------------------------------------------------------------------------------------------------------------------------------
  1336. ////插入标记帧部份,进行特殊处理,从硬盘中拿现已经生成好的标记图像,进行加载,然后转成byte数组,存入到数据库中 ////准备存放标记图的文件夹
  1337. string m_strFieldPath_Mark = m_ReportApp.resultFilesList[m_ReportApp.WorkingResult].FilePath + "\\FIELD_FILES_MARK\\";
  1338. //插入 field_dt
  1339. DataTable ls_field_dt = list_dt.Where(aa => aa.TableName.Contains("field_dt")).ToList()[0];
  1340. for (int i = 0; i < ls_field_dt.Rows.Count; i++)
  1341. {
  1342. string ls_sqlstr = "insert into field_dt (FieldId,FieldImg) values(" + ls_field_dt.Rows[i]["FieldId"] + ",:pict)";
  1343. string str_fieldid = ls_field_dt.Rows[i][0].ToString();
  1344. //从生成的FIELD_FIES_MARK文件夹中加载图像并转成byte数组,保存到数据库,节省内存
  1345. Bitmap ls_bp_mark = new Bitmap(m_strFieldPath_Mark + str_fieldid + ".bmp");
  1346. MemoryStream newms_fieldmark = new MemoryStream();
  1347. ls_bp_mark.Save(newms_fieldmark, System.Drawing.Imaging.ImageFormat.Bmp);
  1348. newms_fieldmark.Seek(0, SeekOrigin.Begin);
  1349. byte[] newarr_field_mrak = new byte[newms_fieldmark.Length];
  1350. newms_fieldmark.Read(newarr_field_mrak, 0, newarr_field_mrak.Length);
  1351. int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", newarr_field_mrak, tr);
  1352. newms_fieldmark.Dispose();
  1353. newms_fieldmark = null;
  1354. ls_bp_mark.Dispose();
  1355. ls_bp_mark = null;
  1356. GC.Collect();
  1357. GC.WaitForPendingFinalizers();
  1358. }
  1359. //-----------------------------------------------------------------------------------------------------------------
  1360. //插入 ElementName
  1361. DataTable ls_ElementName = list_dt.Where(aa => aa.TableName.Contains("ElementName")).ToList()[0];
  1362. for (int i = 0; i < ls_ElementName.Rows.Count; i++)
  1363. {
  1364. string ls_sqlstr = "insert into ElementName (e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14 ) values('"
  1365. + ls_ElementName.Rows[i][0].ToString() + "','"
  1366. + ls_ElementName.Rows[i][1].ToString() + "','"
  1367. + ls_ElementName.Rows[i][2].ToString() + "','"
  1368. + ls_ElementName.Rows[i][3].ToString() + "','"
  1369. + ls_ElementName.Rows[i][4].ToString() + "','"
  1370. + ls_ElementName.Rows[i][5].ToString() + "','"
  1371. + ls_ElementName.Rows[i][6].ToString() + "','"
  1372. + ls_ElementName.Rows[i][7].ToString() + "','"
  1373. + ls_ElementName.Rows[i][8].ToString() + "','"
  1374. + ls_ElementName.Rows[i][9].ToString() + "','"
  1375. + ls_ElementName.Rows[i][10].ToString() + "','"
  1376. + ls_ElementName.Rows[i][11].ToString() + "','"
  1377. + ls_ElementName.Rows[i][12].ToString() + "','"
  1378. + ls_ElementName.Rows[i][13].ToString() + "')";
  1379. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1380. }
  1381. //插入 ElementValue
  1382. DataTable ls_ElementValue = list_dt.Where(aa => aa.TableName.Contains("ElementValue")).ToList()[0];
  1383. for (int i = 0; i < ls_ElementValue.Rows.Count; i++)
  1384. {
  1385. string ls_sqlstr = "insert into ElementValue (e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14,PName,Count,AllElements ) values('"
  1386. + ls_ElementValue.Rows[i][0].ToString() + "','"
  1387. + ls_ElementValue.Rows[i][1].ToString() + "','"
  1388. + ls_ElementValue.Rows[i][2].ToString() + "','"
  1389. + ls_ElementValue.Rows[i][3].ToString() + "','"
  1390. + ls_ElementValue.Rows[i][4].ToString() + "','"
  1391. + ls_ElementValue.Rows[i][5].ToString() + "','"
  1392. + ls_ElementValue.Rows[i][6].ToString() + "','"
  1393. + ls_ElementValue.Rows[i][7].ToString() + "','"
  1394. + ls_ElementValue.Rows[i][8].ToString() + "','"
  1395. + ls_ElementValue.Rows[i][9].ToString() + "','"
  1396. + ls_ElementValue.Rows[i][10].ToString() + "','"
  1397. + ls_ElementValue.Rows[i][11].ToString() + "','"
  1398. + ls_ElementValue.Rows[i][12].ToString() + "','"
  1399. + ls_ElementValue.Rows[i][13].ToString() + "','"
  1400. + ls_ElementValue.Rows[i][14].ToString() + "','"
  1401. + ls_ElementValue.Rows[i][15].ToString() + "','"
  1402. + ls_ElementValue.Rows[i][16].ToString() + "')";
  1403. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1404. }
  1405. //插入 PartSize
  1406. DataTable ls_PartSize = list_dt.Where(aa => aa.TableName.Contains("PartSize")).ToList()[0];
  1407. for (int i = 0; i < ls_PartSize.Rows.Count; i++)
  1408. {
  1409. string ls_sqlstr = "insert into PartSize (c1, c2, c3, c4, c5, c6, c7, c8, c9 ) values('"
  1410. + ls_PartSize.Rows[i][0].ToString() + "','"
  1411. + ls_PartSize.Rows[i][1].ToString() + "','"
  1412. + ls_PartSize.Rows[i][2].ToString() + "','"
  1413. + ls_PartSize.Rows[i][3].ToString() + "','"
  1414. + ls_PartSize.Rows[i][4].ToString() + "','"
  1415. + ls_PartSize.Rows[i][5].ToString() + "','"
  1416. + ls_PartSize.Rows[i][6].ToString() + "','"
  1417. + ls_PartSize.Rows[i][7].ToString() + "','"
  1418. + ls_PartSize.Rows[i][8].ToString() + "')";
  1419. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1420. }
  1421. //插入 Particel
  1422. DataTable ls_Particel = list_dt.Where(aa => aa.TableName.Contains("Particel")).ToList()[0];
  1423. for (int i = 0; i < ls_Particel.Rows.Count; i++)
  1424. {
  1425. string ls_sqlstr = "insert into Particel (c1, c2, c3, c4, c5, c6, c7, c8, c9,SName,total ) values('"
  1426. + ls_Particel.Rows[i][0].ToString() + "','"
  1427. + ls_Particel.Rows[i][1].ToString() + "','"
  1428. + ls_Particel.Rows[i][2].ToString() + "','"
  1429. + ls_Particel.Rows[i][3].ToString() + "','"
  1430. + ls_Particel.Rows[i][4].ToString() + "','"
  1431. + ls_Particel.Rows[i][5].ToString() + "','"
  1432. + ls_Particel.Rows[i][6].ToString() + "','"
  1433. + ls_Particel.Rows[i][7].ToString() + "','"
  1434. + ls_Particel.Rows[i][8].ToString() + "','"
  1435. + ls_Particel.Rows[i][9].ToString() + "','"
  1436. + ls_Particel.Rows[i][10].ToString() + "')";
  1437. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1438. }
  1439. //插入 PicKL
  1440. DataTable ls_PicKL = list_dt.Where(aa => aa.TableName.Contains("PicKL")).ToList()[0];
  1441. for (int i = 0; i < ls_PicKL.Rows.Count; i++)
  1442. {
  1443. if (ls_PicKL.Rows[i][0] == null)
  1444. {
  1445. continue;
  1446. }
  1447. if (ls_PicKL.Rows[i][0] == DBNull.Value)
  1448. {
  1449. continue;
  1450. }
  1451. string ls_sqlstr = "insert into PicKL (pict) values(:pict)";
  1452. byte[] byte_p1 = (byte[])ls_PicKL.Rows[i][0];
  1453. int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", byte_p1, tr);
  1454. }
  1455. //插入 PicYS
  1456. DataTable ls_PicYS = list_dt.Where(aa => aa.TableName.Contains("PicYS")).ToList()[0];
  1457. for (int i = 0; i < ls_PicYS.Rows.Count; i++)
  1458. {
  1459. if (ls_PicYS.Rows[i][0] == null)
  1460. {
  1461. continue;
  1462. }
  1463. if (ls_PicYS.Rows[i][0] == DBNull.Value)
  1464. {
  1465. continue;
  1466. }
  1467. string ls_sqlstr = "insert into PicYS (pict) values(:pict)";
  1468. byte[] byte_p1 = (byte[])ls_PicYS.Rows[i][0];
  1469. int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", byte_p1, tr);
  1470. }
  1471. //插入 PicSYXT2T
  1472. DataTable ls_PicSYXT2T = list_dt.Where(aa => aa.TableName.Contains("PicSYXT2T")).ToList()[0];
  1473. for (int i = 0; i < ls_PicSYXT2T.Rows.Count; i++)
  1474. {
  1475. if (ls_PicSYXT2T.Rows[i][0] == null)
  1476. {
  1477. continue;
  1478. }
  1479. if (ls_PicSYXT2T.Rows[i][0] == DBNull.Value)
  1480. {
  1481. continue;
  1482. }
  1483. string ls_sqlstr = "insert into PicSYXT2T (pict,pict2) values(:pict,:pict2)";
  1484. byte[] byte_p1 = (byte[])ls_PicSYXT2T.Rows[i][0];
  1485. byte[] byte_p2 = (byte[])ls_PicSYXT2T.Rows[i][1];
  1486. int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", byte_p1, "pict2", byte_p2, tr);
  1487. }
  1488. //插入 PicSYXT3T
  1489. DataTable ls_PicSYXT3T = list_dt.Where(aa => aa.TableName.Contains("PicSYXT3T")).ToList()[0];
  1490. for (int i = 0; i < ls_PicSYXT3T.Rows.Count; i++)
  1491. {
  1492. if (ls_PicSYXT3T.Rows[i][0] == null)
  1493. {
  1494. continue;
  1495. }
  1496. if (ls_PicSYXT3T.Rows[i][0] == DBNull.Value)
  1497. {
  1498. continue;
  1499. }
  1500. string ls_sqlstr = "insert into PicSYXT3T (pict,pict2,pict3) values(:pict,:pict2,:pict3)";
  1501. byte[] byte_p1 = (byte[])ls_PicSYXT3T.Rows[i][0];
  1502. byte[] byte_p2 = (byte[])ls_PicSYXT3T.Rows[i][1];
  1503. byte[] byte_p3 = (byte[])ls_PicSYXT3T.Rows[i][2];
  1504. int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", byte_p1, "pict2", byte_p2, "pict3", byte_p3, tr);
  1505. }
  1506. //事务提交
  1507. sh.TranscationCommit(tr);
  1508. }
  1509. catch (Exception ee)
  1510. {
  1511. //回滚
  1512. sh.TranscationRollback(tr);
  1513. }
  1514. finally
  1515. {
  1516. //最后关闭连接
  1517. tr.Dispose();
  1518. tr = null;
  1519. sh.CloseConnection();
  1520. }
  1521. }
  1522. #endregion
  1523. #region 导出工作线程部份
  1524. private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
  1525. {
  1526. BackgroundWorker worker = sender as BackgroundWorker;
  1527. //主任务的实现
  1528. #region //获取模板设置的导出的内容-------------------------------------------------
  1529. //获取报告模板设置内容
  1530. worker.ReportProgress(0, "已获取模板中设置内容为:-------------------");
  1531. System.Threading.Thread.Sleep(1);
  1532. //更新进度
  1533. worker.ReportProgress(5);
  1534. #endregion //设置模板导出内容结束--------------------------------------------------------
  1535. int processvalue = 12;//各功能模块从进度条为15时开始依次调用
  1536. #region //依次循环调用各功能模块-------------------------------------------------------------
  1537. int i_zz = 0;//增值
  1538. i_zz = 80 / 9;
  1539. //首先将测量结果信息表导出,在表头------------------------------------------------
  1540. worker.ReportProgress(0, "加载测量结果信息表模块中....");
  1541. worker.ReportProgress(0, "加载:测量结果信息表");
  1542. //更新进度条
  1543. processvalue = processvalue + 1;
  1544. worker.ReportProgress(processvalue);
  1545. lock (m_thread_flag)
  1546. m_thread_flag = "等待";
  1547. while (m_thread_flag == "等待")
  1548. {
  1549. System.Threading.Thread.Sleep(500);
  1550. }
  1551. worker.ReportProgress(0, "加载测量结果信息表模块完成");
  1552. //-------------------------------------------------------------------------
  1553. //调用输出,颗粒列表----------------------------------------
  1554. worker.ReportProgress(0, "加载颗粒列表模块中....");
  1555. worker.ReportProgress(0, "加载:颗粒列表");
  1556. //更新进度条
  1557. processvalue = processvalue + i_zz;
  1558. worker.ReportProgress(processvalue);
  1559. lock (m_thread_flag)
  1560. m_thread_flag = "等待";
  1561. while (m_thread_flag == "等待")
  1562. {
  1563. System.Threading.Thread.Sleep(500);
  1564. }
  1565. worker.ReportProgress(0, "加载颗粒列表模块完成");
  1566. //调用输出,平均元素含量表---------------------------------------
  1567. worker.ReportProgress(0, "加载平均元素含量表模块中....");
  1568. worker.ReportProgress(0, "加载:平均元素含量表");
  1569. //更新进度条
  1570. processvalue = processvalue + i_zz;
  1571. worker.ReportProgress(processvalue);
  1572. lock (m_thread_flag)
  1573. m_thread_flag = "等待";
  1574. while (m_thread_flag == "等待")
  1575. {
  1576. System.Threading.Thread.Sleep(500);
  1577. }
  1578. worker.ReportProgress(0, "加载平均元素含量表模块完成");
  1579. //调用输出,颗粒尺寸表--------------------------------------
  1580. worker.ReportProgress(0, "加载颗粒尺寸表模块中....");
  1581. worker.ReportProgress(0, "加载:颗粒尺寸表");
  1582. //更新进度条
  1583. processvalue = processvalue + i_zz;
  1584. worker.ReportProgress(processvalue);
  1585. lock (m_thread_flag)
  1586. m_thread_flag = "等待";
  1587. while (m_thread_flag == "等待")
  1588. {
  1589. System.Threading.Thread.Sleep(500);
  1590. }
  1591. worker.ReportProgress(0, "加载颗粒尺寸表模块完成");
  1592. //调用,颗粒成份图------------------------------------------------
  1593. worker.ReportProgress(0, "加载颗粒成份图模块中....");
  1594. worker.ReportProgress(0, "加载:颗粒成份图");
  1595. //更新进度条
  1596. processvalue = processvalue + i_zz;
  1597. worker.ReportProgress(processvalue);
  1598. lock (m_thread_flag)
  1599. m_thread_flag = "等待";
  1600. while (m_thread_flag == "等待")
  1601. {
  1602. System.Threading.Thread.Sleep(500);
  1603. }
  1604. worker.ReportProgress(0, "加载颗粒成份图模块完成");
  1605. //调用,元素成份图---------------------------------------------
  1606. worker.ReportProgress(0, "加载元素成份图模块中....");
  1607. worker.ReportProgress(0, "加载:元素成份图");
  1608. //更新进度条
  1609. processvalue = processvalue + i_zz;
  1610. worker.ReportProgress(processvalue);
  1611. lock (m_thread_flag)
  1612. m_thread_flag = "等待";
  1613. while (m_thread_flag == "等待")
  1614. {
  1615. System.Threading.Thread.Sleep(500);
  1616. }
  1617. worker.ReportProgress(0, "加载元素成份图模块完成");
  1618. //调用,三元相图----------------------------------------------
  1619. worker.ReportProgress(0, "加载三元相图模块中....");
  1620. worker.ReportProgress(0, "加载:三元相图");
  1621. //更新进度条
  1622. processvalue = processvalue + i_zz;
  1623. worker.ReportProgress(processvalue);
  1624. lock (m_thread_flag)
  1625. m_thread_flag = "等待";
  1626. while (m_thread_flag == "等待")
  1627. {
  1628. System.Threading.Thread.Sleep(500);
  1629. }
  1630. worker.ReportProgress(0, "加载三元相图模块完成");
  1631. //生成,模板临时数据库文件----------------------------------------------
  1632. worker.ReportProgress(0, "生成模板临时数据库文件....");
  1633. worker.ReportProgress(0, "加载:生成模板临时数据库文件");
  1634. //更新进度条
  1635. processvalue = processvalue + i_zz;
  1636. worker.ReportProgress(processvalue);
  1637. lock (m_thread_flag)
  1638. m_thread_flag = "等待";
  1639. while (m_thread_flag == "等待")
  1640. {
  1641. System.Threading.Thread.Sleep(500);
  1642. }
  1643. worker.ReportProgress(0, "模板临时数据库文件完成");
  1644. #endregion 依将循环调用各功能模块结束-------------------------------------------------------
  1645. }
  1646. private string AnalyticGraphics(int a_Indexes)
  1647. {
  1648. if (a_Indexes == 0)
  1649. return "pie";//饼图
  1650. else if (a_Indexes == 1)
  1651. return "radius";//圈图
  1652. else if (a_Indexes == 2)
  1653. return "bar";//柱状图
  1654. else if (a_Indexes == 3)
  1655. return "line";//线状图
  1656. else return "stack";//堆叠图
  1657. }
  1658. private void backgroundWorker2_ProgressChanged(object sender, ProgressChangedEventArgs e)
  1659. {
  1660. BackgroundWorker worker = sender as BackgroundWorker;
  1661. //更新进度条的进度
  1662. if (e.UserState != null)
  1663. {
  1664. string ls_str = (string)e.UserState;
  1665. WriteRictBox((string)e.UserState);
  1666. string s= AnalyticGraphics(m_mbszclass.M_KLFXJG.index_cb_jzwfl_xstx);
  1667. if (ls_str.IndexOf("加载:") > -1)
  1668. {
  1669. if (ls_str.IndexOf("测量结果信息表") > -1)
  1670. {
  1671. m_export_reporttemplate.InsertReportTemplateTable_ResultGrid();
  1672. lock (m_thread_flag)
  1673. m_thread_flag = "无";
  1674. }
  1675. if (ls_str.IndexOf("颗粒列表") > -1)
  1676. {
  1677. m_export_reporttemplate.InsertReportTemplateTable_ParticlesGridDevidePage();
  1678. lock (m_thread_flag)
  1679. m_thread_flag = "无";
  1680. }
  1681. if (ls_str.IndexOf("平均元素含量表") > -1)
  1682. {
  1683. m_export_reporttemplate.InsertReportTemplateTable_ElementCompositionAvgGrid();
  1684. lock (m_thread_flag)
  1685. m_thread_flag = "无";
  1686. }
  1687. if (ls_str.IndexOf("颗粒尺寸表") > -1)
  1688. {
  1689. m_export_reporttemplate.InsertReportTemplateTable_ParticleSizeGrid();
  1690. lock (m_thread_flag)
  1691. m_thread_flag = "无";
  1692. }
  1693. if (ls_str.IndexOf("颗粒成份图") > -1)
  1694. {
  1695. m_export_reporttemplate.InsertReportTemplateChart_ParticlesCompositionChart(AnalyticGraphics(m_mbszclass.M_KLFXJG.index_cb_jzwfl_xstx));
  1696. lock (m_thread_flag)
  1697. m_thread_flag = "无";
  1698. }
  1699. if (ls_str.IndexOf("元素成份图") > -1)
  1700. {
  1701. m_export_reporttemplate.InsertReportTemplateChart_ElementCompositionChart(AnalyticGraphics(m_mbszclass.M_YSFXJG.index_cb_yscf_xstx));
  1702. lock (m_thread_flag)
  1703. m_thread_flag = "无";
  1704. }
  1705. if (ls_str.IndexOf("三元相图") > -1)
  1706. {
  1707. m_export_reporttemplate.InsertReportTemplateChart_Trianglediagram();
  1708. lock (m_thread_flag)
  1709. m_thread_flag = "无";
  1710. }
  1711. if (ls_str.IndexOf("模板临时数据库文件") > -1)
  1712. {
  1713. //导出到数据库文件中
  1714. SaveReportTemplateDBFile();
  1715. lock (m_thread_flag)
  1716. m_thread_flag = "无";
  1717. }
  1718. }
  1719. }
  1720. else
  1721. {
  1722. progressBar1.Value = e.ProgressPercentage;
  1723. WriteRictBox("正在导入到报告模板中,已经完成:" + e.ProgressPercentage.ToString() + "%");
  1724. }
  1725. }
  1726. private void backgroundWorker2_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
  1727. {
  1728. WriteRictBox("导出了:" + m_export_reporttemplate.m_list_dt.Count.ToString() + "表", Color.Red);
  1729. //处理结束后,再将button的状态更新回去
  1730. progressBar1.Value = 100;
  1731. WriteRictBox("-----------------导出完成!--------------------", Color.Red);
  1732. MemoryManagementClass.FlushMemory();
  1733. //导出完成,打开报表
  1734. OpenOTSINcAreportTemplateAPP();
  1735. m_ReportApp.m_DataMgrFun.ShowsTheDefaultPic();
  1736. this.Close();
  1737. }
  1738. #endregion
  1739. #region 读取文件
  1740. private void LoadControlsToXml()
  1741. {
  1742. string path = string.Empty;
  1743. OpenFileDialog Load = new OpenFileDialog();
  1744. Load.Filter = "PXML文件|*.xml";
  1745. Load.InitialDirectory = @System.Windows.Forms.Application.StartupPath + "\\Config\\ProData";
  1746. if (Load.ShowDialog() == DialogResult.OK)
  1747. path = Load.FileName;//赋值目录
  1748. if (path != string.Empty)
  1749. {
  1750. tb_mblj.Text = path;
  1751. m_mbszclass.M_DZ.route = path;
  1752. OTSIncAReportApp.Controls.XmlConfigUtil xmlutil = new OTSIncAReportApp.Controls.XmlConfigUtil(path);
  1753. //首页
  1754. m_mbszclass.M_SY.str_tb_ZBT = xmlutil.Read("M_SY", "str_tb_ZBT");
  1755. m_mbszclass.M_SY.str_tb_FBT = xmlutil.Read("M_SY", "str_tb_FBT");
  1756. m_mbszclass.M_SY.str_tb_YPBH = xmlutil.Read("M_SY", "str_tb_YPBH");
  1757. m_mbszclass.M_SY.str_tb_CKBZ = xmlutil.Read("M_SY", "str_tb_CKBZ");
  1758. m_mbszclass.M_SY.b_ck_ypsm = Convert.ToBoolean(xmlutil.Read("M_SY", "b_ck_ypsm"));
  1759. m_mbszclass.M_SY.b_ck_jggk = Convert.ToBoolean(xmlutil.Read("M_SY", "b_ck_jggk"));
  1760. //页眉页脚
  1761. m_mbszclass.M_YMYJ.str_tb_ymwb = xmlutil.Read("M_YMYJ", "str_tb_ymwb");
  1762. m_mbszclass.M_YMYJ.str_tb_KHH = xmlutil.Read("M_YMYJ", "str_tb_KHH");
  1763. m_mbszclass.M_YMYJ.b_ck_ym = Convert.ToBoolean(xmlutil.Read("M_YMYJ", "b_ck_ym"));
  1764. m_mbszclass.M_YMYJ.str_tb_yjwb = xmlutil.Read("M_YMYJ", "str_tb_yjwb");
  1765. //颗粒分析结果
  1766. m_mbszclass.M_KLFXJG.b_ck_klcc_xsmk = Convert.ToBoolean(xmlutil.Read("M_KLFXJG", "b_ck_klcc_xsmk"));//是否显示模块
  1767. m_mbszclass.M_KLFXJG.index_cb_klcc_jsfs = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_klcc_jsfs"));//计算方式
  1768. m_mbszclass.M_KLFXJG.index_cb_klcc_ljb = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_klcc_ljb"));//粒级表
  1769. m_mbszclass.M_KLFXJG.index_cb_klcc_klfw = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_klcc_klfw"));//颗粒范围
  1770. m_mbszclass.M_KLFXJG.b_cb_jzwfl_xsmk = Convert.ToBoolean(xmlutil.Read("M_KLFXJG", "b_cb_jzwfl_xsmk"));//是否显示该模块
  1771. m_mbszclass.M_KLFXJG.index_cb_jzwfl_xstx = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_jzwfl_xstx"));//选择图像
  1772. m_mbszclass.M_KLFXJG.index_cb_jzwfl_jsfs = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_jzwfl_jsfs"));//计算方式
  1773. m_mbszclass.M_KLFXJG.index_cb_jzwfl_ljb = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_jzwfl_ljb"));//粒级表
  1774. m_mbszclass.M_KLFXJG.index_cb_jzwfl_klfw = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_jzwfl_klfw"));//颗粒范围
  1775. //元素分析结果
  1776. m_mbszclass.M_YSFXJG.b_ck_ysfx_xsmk = Convert.ToBoolean(xmlutil.Read("M_YSFXJG", "b_ck_ysfx_xsmk")); //是否显示模块
  1777. m_mbszclass.M_YSFXJG.index_cb_yxfx_jsfs = Convert.ToInt32(xmlutil.Read("M_YSFXJG", "index_cb_yxfx_jsfs")); //计算方式
  1778. m_mbszclass.M_YSFXJG.index_cb_ysfx_klfw = Convert.ToInt32(xmlutil.Read("M_YSFXJG", "index_cb_ysfx_klfw")); //颗粒范围
  1779. m_mbszclass.M_YSFXJG.str_tb_ysfx_xsys = xmlutil.Read("M_YSFXJG", "str_tb_ysfx_xsys"); //显示元素
  1780. m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys.Clear();
  1781. for (int i = 0; i < 100; i++) //取得所有元素列表
  1782. {
  1783. string str = xmlutil.Read("M_YSFXJG", "list_str_tb_ysfx_xsys", "YS" + i.ToString());
  1784. if (str == null)
  1785. {
  1786. break;
  1787. }
  1788. else
  1789. {
  1790. m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys.Add(str);
  1791. }
  1792. }
  1793. m_mbszclass.M_YSFXJG.b_ck_yscf_xsmk = Convert.ToBoolean(xmlutil.Read("M_YSFXJG", "b_ck_yscf_xsmk")); //是否显示模块
  1794. m_mbszclass.M_YSFXJG.index_cb_yscf_xstx = Convert.ToInt32(xmlutil.Read("M_YSFXJG", "index_cb_yscf_xstx")); //显示图形
  1795. m_mbszclass.M_YSFXJG.index_cb_yscf_jsfs = Convert.ToInt32(xmlutil.Read("M_YSFXJG", "index_cb_yscf_jsfs")); //计算方式
  1796. m_mbszclass.M_YSFXJG.index_cb_yscf_klfw = Convert.ToInt32(xmlutil.Read("M_YSFXJG", "index_cb_yscf_klfw")); //颗粒范围
  1797. m_mbszclass.M_YSFXJG.str_tb_yscf_ysxx = xmlutil.Read("M_YSFXJG", "str_tb_yscf_ysxx"); //显示元素
  1798. m_mbszclass.M_YSFXJG.list_str_tb_yscf_ysxx.Clear();
  1799. for (int i = 0; i < 100; i++) //取得所有元素列表
  1800. {
  1801. string str = xmlutil.Read("M_YSFXJG", "list_str_tb_yscf_ysxx", "YS" + i.ToString());
  1802. if (str == null)
  1803. {
  1804. break;
  1805. }
  1806. else
  1807. {
  1808. m_mbszclass.M_YSFXJG.list_str_tb_yscf_ysxx.Add(str);
  1809. }
  1810. }
  1811. //三元相图
  1812. m_mbszclass.M_SYXT.b_ck_syxt_xsmk = Convert.ToBoolean(xmlutil.Read("M_SYXT", "b_ck_syxt_xsmk")); //是否显示模块
  1813. m_mbszclass.M_SYXT.index_cb_syxt_jsfs = Convert.ToInt32(xmlutil.Read("M_SYXT", "index_cb_syxt_jsfs")); //计算方式
  1814. m_mbszclass.M_SYXT.index_cb_syxt_klfw = Convert.ToInt32(xmlutil.Read("M_SYXT", "index_cb_syxt_klfw")); //颗粒范围
  1815. m_mbszclass.M_SYXT.str_cb_syxt_mhxssl = xmlutil.Read("M_SYXT", "str_cb_syxt_mhxssl"); //每行显示数量
  1816. m_mbszclass.M_SYXT.list_lbv_syxt_mblb.Clear();
  1817. for (int i = 0; i < 100; i++) //取得所有模板列表
  1818. {
  1819. string str = xmlutil.Read("M_SYXT", "list_lbv_syxt_mblb", "MB" + i.ToString());
  1820. if (str == null)
  1821. {
  1822. break;
  1823. }
  1824. else
  1825. {
  1826. m_mbszclass.M_SYXT.list_lbv_syxt_mblb.Add(str);
  1827. }
  1828. }
  1829. m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Clear();
  1830. for (int i = 0; i < 100; i++) //取得所有模板列表 索引
  1831. {
  1832. string str = xmlutil.Read("M_SYXT", "list_lbv_syxt_mblb_index", "MBIndex" + i.ToString());
  1833. if (str == null)
  1834. {
  1835. break;
  1836. }
  1837. else
  1838. {
  1839. m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Add(Convert.ToInt32(str));
  1840. }
  1841. }
  1842. //颗粒列表信息
  1843. m_mbszclass.M_KLLBXX.b_ck_kllb_xsmk = Convert.ToBoolean(xmlutil.Read("M_KLLBXX", "b_ck_kllb_xsmk")); //是否显示模块
  1844. m_mbszclass.M_KLLBXX.index_cb_kllb_jsfs = Convert.ToInt32(xmlutil.Read("M_KLLBXX", "index_cb_kllb_jsfs")); //计算方式
  1845. m_mbszclass.M_KLLBXX.index_cb_kllb_klfw = Convert.ToInt32(xmlutil.Read("M_KLLBXX", "index_cb_kllb_klfw")); //颗粒范围
  1846. m_mbszclass.M_KLLBXX.int_tb_kllb_ylsx = Convert.ToInt32(xmlutil.Read("M_KLLBXX", "int_tb_kllb_ylsx")); //数量上限
  1847. m_mbszclass.M_KLLBXX.str_tb_kllb_sxys = xmlutil.Read("M_KLLBXX", "str_tb_kllb_sxys"); //显示元素
  1848. m_mbszclass.M_KLLBXX.list_str_tb_lllb_sxys.Clear();
  1849. for (int i = 0; i < 100; i++) //取得所有元素列表
  1850. {
  1851. string str = xmlutil.Read("M_KLLBXX", "list_str_tb_lllb_sxys", "YS" + i.ToString());
  1852. if (str == null)
  1853. {
  1854. break;
  1855. }
  1856. else
  1857. {
  1858. m_mbszclass.M_KLLBXX.list_str_tb_lllb_sxys.Add(str);
  1859. }
  1860. }
  1861. m_mbszclass.M_KLLBXX.b_ck_kllb_ystx = Convert.ToBoolean(xmlutil.Read("M_KLLBXX", "b_ck_kllb_ystx")); //原始图像
  1862. m_mbszclass.M_KLLBXX.b_ck_kllb_fdtx = Convert.ToBoolean(xmlutil.Read("M_KLLBXX", "b_ck_kllb_fdtx")); //放大图像
  1863. m_mbszclass.M_KLLBXX.b_ck_kllb_npxx = Convert.ToBoolean(xmlutil.Read("M_KLLBXX", "b_ck_kllb_npxx")); //能谱图像
  1864. }
  1865. }
  1866. #endregion
  1867. private void button7_Click(object sender, EventArgs e)
  1868. {
  1869. //为防止重复打开报告后,显示数据库占用错误,先确保报告模板进程已关闭
  1870. Process[] processes = Process.GetProcesses();
  1871. foreach (Process proc in processes)
  1872. {
  1873. if (proc.ProcessName == "OTSIncAReportTemplate")
  1874. {
  1875. DialogResult dr = MessageBox.Show("报告模板已打开,请先关闭!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1876. if (dr == DialogResult.OK)
  1877. {
  1878. return;
  1879. }
  1880. }
  1881. }
  1882. if (File.Exists(m_strDBpathGB))
  1883. {
  1884. DialogResult dr = MessageBox.Show("[Yes]直接打开报表,[No]重新生成报表,[Cancal]取消操作", "报表已有生成数据,请选择操作", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
  1885. if (dr == DialogResult.Yes)
  1886. {
  1887. OpenOTSINcAreportGBTemplateAPP();
  1888. return;
  1889. }
  1890. if (dr == DialogResult.No)
  1891. {
  1892. //GoTo Here;
  1893. //不干预,跳转到下面执行导出操作
  1894. }
  1895. if (dr == DialogResult.Cancel)
  1896. {
  1897. //取消,返回
  1898. return;
  1899. }
  1900. }
  1901. //通过底层CLR运算,获取国标参数信息
  1902. string resultfile = m_ReportApp.resultFilesList[m_ReportApp.WorkingResult].FilePath + "\\"
  1903. + m_ReportApp.resultFilesList[m_ReportApp.WorkingResult].FileName;
  1904. m_ReportApp.m_DataMgrFun.m_ReportMgr.AddASmplMsrResultMgr(resultfile);
  1905. OTSCLRINTERFACE.CPropParamClr clr_prop = m_ReportApp.m_DataMgrFun.m_ReportMgr.GetPropertyParamTable();
  1906. List<DataTable> GB1 = m_export_reporttemplate.InsertReportTemplateTable_ChineseStandardABCDDS(clr_prop);
  1907. List<DataTable> GB2 = m_export_reporttemplate.InsertReportTemplateTable_NationalStandardMethodTwo(clr_prop);
  1908. DataTable ResultGrid = m_export_reporttemplate.InsertReportTemplateTable_ResultGrid();
  1909. SaveReportGBTemplateDBFile(GB1, GB2, ResultGrid);//将国标信息存储到数据库中
  1910. OpenOTSINcAreportGBTemplateAPP();//打开报告模板程序
  1911. }
  1912. /// <summary>
  1913. /// 将国标数据保存至DB数据中
  1914. /// </summary>
  1915. private void SaveReportGBTemplateDBFile(List<DataTable> GB1, List<DataTable> GB2, DataTable ResultGrid)
  1916. {
  1917. File.Delete(m_strDBpathGB);//测试时删除数据库文件,为防止第二次打开报告提示数据库占用,挪到方法开始处
  1918. SqlHelper.CreateNewDatabase(m_strDBpathGB);
  1919. SqlHelper sh = new SqlHelper("data source='" + m_strDBpathGB + "'");
  1920. //开始事务
  1921. SQLiteTransaction tr = sh.BeginTranscation();
  1922. try
  1923. {
  1924. //创建表 ResultGrid
  1925. string[] strcolumns_ResultGrid = { "CLJGMC", "YXSJ", "SCZS", "FLFA", "YJCTZ", "SCMJ", "CKBZ" };
  1926. string[] strcoltypes_ResultGrid = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1927. sh.CreateTable("ResultGrid", strcolumns_ResultGrid, strcoltypes_ResultGrid);
  1928. //创建表 GB1_A
  1929. string[] strcolumns_GB1_A = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1930. string[] strcoltypes_GB1_A = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1931. sh.CreateTable("GB1_A", strcolumns_GB1_A, strcoltypes_GB1_A);
  1932. //创建表 GB1_B
  1933. string[] strcolumns_GB1_B = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1934. string[] strcoltypes_GB1_B = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1935. sh.CreateTable("GB1_B", strcolumns_GB1_B, strcoltypes_GB1_B);
  1936. //创建表 GB1_C
  1937. string[] strcolumns_GB1_C = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1938. string[] strcoltypes_GB1_C = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1939. sh.CreateTable("GB1_C", strcolumns_GB1_C, strcoltypes_GB1_C);
  1940. //创建表 GB1_D
  1941. string[] strcolumns_GB1_D = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1942. string[] strcoltypes_GB1_D = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1943. sh.CreateTable("GB1_D", strcolumns_GB1_D, strcoltypes_GB1_D);
  1944. //创建表 GB1_DS
  1945. string[] strcolumns_GB1_DS = { "No", "Area", "MaxFeret", "X", "Y", "Grade" };
  1946. string[] strcoltypes_GB1_DS = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1947. sh.CreateTable("GB1_DS", strcolumns_GB1_DS, strcoltypes_GB1_DS);
  1948. //创建表 GB2_A
  1949. string[] strcolumns_GB2_A = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1950. string[] strcoltypes_GB2_A = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1951. sh.CreateTable("GB2_A", strcolumns_GB2_A, strcoltypes_GB2_A);
  1952. //创建表 GB2_B
  1953. string[] strcolumns_GB2_B = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1954. string[] strcoltypes_GB2_B = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1955. sh.CreateTable("GB2_B", strcolumns_GB2_B, strcoltypes_GB2_B);
  1956. //创建表 GB2_C
  1957. string[] strcolumns_GB2_C = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1958. string[] strcoltypes_GB2_C = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1959. sh.CreateTable("GB2_C", strcolumns_GB2_C, strcoltypes_GB2_C);
  1960. //创建表 GB2_D
  1961. string[] strcolumns_GB2_D = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1962. string[] strcoltypes_GB2_D = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1963. sh.CreateTable("GB2_D", strcolumns_GB2_D, strcoltypes_GB2_D);
  1964. //创建表 GB2_D_sulfide
  1965. string[] strcolumns_GB2_D_sulfide = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
  1966. string[] strcoltypes_GB2_D_sulfide = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1967. sh.CreateTable("GB2_D_sulfide", strcolumns_GB2_D_sulfide, strcoltypes_GB2_D_sulfide);
  1968. //创建表 GB2_DS
  1969. string[] strcolumns_GB2_DS = { "No", "Area", "MaxFeret", "X", "Y", "Grade" };
  1970. string[] strcoltypes_GB2_DS = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
  1971. sh.CreateTable("GB2_DS", strcolumns_GB2_DS, strcoltypes_GB2_DS);
  1972. for (int i = 0; i < ResultGrid.Rows.Count; i++)
  1973. {
  1974. string ls_sqlstr = "insert into ResultGrid (CLJGMC, YXSJ, SCZS, FLFA, YJCTZ, SCMJ, CKBZ) values('"
  1975. + ResultGrid.Rows[i][0].ToString() + "','"
  1976. + ResultGrid.Rows[i][1].ToString() + "','"
  1977. + ResultGrid.Rows[i][2].ToString() + "','"
  1978. + ResultGrid.Rows[i][3].ToString() + "','"
  1979. + ResultGrid.Rows[i][4].ToString() + "','"
  1980. + ResultGrid.Rows[i][5].ToString() + "','"
  1981. + ResultGrid.Rows[i][6].ToString() + "')";
  1982. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  1983. }
  1984. //插入 GB1_A
  1985. for (int i = 0; i < GB1[0].Rows.Count; i++)
  1986. {
  1987. string ls_sqlstr = "insert into GB1_A (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  1988. + GB1[0].Rows[i][0].ToString() + "','"
  1989. + GB1[0].Rows[i][1].ToString() + "','"
  1990. + GB1[0].Rows[i][2].ToString() + "','"
  1991. + GB1[0].Rows[i][3].ToString() + "','"
  1992. + GB1[0].Rows[i][4].ToString() + "','"
  1993. + GB1[0].Rows[i][5].ToString() + "','"
  1994. + GB1[0].Rows[i][6].ToString() + "','"
  1995. + GB1[0].Rows[i][7].ToString() + "','"
  1996. + GB1[0].Rows[i][8].ToString() + "','"
  1997. + GB1[0].Rows[i][9].ToString() + "','"
  1998. + GB1[0].Rows[i][10].ToString() + "','"
  1999. + GB1[0].Rows[i][11].ToString() + "','"
  2000. + GB1[0].Rows[i][12].ToString() + "')";
  2001. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2002. }
  2003. //插入 GB1_B
  2004. for (int i = 0; i < GB1[1].Rows.Count; i++)
  2005. {
  2006. string ls_sqlstr = "insert into GB1_B (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  2007. + GB1[1].Rows[i][0].ToString() + "','"
  2008. + GB1[1].Rows[i][1].ToString() + "','"
  2009. + GB1[1].Rows[i][2].ToString() + "','"
  2010. + GB1[1].Rows[i][3].ToString() + "','"
  2011. + GB1[1].Rows[i][4].ToString() + "','"
  2012. + GB1[1].Rows[i][5].ToString() + "','"
  2013. + GB1[1].Rows[i][6].ToString() + "','"
  2014. + GB1[1].Rows[i][7].ToString() + "','"
  2015. + GB1[1].Rows[i][8].ToString() + "','"
  2016. + GB1[1].Rows[i][9].ToString() + "','"
  2017. + GB1[1].Rows[i][10].ToString() + "','"
  2018. + GB1[1].Rows[i][11].ToString() + "','"
  2019. + GB1[1].Rows[i][12].ToString() + "')";
  2020. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2021. }
  2022. //插入 GB1_C
  2023. for (int i = 0; i < GB1[2].Rows.Count; i++)
  2024. {
  2025. string ls_sqlstr = "insert into GB1_C (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  2026. + GB1[2].Rows[i][0].ToString() + "','"
  2027. + GB1[2].Rows[i][1].ToString() + "','"
  2028. + GB1[2].Rows[i][2].ToString() + "','"
  2029. + GB1[2].Rows[i][3].ToString() + "','"
  2030. + GB1[2].Rows[i][4].ToString() + "','"
  2031. + GB1[2].Rows[i][5].ToString() + "','"
  2032. + GB1[2].Rows[i][6].ToString() + "','"
  2033. + GB1[2].Rows[i][7].ToString() + "','"
  2034. + GB1[2].Rows[i][8].ToString() + "','"
  2035. + GB1[2].Rows[i][9].ToString() + "','"
  2036. + GB1[2].Rows[i][10].ToString() + "','"
  2037. + GB1[2].Rows[i][11].ToString() + "','"
  2038. + GB1[2].Rows[i][12].ToString() + "')";
  2039. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2040. }
  2041. //插入 GB1_D
  2042. for (int i = 0; i < GB1[3].Rows.Count; i++)
  2043. {
  2044. string ls_sqlstr = "insert into GB1_D (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  2045. + GB1[3].Rows[i][0].ToString() + "','"
  2046. + GB1[3].Rows[i][1].ToString() + "','"
  2047. + GB1[3].Rows[i][2].ToString() + "','"
  2048. + GB1[3].Rows[i][3].ToString() + "','"
  2049. + GB1[3].Rows[i][4].ToString() + "','"
  2050. + GB1[3].Rows[i][5].ToString() + "','"
  2051. + GB1[3].Rows[i][6].ToString() + "','"
  2052. + GB1[3].Rows[i][7].ToString() + "','"
  2053. + GB1[3].Rows[i][8].ToString() + "','"
  2054. + GB1[3].Rows[i][9].ToString() + "','"
  2055. + GB1[3].Rows[i][10].ToString() + "','"
  2056. + GB1[3].Rows[i][11].ToString() + "','"
  2057. + GB1[3].Rows[i][12].ToString() + "')";
  2058. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2059. }
  2060. //插入 GB1_DS
  2061. for (int i = 0; i < GB1[4].Rows.Count; i++)
  2062. {
  2063. string ls_sqlstr = "insert into GB1_DS (No, Area, MaxFeret, X, Y, Grade ) values('"
  2064. + GB1[4].Rows[i][0].ToString() + "','"
  2065. + GB1[4].Rows[i][1].ToString() + "','"
  2066. + GB1[4].Rows[i][2].ToString() + "','"
  2067. + GB1[4].Rows[i][3].ToString() + "','"
  2068. + GB1[4].Rows[i][4].ToString() + "','"
  2069. + GB1[4].Rows[i][5].ToString() + "')";
  2070. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2071. }
  2072. //插入 GB2_A
  2073. for (int i = 0; i < GB2[0].Rows.Count; i++)
  2074. {
  2075. string ls_sqlstr = "insert into GB2_A (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  2076. + GB2[0].Rows[i][0].ToString() + "','"
  2077. + GB2[0].Rows[i][1].ToString() + "','"
  2078. + GB2[0].Rows[i][2].ToString() + "','"
  2079. + GB2[0].Rows[i][3].ToString() + "','"
  2080. + GB2[0].Rows[i][4].ToString() + "','"
  2081. + GB2[0].Rows[i][5].ToString() + "','"
  2082. + GB2[0].Rows[i][6].ToString() + "','"
  2083. + GB2[0].Rows[i][7].ToString() + "','"
  2084. + GB2[0].Rows[i][8].ToString() + "','"
  2085. + GB2[0].Rows[i][9].ToString() + "','"
  2086. + GB2[0].Rows[i][10].ToString() + "','"
  2087. + GB2[0].Rows[i][11].ToString() + "','"
  2088. + GB2[0].Rows[i][12].ToString() + "')";
  2089. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2090. }
  2091. //插入 GB2_B
  2092. for (int i = 0; i < GB2[1].Rows.Count; i++)
  2093. {
  2094. string ls_sqlstr = "insert into GB2_B (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  2095. + GB2[1].Rows[i][0].ToString() + "','"
  2096. + GB2[1].Rows[i][1].ToString() + "','"
  2097. + GB2[1].Rows[i][2].ToString() + "','"
  2098. + GB2[1].Rows[i][3].ToString() + "','"
  2099. + GB2[1].Rows[i][4].ToString() + "','"
  2100. + GB2[1].Rows[i][5].ToString() + "','"
  2101. + GB2[1].Rows[i][6].ToString() + "','"
  2102. + GB2[1].Rows[i][7].ToString() + "','"
  2103. + GB2[1].Rows[i][8].ToString() + "','"
  2104. + GB2[1].Rows[i][9].ToString() + "','"
  2105. + GB2[1].Rows[i][10].ToString() + "','"
  2106. + GB2[1].Rows[i][11].ToString() + "','"
  2107. + GB2[1].Rows[i][12].ToString() + "')";
  2108. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2109. }
  2110. //插入 GB2_C
  2111. for (int i = 0; i < GB2[2].Rows.Count; i++)
  2112. {
  2113. string ls_sqlstr = "insert into GB2_C (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  2114. + GB2[2].Rows[i][0].ToString() + "','"
  2115. + GB2[2].Rows[i][1].ToString() + "','"
  2116. + GB2[2].Rows[i][2].ToString() + "','"
  2117. + GB2[2].Rows[i][3].ToString() + "','"
  2118. + GB2[2].Rows[i][4].ToString() + "','"
  2119. + GB2[2].Rows[i][5].ToString() + "','"
  2120. + GB2[2].Rows[i][6].ToString() + "','"
  2121. + GB2[2].Rows[i][7].ToString() + "','"
  2122. + GB2[2].Rows[i][8].ToString() + "','"
  2123. + GB2[2].Rows[i][9].ToString() + "','"
  2124. + GB2[2].Rows[i][10].ToString() + "','"
  2125. + GB2[2].Rows[i][11].ToString() + "','"
  2126. + GB2[2].Rows[i][12].ToString() + "')";
  2127. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2128. }
  2129. //插入 GB1_D
  2130. for (int i = 0; i < GB2[3].Rows.Count; i++)
  2131. {
  2132. string ls_sqlstr = "insert into GB2_D (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  2133. + GB2[3].Rows[i][0].ToString() + "','"
  2134. + GB2[3].Rows[i][1].ToString() + "','"
  2135. + GB2[3].Rows[i][2].ToString() + "','"
  2136. + GB2[3].Rows[i][3].ToString() + "','"
  2137. + GB2[3].Rows[i][4].ToString() + "','"
  2138. + GB2[3].Rows[i][5].ToString() + "','"
  2139. + GB2[3].Rows[i][6].ToString() + "','"
  2140. + GB2[3].Rows[i][7].ToString() + "','"
  2141. + GB2[3].Rows[i][8].ToString() + "','"
  2142. + GB2[3].Rows[i][9].ToString() + "','"
  2143. + GB2[3].Rows[i][10].ToString() + "','"
  2144. + GB2[3].Rows[i][11].ToString() + "','"
  2145. + GB2[3].Rows[i][12].ToString() + "')";
  2146. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2147. }
  2148. //插入 GB2_D_sulfide
  2149. for (int i = 0; i < GB2[4].Rows.Count; i++)
  2150. {
  2151. string ls_sqlstr = "insert into GB2_D_sulfide (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
  2152. + GB2[4].Rows[i][0].ToString() + "','"
  2153. + GB2[4].Rows[i][1].ToString() + "','"
  2154. + GB2[4].Rows[i][2].ToString() + "','"
  2155. + GB2[4].Rows[i][3].ToString() + "','"
  2156. + GB2[4].Rows[i][4].ToString() + "','"
  2157. + GB2[4].Rows[i][5].ToString() + "','"
  2158. + GB2[4].Rows[i][6].ToString() + "','"
  2159. + GB2[4].Rows[i][7].ToString() + "','"
  2160. + GB2[4].Rows[i][8].ToString() + "','"
  2161. + GB2[4].Rows[i][9].ToString() + "','"
  2162. + GB2[4].Rows[i][10].ToString() + "','"
  2163. + GB2[4].Rows[i][11].ToString() + "','"
  2164. + GB2[4].Rows[i][12].ToString() + "')";
  2165. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2166. }
  2167. //插入 GB1_DS
  2168. for (int i = 0; i < GB2[5].Rows.Count; i++)
  2169. {
  2170. string ls_sqlstr = "insert into GB2_DS (No, Area, MaxFeret, X, Y, Grade ) values('"
  2171. + GB1[5].Rows[i][0].ToString() + "','"
  2172. + GB1[5].Rows[i][1].ToString() + "','"
  2173. + GB1[5].Rows[i][2].ToString() + "','"
  2174. + GB1[5].Rows[i][3].ToString() + "','"
  2175. + GB1[5].Rows[i][4].ToString() + "','"
  2176. + GB1[5].Rows[i][5].ToString() + "')";
  2177. int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
  2178. }
  2179. //事务提交
  2180. sh.TranscationCommit(tr);
  2181. }
  2182. catch (Exception ee)
  2183. {
  2184. //回滚
  2185. sh.TranscationRollback(tr);
  2186. }
  2187. finally
  2188. {
  2189. //最后关闭连接
  2190. tr.Dispose();
  2191. tr = null;
  2192. sh.CloseConnection();
  2193. }
  2194. }
  2195. /// <summary>
  2196. /// 打开国标导出
  2197. /// </summary>
  2198. private void OpenOTSINcAreportGBTemplateAPP()
  2199. {
  2200. ProcessStartInfo process = new ProcessStartInfo();
  2201. process.FileName = "ReportTemplateExe\\OTSIncAReportTemplate.exe";//打开app的路径
  2202. string arg1 = m_strDBpathGB.Replace(" ", "^");//参数1,是需要打开db数据库的路径
  2203. string arg2 = tb_mblj.Text.Trim().Replace(" ", "^");//参数2,是模板文件的路径
  2204. string arg3 = "GBReport";//主体报表
  2205. string arg4 = "100";//夹杂物数量
  2206. string arg5 = "0-100";//打开的标记帧图图像数量
  2207. process.Arguments = string.Format("{0} {1} {2} {3} {4}", arg1, arg2, arg3, arg4, arg5); //多个参数用空格隔开
  2208. process.WindowStyle = ProcessWindowStyle.Normal;
  2209. Process.Start(process);
  2210. }
  2211. }
  2212. }