1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398 |
- using OTSIncAReportApp.Controls;
- using OTSIncAReportApp.DataOperation.DataAccess;
- using OTSIncAReportApp.OTSSampleReportInfo;
- using OTSIncAReportApp.OTSTemplateDesigner;
- using OTSIncAReportApp.SysMgrTools;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.SQLite;
- using System.Diagnostics;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Windows.Forms;
- namespace OTSIncAReportApp
- {
- public partial class OTSReport_Export : Form
- {
-
- #region 全局变量
- public string m_thread_flag = "无"; //线程操作的标识
- public string m_str_tmpbitmappath = "d:\\1.bmp"; //存放临时图片 的路径名和文件名
- public string m_str_tmpbitmappath2 = "d:\\2.bmp";
- public string m_str_tmpdocxpath = "d:\\1.doc";
- public string m_strDBpath = ""; //报表模板数据库文件
- public string m_strDBpathGB = ""; //报告国标导出
- public string m_strDBpath_ParticleList = ""; //报表模板,颗粒列表数据库文件
- System.Collections.Hashtable table;
- public frmReportApp m_ReportApp = null; //报告项目总进程对象
- public string m_export_type = "Excel"; //导出文件的格式类型Excel,Word,Pdf
- Export_ReportTemplate m_export_reporttemplate;
- public string strPath = "./Config/ProData/ReportTemplateConfig.xml"; //报告模板设置文件的路径
- public string strPath2;
- public XmlConfigUtil xmlutil;
- public XmlConfigUtil xmlutil2;
- public MBSZClass m_mbszclass = null;
-
- #endregion
- #region 条件参数变量
- /// <summary>
- /// 选择的数据类型
- /// </summary>
- public string SJLX { get; set; }
- /// <summary>
- /// 尺寸计算方法
- /// </summary>
- public string CCJSFF { get; set; }
- /// <summary>
- /// 粒级表
- /// </summary>
- public string LJB { get; set; }
- /// <summary>
- /// 三元相图模板
- /// </summary>
- public string SYXTMB { get; set; }
- #endregion
- #region 模板设置类
- /// <summary>
- /// 模板设置类
- /// </summary>
- public class MBSZClass
- {
- public DZ M_DZ { get; set; }
- #region 属性
- /// <summary>
- /// 首页
- /// </summary>
- public SY M_SY { get; set; }
- /// <summary>
- /// 页眉页脚
- /// </summary>
- public YMYJ M_YMYJ { get; set; }
- /// <summary>
- /// 颗粒分析结果
- /// </summary>
- public KLFXJG M_KLFXJG { get; set; }
- /// <summary>
- /// 元素分析结果
- /// </summary>
- public YSFXJG M_YSFXJG { get; set; }
- /// <summary>
- /// 三元相图
- /// </summary>
- public SYXT M_SYXT { get; set; }
- /// <summary>
- /// 颗粒列表信息
- /// </summary>
- public KLLBXX M_KLLBXX { get; set; }
- #endregion
- #region 构造函数
- public MBSZClass()
- {
- M_SY = new SY();
- M_YMYJ = new YMYJ();
- M_KLFXJG = new KLFXJG();
- M_YSFXJG = new YSFXJG();
- M_YSFXJG.list_str_tb_yscf_ysxx = new List<string>();
- M_YSFXJG.list_str_tb_ysfx_xsys = new List<string>();
- M_SYXT = new SYXT();
- M_SYXT.list_lbv_syxt_mblb = new List<string>();
- M_SYXT.list_lbv_syxt_mblb_index = new List<int>();
- M_KLLBXX = new KLLBXX();
- M_KLLBXX.list_str_tb_lllb_sxys = new List<string>();
- M_DZ = new DZ();
- }
- #endregion
- public class DZ
- {
- public string route { get; set; }
- }
- #region 首页部份
- public class SY
- {
- /// <summary>
- /// 主标题
- /// </summary>
- public string str_tb_ZBT { get; set; }
- /// <summary>
- /// 副标题
- /// </summary>
- public string str_tb_FBT { get; set; }
- /// <summary>
- /// 样品编号
- /// </summary>
- public string str_tb_YPBH { get; set; }
- /// <summary>
- /// 参考标准
- /// </summary>
- public string str_tb_CKBZ { get; set; }
- /// <summary>
- /// 是否显示样品说明
- /// </summary>
- public bool b_ck_ypsm { get; set; }
- /// <summary>
- /// 是否显示结果概况
- /// </summary>
- public bool b_ck_jggk { get; set; }
- }
- #endregion
- #region 页眉页脚部份
- public class YMYJ
- {
- /// <summary>
- /// 页眉文本
- /// </summary>
- public string str_tb_ymwb { get; set; }
- /// <summary>
- /// 客户号
- /// </summary>
- public string str_tb_KHH { get; set; }
- /// <summary>
- /// 是否显示页码
- /// </summary>
- public bool b_ck_ym { get; set; }
- /// <summary>
- /// 页脚文本
- /// </summary>
- public string str_tb_yjwb { get; set; }
- }
- #endregion
- #region 颗粒分析结果部份
- public class KLFXJG
- {
- /// <summary>
- /// 是否显示颗粒尺寸分析结果表
- /// </summary>
- public bool b_ck_klcc_xsmk { get; set; }
- /// <summary>
- ///颗粒尺寸分析结果表 计算方式文本
- /// </summary>
- public string str_cb_klcc_jsfs { get; set; }
- /// <summary>
- ///颗粒尺寸分析结果表 计算方式索引
- /// </summary>
- public int index_cb_klcc_jsfs { get; set; }
- /// <summary>
- ///颗粒尺寸分析结果表 粒级表文本
- /// </summary>
- public string str_cb_klcc_ljb { get; set; }
- /// <summary>
- ///颗粒尺寸分析结果表 粒级表索引
- /// </summary>
- public int index_cb_klcc_ljb { get; set; }
- /// <summary>
- ///颗粒尺寸分析结果表 颗粒选择范围文本
- /// </summary>
- public string str_cb_klcc_klfw { get; set; }
- /// <summary>
- ///颗粒尺寸分析结果表 颗粒选择范围索引
- /// </summary>
- public int index_cb_klcc_klfw { get; set; }
- /// <summary>
- /// 夹杂物分类图 是否显示该模块
- /// </summary>
- public bool b_cb_jzwfl_xsmk { get; set; }
- /// <summary>
- ///夹杂物分类图 显示图形选择文本
- /// </summary>
- public string str_cb_jzwfl_xstx { get; set; }
- /// <summary>
- ///夹杂物分类图 显示图形 选择索引
- /// </summary>
- public int index_cb_jzwfl_xstx { get; set; }
- /// <summary>
- ///夹杂物分类图 计算方式 选择文本
- /// </summary>
- public string str_cb_jzwfl_jsfs { get; set; }
- /// <summary>
- ///夹杂物分类图 计算方式 选择索引
- /// </summary>
- public int index_cb_jzwfl_jsfs { get; set; }
- /// <summary>
- ///夹杂物分类图 粒级表 选择文本
- /// </summary>
- public string str_cb_jzwfl_ljb { get; set; }
- /// <summary>
- ///夹杂物分类图 粒级表 选择索引
- /// </summary>
- public int index_cb_jzwfl_ljb { get; set; }
- /// <summary>
- ///夹杂物分类图 颗粒范围 选择文本
- /// </summary>
- public string str_cb_jzwfl_klfw { get; set; }
- /// <summary>
- ///夹杂物分类图 颗粒范围 选择索引
- /// </summary>
- public int index_cb_jzwfl_klfw { get; set; }
- }
- #endregion
- #region 元素分析结果部份
- public class YSFXJG
- {
- /// <summary>
- /// 元素分析表 是否显示该模块
- /// </summary>
- public bool b_ck_ysfx_xsmk { get; set; }
- /// <summary>
- /// 元素分析表 计算方式 选择文本
- /// </summary>
- public string str_cb_yxfx_jsfs { get; set; }
- /// <summary>
- /// 元素分析表 计算方式 选择索引
- /// </summary>
- public int index_cb_yxfx_jsfs { get; set; }
- /// <summary>
- /// 元素分析表 颗粒范围 选择文本
- /// </summary>
- public string str_cb_ysfx_klfw { get; set; }
- /// <summary>
- /// 元素分析表 颗粒范围 选择索引
- /// </summary>
- public int index_cb_ysfx_klfw { get; set; }
- /// <summary>
- /// 元素分析表 显示元素显示文本
- /// </summary>
- public string str_tb_ysfx_xsys { get; set; }
- /// <summary>
- /// 元素分析表 显示元素拆分元素列表
- /// </summary>
- public List<string> list_str_tb_ysfx_xsys { get; set; }
- /// <summary>
- /// 元素成份图 是否显示该模块
- /// </summary>
- public bool b_ck_yscf_xsmk { get; set; }
- /// <summary>
- /// 元素成份图 显示图形 文本
- /// </summary>
- public string str_cb_yscf_xstx { get; set; }
- /// <summary>
- /// 元素成份图 显示图形 索引
- /// </summary>
- public int index_cb_yscf_xstx { get; set; }
- /// <summary>
- /// 元素成份图 计算方式 文本
- /// </summary>
- public string str_cb_yscf_jsfs { get; set; }
- /// <summary>
- /// 元素成份图 计算方式 索引
- /// </summary>
- public int index_cb_yscf_jsfs { get; set; }
- /// <summary>
- /// 元素成份图 颗粒范围 文本
- /// </summary>
- public string str_cb_yscf_klfw { get; set; }
- /// <summary>
- /// 元素成份图 颗粒范围 索引
- /// </summary>
- public int index_cb_yscf_klfw { get; set; }
- /// <summary>
- /// 元素成份图 元素信息
- /// </summary>
- public string str_tb_yscf_ysxx { get; set; }
- /// <summary>
- /// 元素成份图 元素信息列表拆分字符列表
- /// </summary>
- public List<string> list_str_tb_yscf_ysxx { get; set; }
- }
- #endregion
- #region 三元相图部份
- public class SYXT
- {
- /// <summary>
- /// 三元相图 是否显示该模块
- /// </summary>
- public bool b_ck_syxt_xsmk { get; set; }
- /// <summary>
- /// 计算方式 文本
- /// </summary>
- public string str_cb_syxt_jsfs { get; set; }
- /// <summary>
- /// 计算方式 索引
- /// </summary>
- public int index_cb_syxt_jsfs { get; set; }
- /// <summary>
- /// 颗粒范围 文本
- /// </summary>
- public string str_cb_syxt_klfw { get; set; }
- /// <summary>
- /// 颗粒范围 索引
- /// </summary>
- public int index_cb_syxt_klfw { get; set; }
- /// <summary>
- /// 粒级表信息 文本
- /// </summary>
- public string str_cb_syxt_ljb { get; set; }
- /// <summary>
- /// 粒级表信息 索引
- /// </summary>
- public int index_cb_syxt_ljb { get; set; }
- /// <summary>
- /// 每行显示数量 文本
- /// </summary>
- public string str_cb_syxt_mhxssl { get; set; }
- /// <summary>
- /// 每行显示数量 索引
- /// </summary>
- public int index_cb_syxt_mhxssl { get; set; }
- /// <summary>
- /// 三元相图模板集合列表
- /// </summary>
- public List<string> list_lbv_syxt_mblb { get; set; }
- /// <summary>
- /// 三元相图模板索引集合列表
- /// </summary>
- public List<int> list_lbv_syxt_mblb_index { get; set; }
- }
- #endregion
- #region 颗粒列表信息部份
- public class KLLBXX
- {
- /// <summary>
- /// 颗粒列表 是否显示该模块
- /// </summary>
- public bool b_ck_kllb_xsmk { get; set; }
- /// <summary>
- /// 颗粒列表 计算方式 文本
- /// </summary>
- public string str_cb_kllb_jsfs { get; set; }
- /// <summary>
- /// 颗粒列表 计算方式 索引
- /// </summary>
- public int index_cb_kllb_jsfs { get; set; }
- /// <summary>
- /// 颗粒列表 颗粒范围 文本
- /// </summary>
- public string str_cb_kllb_klfw { get; set; }
- /// <summary>
- /// 颗粒列表 颗粒范围 索引
- /// </summary>
- public int index_cb_kllb_klfw { get; set; }
- /// <summary>
- /// 颗粒列表 数量上限
- /// </summary>
- public int int_tb_kllb_ylsx { get; set; }
- /// <summary>
- /// 颗粒列表 显示元素
- /// </summary>
- public string str_tb_kllb_sxys { get; set; }
- /// <summary>
- /// 颗粒列表 显示元素拆分元素列表
- /// </summary>
- public List<string> list_str_tb_lllb_sxys { get; set; }
- /// <summary>
- /// 颗粒列表 是否显示原始图像
- /// </summary>
- public bool b_ck_kllb_ystx { get; set; }
- /// <summary>
- /// 颗粒列表 是否显示放大图像
- /// </summary>
- public bool b_ck_kllb_fdtx { get; set; }
- /// <summary>
- /// 颗粒列表 是否显示能谱信息
- /// </summary>
- public bool b_ck_kllb_npxx { get; set; }
- }
- #endregion
- }
- #endregion
- #region 窗体加载及构造函数
- public OTSReport_Export(frmReportApp ReportApp)
- {
- InitializeComponent();
- m_ReportApp = ReportApp;
- m_export_reporttemplate = new Export_ReportTemplate(this);
- //初始化xml类
- xmlutil = new XmlConfigUtil(strPath);
- m_mbszclass = new MBSZClass();
- //读取配置文件中的模板
- LoadMBSZClass();
- LoadRouteclass();
- #region 国际化语言
- Language lan = new Language(this);
- table = lan.GetNameTable(this.Name);
- #endregion
- }
- ///<summary>
- ///从配置文件中读取报告模板信息
- /// </summary>
- private void LoadRouteclass()
- {
- if (m_mbszclass.M_DZ.route == null)
- {
- strPath2 = strPath;
- m_mbszclass.M_DZ.route = strPath;
- }
- else
- if (m_mbszclass.M_DZ.route == "")
- {
- strPath2 = strPath;
- m_mbszclass.M_DZ.route = strPath;
- }
- else
- {
- strPath2 = m_mbszclass.M_DZ.route;
- }
- xmlutil2 = new XmlConfigUtil(strPath2);
- //首页
- m_mbszclass.M_SY.str_tb_ZBT = xmlutil2.Read("M_SY", "str_tb_ZBT");
- m_mbszclass.M_SY.str_tb_FBT = xmlutil2.Read("M_SY", "str_tb_FBT");
- m_mbszclass.M_SY.str_tb_YPBH = xmlutil2.Read("M_SY", "str_tb_YPBH");
- m_mbszclass.M_SY.str_tb_CKBZ = xmlutil2.Read("M_SY", "str_tb_CKBZ");
- m_mbszclass.M_SY.b_ck_ypsm = Convert.ToBoolean(xmlutil2.Read("M_SY", "b_ck_ypsm"));
- m_mbszclass.M_SY.b_ck_jggk = Convert.ToBoolean(xmlutil2.Read("M_SY", "b_ck_jggk"));
- //页眉页脚
- m_mbszclass.M_YMYJ.str_tb_ymwb = xmlutil2.Read("M_YMYJ", "str_tb_ymwb");
- m_mbszclass.M_YMYJ.str_tb_KHH = xmlutil2.Read("M_YMYJ", "str_tb_KHH");
- m_mbszclass.M_YMYJ.b_ck_ym = Convert.ToBoolean(xmlutil2.Read("M_YMYJ", "b_ck_ym"));
- m_mbszclass.M_YMYJ.str_tb_yjwb = xmlutil2.Read("M_YMYJ", "str_tb_yjwb");
- //颗粒分析结果
- m_mbszclass.M_KLFXJG.b_ck_klcc_xsmk = Convert.ToBoolean(xmlutil2.Read("M_KLFXJG", "b_ck_klcc_xsmk"));//是否显示模块
- m_mbszclass.M_KLFXJG.index_cb_klcc_jsfs = Convert.ToInt32(xmlutil2.Read("M_KLFXJG", "index_cb_klcc_jsfs"));//计算方式
- m_mbszclass.M_KLFXJG.index_cb_klcc_ljb = Convert.ToInt32(xmlutil2.Read("M_KLFXJG", "index_cb_klcc_ljb"));//粒级表
- m_mbszclass.M_KLFXJG.index_cb_klcc_klfw = Convert.ToInt32(xmlutil2.Read("M_KLFXJG", "index_cb_klcc_klfw"));//颗粒范围
- m_mbszclass.M_KLFXJG.b_cb_jzwfl_xsmk = Convert.ToBoolean(xmlutil2.Read("M_KLFXJG", "b_cb_jzwfl_xsmk"));//是否显示该模块
- m_mbszclass.M_KLFXJG.index_cb_jzwfl_xstx = Convert.ToInt32(xmlutil2.Read("M_KLFXJG", "index_cb_jzwfl_xstx"));//选择图像
- m_mbszclass.M_KLFXJG.index_cb_jzwfl_jsfs = Convert.ToInt32(xmlutil2.Read("M_KLFXJG", "index_cb_jzwfl_jsfs"));//计算方式
- m_mbszclass.M_KLFXJG.index_cb_jzwfl_ljb = Convert.ToInt32(xmlutil2.Read("M_KLFXJG", "index_cb_jzwfl_ljb"));//粒级表
- m_mbszclass.M_KLFXJG.index_cb_jzwfl_klfw = Convert.ToInt32(xmlutil2.Read("M_KLFXJG", "index_cb_jzwfl_klfw"));//颗粒范围
- //元素分析结果
- m_mbszclass.M_YSFXJG.b_ck_ysfx_xsmk = Convert.ToBoolean(xmlutil2.Read("M_YSFXJG", "b_ck_ysfx_xsmk")); //是否显示模块
- m_mbszclass.M_YSFXJG.index_cb_yxfx_jsfs = Convert.ToInt32(xmlutil2.Read("M_YSFXJG", "index_cb_yxfx_jsfs")); //计算方式
- m_mbszclass.M_YSFXJG.index_cb_ysfx_klfw = Convert.ToInt32(xmlutil2.Read("M_YSFXJG", "index_cb_ysfx_klfw")); //颗粒范围
- m_mbszclass.M_YSFXJG.str_tb_ysfx_xsys = xmlutil2.Read("M_YSFXJG", "str_tb_ysfx_xsys"); //显示元素
- m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys.Clear();
- for (int i = 0; i < 100; i++) //取得所有元素列表
- {
- string str = xmlutil2.Read("M_YSFXJG", "list_str_tb_ysfx_xsys", "YS" + i.ToString());
- if (str == null)
- {
- break;
- }
- else
- {
- m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys.Add(str);
- }
- }
- m_mbszclass.M_YSFXJG.b_ck_yscf_xsmk = Convert.ToBoolean(xmlutil2.Read("M_YSFXJG", "b_ck_yscf_xsmk")); //是否显示模块
- m_mbszclass.M_YSFXJG.index_cb_yscf_xstx = Convert.ToInt32(xmlutil2.Read("M_YSFXJG", "index_cb_yscf_xstx")); //显示图形
- m_mbszclass.M_YSFXJG.index_cb_yscf_jsfs = Convert.ToInt32(xmlutil2.Read("M_YSFXJG", "index_cb_yscf_jsfs")); //计算方式
- m_mbszclass.M_YSFXJG.index_cb_yscf_klfw = Convert.ToInt32(xmlutil2.Read("M_YSFXJG", "index_cb_yscf_klfw")); //颗粒范围
- m_mbszclass.M_YSFXJG.str_tb_yscf_ysxx = xmlutil2.Read("M_YSFXJG", "str_tb_yscf_ysxx"); //显示元素
- m_mbszclass.M_YSFXJG.list_str_tb_yscf_ysxx.Clear();
- for (int i = 0; i < 100; i++) //取得所有元素列表
- {
- string str = xmlutil2.Read("M_YSFXJG", "list_str_tb_yscf_ysxx", "YS" + i.ToString());
- if (str == null)
- {
- break;
- }
- else
- {
- m_mbszclass.M_YSFXJG.list_str_tb_yscf_ysxx.Add(str);
- }
- }
- //三元相图
- m_mbszclass.M_SYXT.b_ck_syxt_xsmk = Convert.ToBoolean(xmlutil2.Read("M_SYXT", "b_ck_syxt_xsmk")); //是否显示模块
- m_mbszclass.M_SYXT.index_cb_syxt_jsfs = Convert.ToInt32(xmlutil2.Read("M_SYXT", "index_cb_syxt_jsfs")); //计算方式
- m_mbszclass.M_SYXT.index_cb_syxt_klfw = Convert.ToInt32(xmlutil2.Read("M_SYXT", "index_cb_syxt_klfw")); //颗粒范围
- m_mbszclass.M_SYXT.str_cb_syxt_mhxssl = xmlutil2.Read("M_SYXT", "str_cb_syxt_mhxssl"); //每行显示数量
- m_mbszclass.M_SYXT.list_lbv_syxt_mblb.Clear();
- for (int i = 0; i < 100; i++) //取得所有模板列表
- {
- string str = xmlutil2.Read("M_SYXT", "list_lbv_syxt_mblb", "MB" + i.ToString());
- if (str == null)
- {
- break;
- }
- else
- {
- m_mbszclass.M_SYXT.list_lbv_syxt_mblb.Add(str);
- }
- }
- m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Clear();
- for (int i = 0; i < 100; i++) //取得所有模板列表 索引
- {
- string str = xmlutil2.Read("M_SYXT", "list_lbv_syxt_mblb_index", "MBIndex" + i.ToString());
- if (str == null)
- {
- break;
- }
- else
- {
- m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Add(Convert.ToInt32(str));
- }
- }
- //颗粒列表信息
- m_mbszclass.M_KLLBXX.b_ck_kllb_xsmk = Convert.ToBoolean(xmlutil2.Read("M_KLLBXX", "b_ck_kllb_xsmk")); //是否显示模块
- m_mbszclass.M_KLLBXX.index_cb_kllb_jsfs = Convert.ToInt32(xmlutil2.Read("M_KLLBXX", "index_cb_kllb_jsfs")); //计算方式
- m_mbszclass.M_KLLBXX.index_cb_kllb_klfw = Convert.ToInt32(xmlutil2.Read("M_KLLBXX", "index_cb_kllb_klfw")); //颗粒范围
- m_mbszclass.M_KLLBXX.int_tb_kllb_ylsx = Convert.ToInt32(xmlutil2.Read("M_KLLBXX", "int_tb_kllb_ylsx")); //数量上限
- m_mbszclass.M_KLLBXX.str_tb_kllb_sxys = xmlutil2.Read("M_KLLBXX", "str_tb_kllb_sxys"); //显示元素
- m_mbszclass.M_KLLBXX.list_str_tb_lllb_sxys.Clear();
- for (int i = 0; i < 100; i++) //取得所有元素列表
- {
- string str = xmlutil2.Read("M_KLLBXX", "list_str_tb_lllb_sxys", "YS" + i.ToString());
- if (str == null)
- {
- break;
- }
- else
- {
- m_mbszclass.M_KLLBXX.list_str_tb_lllb_sxys.Add(str);
- }
- }
- m_mbszclass.M_KLLBXX.b_ck_kllb_ystx = Convert.ToBoolean(xmlutil2.Read("M_KLLBXX", "b_ck_kllb_ystx")); //原始图像
- m_mbszclass.M_KLLBXX.b_ck_kllb_fdtx = Convert.ToBoolean(xmlutil2.Read("M_KLLBXX", "b_ck_kllb_fdtx")); //放大图像
- m_mbszclass.M_KLLBXX.b_ck_kllb_npxx = Convert.ToBoolean(xmlutil2.Read("M_KLLBXX", "b_ck_kllb_npxx")); //能谱图像
- }
- /// <summary>
- /// 从配置文件中读取报告模板路径
- /// </summary>
- private void LoadMBSZClass()
- {
- //文件路径
- m_mbszclass.M_DZ.route = xmlutil.Read("M_address", "Path");
- if (m_mbszclass.M_DZ.route == "")
- {
- tb_mblj.Text = strPath;
- m_mbszclass.M_DZ.route = strPath;
- }
- else
- if (File.Exists(m_mbszclass.M_DZ.route))
- {
- tb_mblj.Text = m_mbszclass.M_DZ.route;
- }
- else
- {
- tb_mblj.Text = strPath;
- m_mbszclass.M_DZ.route = strPath;
- }
- }
- /// <summary>
- /// 将报告模板信息保存到配置文件中
- /// </summary>
- private void SaveMBSClass()
- {
- //文件路径
- xmlutil.Write(m_mbszclass.M_DZ.route.ToString(), "M_address", "Path");
- }
- /// <summary>
- /// 传入,3个层级的xml结点标识,进行删除结点
- /// </summary>
- /// <param name="strnode_mk"></param>
- /// <param name="strnode_kj"></param>
- /// <param name="strnode_xh"></param>
- private void RemoveMBSZClassNode(string strnode_mk, string strnode_kj, string strnode_xh, int int_start)
- {
- for (int i = int_start; i < 1000; i++)
- {
- string strxh = i.ToString();
- if (null != xmlutil.Read(strnode_mk, strnode_kj, strnode_xh + strxh))
- {
- //删除该节点
- xmlutil.RemoveNode(strnode_mk, strnode_kj, strnode_xh + strxh);
- }
- else
- {
- break;
- }
- }
- }
-
-
- /// <summary>
- /// 加载报告模板选择项,数据源选项
- /// </summary>
- private void BindComboBox()
- {
- //加载数据源
- for (int i = 0; i < m_ReportApp.m_rstDataMgr.ResultFilesList.Count; i++)
- {
- cbo_sjy.Items.Add(m_ReportApp.m_rstDataMgr.ResultFilesList[i].FileName);
- }
- if (cbo_sjy.Items.Count > 0)
- cbo_sjy.SelectedIndex = 0;
- }
- private void OTSReport_Export_Load(object sender, EventArgs e)
- {
-
- //先获取D盘,如果没有,则再获取C盘
- string str_drivename = GetSecondDriveName();
- if (str_drivename == "")
- str_drivename = GetFirstDriveName();
- //初始化临时文件位置
- m_str_tmpbitmappath = str_drivename + "1.bmp";
- m_str_tmpbitmappath2 = str_drivename + "2.bmp";
- m_str_tmpdocxpath = str_drivename + "1.doc";
- //窗体加载时,初始化Combobox
- BindComboBox();
- //设置界面线程
- backgroundWorker2.WorkerReportsProgress = true;
- backgroundWorker2.WorkerSupportsCancellation = true;
- //确定报表进程db数据库的路径
- string strdbname = "ReportTemplateDB.db";
- m_strDBpath = m_ReportApp.m_rstDataMgr.ResultFilesList[cbo_sjy.SelectedIndex].FilePath;
- m_strDBpathGB = m_ReportApp.m_rstDataMgr.ResultFilesList[cbo_sjy.SelectedIndex].FilePath;
- m_strDBpath = m_strDBpath + "\\" + strdbname;
- m_strDBpathGB = m_strDBpathGB + "\\" + "ReportGBDB.db";
- string strdbparticlelistname = "ReportTemplateDBParticleList.db";
- m_strDBpath_ParticleList = m_ReportApp.m_rstDataMgr.ResultFilesList[cbo_sjy.SelectedIndex].FilePath;
- m_strDBpath_ParticleList = m_strDBpath_ParticleList + "\\" + strdbparticlelistname;
-
- }
- #endregion
- #region 自定义方法
- /// <summary>
- /// 传入完整的路径及文件名,和需要的扩展名,返回文件加上需要的扩展名
- /// </summary>
- /// <param name="in_str"></param>
- /// <param name="in_extename"></param>
- /// <returns></returns>
- public string GetFileExteName(string in_str, string in_extename)
- {
- string ret_str = in_str.Substring(0, in_str.IndexOf('.'));
- ret_str = ret_str + in_extename;
- return ret_str;
- }
- /// <summary>
- /// 获取第一个磁盘盘符的名称
- /// </summary>
- /// <returns></returns>
- public string GetFirstDriveName()
- {
- System.IO.DriveInfo[] ls_driveinfo = System.IO.DriveInfo.GetDrives();
- if (ls_driveinfo.Count() > 0)
- return ls_driveinfo[0].Name;
- return "";
- }
- /// <summary>
- /// 获取第二个磁盘盘符的名称,因为有时c盘不会给予读写的权限,所以要用到这个
- /// </summary>
- /// <returns></returns>
- private string GetSecondDriveName()
- {
- System.IO.DriveInfo[] ls_driveinfo = System.IO.DriveInfo.GetDrives();
- if (ls_driveinfo.Count() > 1)
- return ls_driveinfo[1].Name;
- return "";
- }
- /// <summary>
- /// 将文本追加到RictBox的尾部上
- /// </summary>
- public void WriteRictBox(string in_str)
- {
- //追加到rictbox尾部
- richTextBox1.AppendText("[" + DateTime.Now.Hour.ToString() + ":"
- + DateTime.Now.Minute.ToString() + ":"
- + DateTime.Now.Second.ToString() + "]"
- + in_str + Environment.NewLine);
- richTextBox1.SelectionColor = GetRandomColor30(30);
- richTextBox1.ScrollToCaret();
- }
- /// <summary>
- /// 重载输出文本,带有可以指定颜色
- /// </summary>
- /// <param name="in_str"></param>
- /// <param name="in_c"></param>
- public void WriteRictBox(string in_str, Color in_c)
- {
- //追加到rictbox尾部
- richTextBox1.AppendText("[" + DateTime.Now.Hour.ToString() + ":"
- + DateTime.Now.Minute.ToString() + ":"
- + DateTime.Now.Second.ToString() + "]"
- + in_str + Environment.NewLine);
- richTextBox1.SelectionColor = in_c;
- richTextBox1.ScrollToCaret();
- }
- /// <summary>
- /// 根据传入的颜色,及传入Size的大小,返回一个该色的bitmap对象
- /// </summary>
- /// <param name="in_c"></param>
- /// <returns></returns>
- public Bitmap GetBitmapByColor(Color in_c, Size in_z)
- {
- Bitmap bmp = new Bitmap(in_z.Width, in_z.Height); //这里给104是为了左边和右边空出2个像素,剩余的100就是百分比的值
- Graphics g = Graphics.FromImage(bmp);
- g.Clear(Color.White);
- SolidBrush drawBrush = new SolidBrush(Color.Black);
- g.FillRectangle(new SolidBrush(in_c), 0, 0, in_z.Width, in_z.Height);
- return bmp;
- }
- /// <summary>
- /// [颜色:16进制转成RGB]
- /// </summary>
- /// <param name="strColor">设置16进制颜色 [返回RGB]</param>
- /// <returns></returns>
- public System.Drawing.Color colorHx16toRGB(string strHxColor)
- {
- try
- {
- if (strHxColor.Length == 0)
- {//如果为空
- return System.Drawing.Color.FromArgb(0, 0, 0);//设为黑色
- }
- else
- {//转换颜色
- if (strHxColor.IndexOf('#') > -1)
- {
- //如果颜色格式是 #0000FF 格式的
- 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));
- }
- else
- {
- //如果颜色格式是 0000FF 格式的
- 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));
- }
- }
- }
- catch
- {//设为黑色
- return System.Drawing.Color.FromArgb(0, 0, 0);
- }
- }
- /// <summary>
- /// [颜色:RGB转成16进制]专为输出Excel表头格式而定制,其它地方不要使用该方法,或修改返回加#号,例#000000FF
- /// </summary>
- /// <param name="R">红 int</param>
- /// <param name="G">绿 int</param>
- /// <param name="B">蓝 int</param>
- /// <returns></returns>
- public string colorRGBtoHx16ForExcel(Color color)
- {
- if (color.IsEmpty)
- return "000000";
- return String.Format("{0:X2}{1:X2}{2:X2}", color.R, color.G, color.B);
- }
- /// <summary>
- /// 将RGB颜色转成整数
- /// </summary>
- /// <param name="color"></param>
- /// <returns></returns>
- public int ParseRGB(Color color)
- {
- return (int)(((int)color.B << 16) | (ushort)(((ushort)color.G << 8) | color.R));
- }
- /// <summary>
- /// 从指定的几种颜色中进行随机颜色,传入30个颜色的范围,越大颜色越多
- /// </summary>
- /// <returns></returns>
- public Color GetRandomColor30(int i_randomrange)
- {
- Random r = new Random();
- int n = r.Next(0, i_randomrange);
- Color ret_color;
- switch (n)
- {
- case 1:
- ret_color = Color.Aqua;
- break;
- case 2:
- ret_color = Color.Black;
- break;
- case 3:
- ret_color = Color.Blue;
- break;
- case 4:
- ret_color = Color.BlueViolet;
- break;
- case 5:
- ret_color = Color.Brown;
- break;
- case 6:
- ret_color = Color.BurlyWood;
- break;
- case 7:
- ret_color = Color.CadetBlue;
- break;
- case 8:
- ret_color = Color.CadetBlue;
- break;
- case 9:
- ret_color = Color.CornflowerBlue;
- break;
- case 10:
- ret_color = Color.DarkBlue;
- break;
- case 11:
- ret_color = Color.Gray;
- break;
- case 12:
- ret_color = Color.Indigo;
- break;
- case 13:
- ret_color = Color.LightSlateGray;
- break;
- case 14:
- ret_color = Color.Magenta;
- break;
- case 15:
- ret_color = Color.Maroon;
- break;
- case 16:
- ret_color = Color.MediumBlue;
- break;
- case 17:
- ret_color = Color.MediumOrchid;
- break;
- case 18:
- ret_color = Color.MidnightBlue;
- break;
- case 19:
- ret_color = Color.Navy;
- break;
- case 20:
- ret_color = Color.Olive;
- break;
- case 21:
- ret_color = Color.PaleVioletRed;
- break;
- case 22:
- ret_color = Color.Peru;
- break;
- case 23:
- ret_color = Color.Purple;
- break;
- case 24:
- ret_color = Color.Red;
- break;
- case 25:
- ret_color = Color.RosyBrown;
- break;
- case 26:
- ret_color = Color.RoyalBlue;
- break;
- case 27:
- ret_color = Color.SaddleBrown;
- break;
- case 28:
- ret_color = Color.SeaGreen;
- break;
- case 29:
- ret_color = Color.Teal;
- break;
- case 30:
- ret_color = Color.Tomato;
- break;
- case 31:
- ret_color = Color.YellowGreen;
- break;
- default:
- ret_color = Color.Black;
- break;
- }
- return ret_color;
- }
- /// <summary>
- /// 打开报表模板进程
- /// </summary>
- private void OpenOTSINcAreportTemplateAPP()
- {
- //----------------------------------
- //共传4个参数
- //参数1:是需要打开db数据库的路径
- //参数2:是打开报表模板xml文件的路径
- //参数3:是要执行查看报表的类型,输出主报表,还是输出颗粒列表
- //参数4:打开主报表时是是指定夹杂物的数量,打开颗粒列表时,是颗粒列表显示的范围如,0-50,50-100
- //参数5:是要执行查看报表的类型,输出主报表时,指定读取的标记帧图图像范围,如0-50,50-100,输出颗粒列表时无用
- //----------------------------------
- //Process[] processes = Process.GetProcesses();
- //foreach (Process proc in processes)
- //{
- // if (proc.ProcessName == "OTSIncAReportTemplate")
- // {
- // proc.Kill();-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- // proc.WaitForExit();
- // break;
- // }
- //}
- ProcessStartInfo process = new ProcessStartInfo();
- process.FileName = "ReportTemplateExe\\OTSIncAReportTemplate.exe";//打开app的路径
- string arg1 = m_strDBpath.Replace(" ", "^");//参数1,是需要打开db数据库的路径
- string arg2 = tb_mblj.Text.Trim().Replace(" ", "^");//参数2,是模板文件的路径
- string arg3 = "MainReport";//主体报表
- string arg4 = "100";//夹杂物数量
- string arg5 = "0-100";//打开的标记帧图图像数量
- process.Arguments = string.Format("{0} {1} {2} {3} {4}", arg1, arg2, arg3, arg4, arg5); //多个参数用空格隔开
- process.WindowStyle = ProcessWindowStyle.Normal;
- Process.Start(process);
- }
- /// <summary>
- /// 打开报表模板进程,颗粒列表
- /// </summary>
- public void OpenOTSINcAreportTemplateAPP_ParticleList(string arg4)
- {
- //----------------------------------
- //共传4个参数
- //参数1:是需要打开db数据库的路径
- //参数2:是打开报表模板xml文件的路径
- //参数3:是要执行查看报表的类型,输出主报表,还是输出颗粒列表
- //参数4:打开主报表时是是指定夹杂物的数量,打开颗粒列表时,是颗粒列表显示的范围如,0-50,50-100
- //参数5:是要执行查看报表的类型,输出主报表时,指定读取的标记帧图图像范围,如0-50,50-100,输出颗粒列表时无用
- //----------------------------------
- ProcessStartInfo process = new ProcessStartInfo();
- process.FileName = "ReportTemplateExe\\OTSIncAReportTemplate.exe";//打开app的路径
- string arg1 = m_strDBpath_ParticleList.Replace(" ", "^");//参数1,是需要打开db数据库的路径
- string arg2 = tb_mblj.Text.Trim().Replace(" ", "^");//参数2,是模板文件的路径
- string arg3 = "ParticleListReport";//颗粒列表
- //string arg4 = "";//夹杂物数量,从多少到多少
- string arg5 = "0";//在打开颗粒列表时,传的标记帧图图像数量参数暂不用
- process.Arguments = string.Format("{0} {1} {2} {3} {4}", arg1, arg2, arg3, arg4, arg5); //多个参数用空格隔开
- process.WindowStyle = ProcessWindowStyle.Normal;
- Process.Start(process);
- }
- #endregion
- #region 窗体控件事件
- private void OTSReport_Export_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (backgroundWorker2.IsBusy == true)
- {
- //导出线程正在工作中,不让退出该界面
- MessageBox.Show(table["messagebox1"].ToString(), table["messagebox2"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Information);
- //然后取消关闭窗体的事件
- e.Cancel = true;
- }
- }
-
- private void btn_preview_Click(object sender, EventArgs e)
- {
- //为防止重复打开报告后,显示数据库占用错误,先确保报告模板进程已关闭
- Process[] processes = Process.GetProcesses();
- foreach (Process proc in processes)
- {
- if (proc.ProcessName == "OTSIncAReportTemplate")
- {
- DialogResult dr = MessageBox.Show(table["messagebox3"].ToString(), table["messagebox4"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
- if (dr == DialogResult.OK)
- {
- return;
- }
- }
- }
- //调用模板设计器,预览
- //判断该测量结果文件目录中是否已经有数据库文件,有的话,直接打开,没有则进行导出数据库然后再打开
- if (File.Exists(m_strDBpath))
- {
- DialogResult dr = MessageBox.Show(table["messagebox5"].ToString(), table["messagebox6"].ToString(), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.Yes)
- {
- WriteRictBox(table["messagebox7"].ToString());
- //存在则直接打开报表
- OpenOTSINcAreportTemplateAPP();
- return;
- }
- if (dr == DialogResult.No)
- {
- //GoTo Here;
- //不干预,跳转到下面执行导出操作
- }
- if (dr == DialogResult.Cancel)
- {
- //取消,返回
- return;
- }
- }
- //重新导出报表数据
- m_ReportApp.m_ChartsWindow.Activate();
- WriteRictBox(table["rictbox1"].ToString());
- progressBar1.Value = 0;
- //预览
- if (backgroundWorker2.IsBusy != true)
- {
- // 启动异步操作
- backgroundWorker2.RunWorkerAsync();
- }
- }
- private void button3_Click(object sender, EventArgs e)
- {
- if (File.Exists(tb_lj.Text.Trim()))
- {
- //打开刚才导出的文件
- System.Diagnostics.Process.Start(tb_lj.Text.Trim());
- }
- else
- {
- WriteRictBox(table["rictbox2"].ToString() + tb_lj.Text.Trim() + table["rictbox3"].ToString());
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- //退出
- this.Close();
- }
- private void btn_openfilepath_Click(object sender, EventArgs e)
- {
- LoadControlsToXml();
- SaveMBSClass();
- }
- private void btn_selectPath_Click(object sender, EventArgs e)
- {
- //选择保存文件路径对话框
- SaveFileDialog saveFileDialog1 = new SaveFileDialog();
- //获取默认操作的数据源名,用来当做保存的文件名
- saveFileDialog1.FileName = m_ReportApp.m_rstDataMgr.GetSampleName();
- saveFileDialog1.Filter = "Excel (*.xls)|*.xls|Word (*.doc)|*.doc|PDF (*.pdf)|*.pdf";
- saveFileDialog1.FilterIndex = 1;
- saveFileDialog1.RestoreDirectory = true;
- if (saveFileDialog1.ShowDialog() == DialogResult.OK)
- {
- if (saveFileDialog1.FilterIndex == 1)
- {
- //选择输出Excel
- m_export_type = "Excel";
- }
- if (saveFileDialog1.FilterIndex == 2)
- {
- //选择输出Word
- m_export_type = "Word";
- }
- if (saveFileDialog1.FilterIndex == 3)
- {
- //选择输出PDF
- m_export_type = "PDF";
- }
- tb_lj.Text = saveFileDialog1.FileName;
- }
- }
- //调用编辑模板窗体
- private void btn_TempDes_Click(object sender, EventArgs e)
- {
- //预览设置
- OTSReport_TemplateDesignerRM OtsTemDRM = new OTSReport_TemplateDesignerRM(this);
- if (OtsTemDRM.ShowDialog() == DialogResult.Yes)
- {
- //如果用户点击确定,则将m_mbszclass,模板设置类的内容存到文件中。
- // m_mbszclass.M_DZ.route = tb_mblj.Text;
- m_mbszclass.M_DZ.route = tb_mblj.Text;
- SaveMBSClass();
- }
- }
- #endregion
-
- #region 将报表数据保存到数据库中
- /// <summary>
- /// 将报表数据保存到数据库中
- /// </summary>
- private void SaveReportTemplateDBFile()
- {
- File.Delete(m_strDBpath);//测试时删除数据库文件,为防止第二次打开报告提示数据库占用,挪到方法开始处
- SqlHelper.CreateNewDatabase(m_strDBpath);
- SqlHelper sh = new SqlHelper("data source='" + m_strDBpath + "'");
- //开始事务
- SQLiteTransaction tr = sh.BeginTranscation();
- //数据库过程
- try
- {
- //创建表 ResultGrid
- string[] strcolumns_ResultGrid = { "CLJGMC", "YXSJ", "SCZS", "FLFA", "YJCTZ", "SCMJ", "CKBZ" };
- string[] strcoltypes_ResultGrid = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("ResultGrid", strcolumns_ResultGrid, strcoltypes_ResultGrid);
- //创建表 Largest_frame
- string[] strcolumns_Largest_frame = { "pid", "Size", "Width", "Class", "ColName1", "ColName2", "ColName3", "ColName4", "ColName5", "ColName6",
- "ColVal1", "ColVal2", "ColVal3", "ColVal4", "ColVal5", "ColVal6" ,"FieldId","p1"};
- string[] strcoltypes_Largest_frame = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" ,
- "INT","BLOB"};
- sh.CreateTable("Largest_frame", strcolumns_Largest_frame, strcoltypes_Largest_frame);
- //创建表 Largest20
- string[] strcolumns_Largest20 = { "pid", "Size", "Width", "Class", "ColName1", "ColName2", "ColName3", "ColName4", "ColName5", "ColName6",
- "ColVal1", "ColVal2", "ColVal3", "ColVal4", "ColVal5", "ColVal6" ,"p1" ,"p2" ,"p3"};
- string[] strcoltypes_Largest20 = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" ,
- "BLOB","BLOB","BLOB"};
- sh.CreateTable("Largest20", strcolumns_Largest20, strcoltypes_Largest20);
- //创建表 Largest2new
- string[] strcolumns_Largest2new = { "pid", "Size", "Width", "Class", "ColName1", "ColName2", "ColName3", "ColName4", "ColName5", "ColName6",
- "ColVal1", "ColVal2", "ColVal3", "ColVal4", "ColVal5", "ColVal6" ,"p1"};
- string[] strcoltypes_Largest2new = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" ,
- "BLOB"};
- sh.CreateTable("Largest2new", strcolumns_Largest2new, strcoltypes_Largest2new);
- //创建表 field_dt
- string[] strcolumns_field_dt = { "FieldId", "FieldImg" };
- string[] strcoltypes_field_dt = { "INT", "BLOB" };
- sh.CreateTable("field_dt", strcolumns_field_dt, strcoltypes_field_dt);
- //创建表 ElementName
- string[] strcolumns_ElementName = { "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9","e10","e11","e12","e13","e14" };
- string[] strcoltypes_ElementName = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("ElementName", strcolumns_ElementName, strcoltypes_ElementName);
- //创建表 ElementValue
- string[] strcolumns_ElementValue = { "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9","e10","e11","e12","e13","e14", "PName", "Count" , "AllElements" };
- string[] strcoltypes_ElementValue = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("ElementValue", strcolumns_ElementValue, strcoltypes_ElementValue);
- //创建表 PartSize
- string[] strcolumns_PartSize = { "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9" };
- string[] strcoltypes_PartSize = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("PartSize", strcolumns_PartSize, strcoltypes_PartSize);
- //创建表 Particel
- string[] strcolumns_Particel = { "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "SName", "total" };
- string[] strcoltypes_Particel = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("Particel", strcolumns_Particel, strcoltypes_Particel);
- //创建表 PicKL
- string[] strcolumns_PicKL = { "pict" };
- string[] strcoltypes_PicKL = { "BLOB" };
- sh.CreateTable("PicKL", strcolumns_PicKL, strcoltypes_PicKL);
- //创建表 夹杂物面积比
- string[] strcolumns_PicInclusionAreaRatio = { "pict" };
- string[] strcoltypes_PicInclusionAreaRatio = { "BLOB" };
- sh.CreateTable("PicInclusionAreaRatio", strcolumns_PicKL, strcoltypes_PicKL);
- //创建表 PicYS
- string[] strcolumns_PicYS = { "pict" };
- string[] strcoltypes_PicYS = { "BLOB" };
- sh.CreateTable("PicYS", strcolumns_PicYS, strcoltypes_PicYS);
- //创建表 PicSYXT2T
- string[] strcolumns_PicSYXT2T = { "pict", "pict2" };
- string[] strcoltypes_PicSYXT2T = { "BLOB", "BLOB" };
- sh.CreateTable("PicSYXT2T", strcolumns_PicSYXT2T, strcoltypes_PicSYXT2T);
- //创建表 PicSYXT3T
- string[] strcolumns_PicSYXT3T = { "pict", "pict2", "pict3" };
- string[] strcoltypes_PicSYXT3T = { "BLOB", "BLOB", "BLOB" };
- sh.CreateTable("PicSYXT3T", strcolumns_PicSYXT3T, strcoltypes_PicSYXT3T);
- //创建 颗粒面积比表
- string[] strcolums_AreaRatio = { "c1", "c2", "c3", "c4", "c5" };
- string[] strcoltypes_AreaRatio = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("AreaRatio", strcolums_AreaRatio, strcoltypes_AreaRatio);
- //将数据插入到数据库中
- List<DataTable> list_dt = m_export_reporttemplate.m_list_dt;
- DataTable ls_AreaRatio = list_dt.Where(aa => aa.TableName.Contains("InclusionAreaRatio")).ToList()[0];
- for (int i = 0; i < ls_AreaRatio.Rows.Count; i++)
- {
- string ls_sqlstr = "insert into AreaRatio (c1, c2, c3, c4, c5) values('"
- + ls_AreaRatio.Rows[i][0].ToString() + "','"
- + ls_AreaRatio.Rows[i][1].ToString() + "','"
- + ls_AreaRatio.Rows[i][2].ToString() + "','"
- + ls_AreaRatio.Rows[i][3].ToString() + "','"
- + ls_AreaRatio.Rows[i][4].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- DataTable ls_resultgrid = list_dt.Where(aa => aa.TableName.Contains("ResultGrid")).ToList()[0];
- for (int i = 0; i < ls_resultgrid.Rows.Count; i++)
- {
- string ls_sqlstr = "insert into ResultGrid (CLJGMC, YXSJ, SCZS, FLFA, YJCTZ, SCMJ, CKBZ) values('"
- + ls_resultgrid.Rows[i][0].ToString() + "','"
- + ls_resultgrid.Rows[i][1].ToString() + "','"
- + ls_resultgrid.Rows[i][2].ToString() + "','"
- + ls_resultgrid.Rows[i][3].ToString() + "','"
- + ls_resultgrid.Rows[i][4].ToString() + "','"
- + ls_resultgrid.Rows[i][5].ToString() + "','"
- + ls_resultgrid.Rows[i][6].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 Largest_frame
- DataTable ls_Largest_frame = list_dt.Where(aa => aa.TableName.Contains("Largest_frame")).ToList()[0];
- for (int i = 0; i < ls_Largest_frame.Rows.Count; i++)
- {
- if (ls_Largest_frame.Rows[i][17] == null)
- {
- continue;
- }
- if (ls_Largest_frame.Rows[i][17] == DBNull.Value)
- {
- continue;
- }
- 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('"
- + ls_Largest_frame.Rows[i][0].ToString() + "','"
- + ls_Largest_frame.Rows[i][1].ToString() + "','"
- + ls_Largest_frame.Rows[i][2].ToString() + "','"
- + ls_Largest_frame.Rows[i][3].ToString() + "','"
- + ls_Largest_frame.Rows[i][4].ToString() + "','"
- + ls_Largest_frame.Rows[i][5].ToString() + "','"
- + ls_Largest_frame.Rows[i][6].ToString() + "','"
- + ls_Largest_frame.Rows[i][7].ToString() + "','"
- + ls_Largest_frame.Rows[i][8].ToString() + "','"
- + ls_Largest_frame.Rows[i][9].ToString() + "','"
- + ls_Largest_frame.Rows[i][10].ToString() + "','"
- + ls_Largest_frame.Rows[i][11].ToString() + "','"
- + ls_Largest_frame.Rows[i][12].ToString() + "','"
- + ls_Largest_frame.Rows[i][13].ToString() + "','"
- + ls_Largest_frame.Rows[i][14].ToString() + "','"
- + ls_Largest_frame.Rows[i][15].ToString() + "',"
- + ls_Largest_frame.Rows[i][16].ToString() + ",:p1)";
- byte[] byte_p1 = (byte[])ls_Largest_frame.Rows[i][17];
- int iresult = sh.ExecuteQuery(ls_sqlstr, "p1", byte_p1, tr);
- }
- //插入 Largest20
- DataTable ls_Largest20 = list_dt.Where(aa => aa.TableName.Contains("Largest20")).ToList()[0];
- for (int i = 0; i < ls_Largest20.Rows.Count; i++)
- {
- if (ls_Largest20.Rows[i][16] == null)
- {
- continue;
- }
- if (ls_Largest20.Rows[i][16] == DBNull.Value)
- {
- continue;
- }
- 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('"
- + ls_Largest20.Rows[i][0].ToString() + "','"
- + ls_Largest20.Rows[i][1].ToString() + "','"
- + ls_Largest20.Rows[i][2].ToString() + "','"
- + ls_Largest20.Rows[i][3].ToString() + "','"
- + ls_Largest20.Rows[i][4].ToString() + "','"
- + ls_Largest20.Rows[i][5].ToString() + "','"
- + ls_Largest20.Rows[i][6].ToString() + "','"
- + ls_Largest20.Rows[i][7].ToString() + "','"
- + ls_Largest20.Rows[i][8].ToString() + "','"
- + ls_Largest20.Rows[i][9].ToString() + "','"
- + ls_Largest20.Rows[i][10].ToString() + "','"
- + ls_Largest20.Rows[i][11].ToString() + "','"
- + ls_Largest20.Rows[i][12].ToString() + "','"
- + ls_Largest20.Rows[i][13].ToString() + "','"
- + ls_Largest20.Rows[i][14].ToString() + "','"
- + ls_Largest20.Rows[i][15].ToString() + "',:p1,:p2,:p3)";
- byte[] byte_p1 = (byte[])ls_Largest20.Rows[i][16];
- byte[] byte_p2 = (byte[])ls_Largest20.Rows[i][17];
- byte[] byte_p3 = (byte[])ls_Largest20.Rows[i][18];
- int iresult = sh.ExecuteQuery(ls_sqlstr, "p1", byte_p1, "p2", byte_p2, "p3", byte_p3, tr);
- }
- //-----------------------------------------------------------------------------------------------------------------------------------
- ////插入标记帧部份,进行特殊处理,从硬盘中拿现已经生成好的标记图像,进行加载,然后转成byte数组,存入到数据库中 ////准备存放标记图的文件夹
- string m_strFieldPath_Mark = m_ReportApp.m_rstDataMgr.ResultFilesList[m_ReportApp.m_rstDataMgr.GetWorkingResult()].FilePath + "\\FIELD_FILES_MARK\\";
- //插入 field_dt
- DataTable ls_field_dt = list_dt.Where(aa => aa.TableName.Contains("field_dt")).ToList()[0];
- for (int i = 0; i < ls_field_dt.Rows.Count; i++)
- {
- string ls_sqlstr = "insert into field_dt (FieldId,FieldImg) values(" + ls_field_dt.Rows[i]["FieldId"] + ",:pict)";
- string str_fieldid = ls_field_dt.Rows[i][0].ToString();
- //从生成的FIELD_FIES_MARK文件夹中加载图像并转成byte数组,保存到数据库,节省内存
- Bitmap ls_bp_mark = new Bitmap(m_strFieldPath_Mark + str_fieldid + ".bmp");
- MemoryStream newms_fieldmark = new MemoryStream();
- ls_bp_mark.Save(newms_fieldmark, System.Drawing.Imaging.ImageFormat.Bmp);
- newms_fieldmark.Seek(0, SeekOrigin.Begin);
- byte[] newarr_field_mrak = new byte[newms_fieldmark.Length];
- newms_fieldmark.Read(newarr_field_mrak, 0, newarr_field_mrak.Length);
- int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", newarr_field_mrak, tr);
- newms_fieldmark.Dispose();
- newms_fieldmark = null;
- ls_bp_mark.Dispose();
- ls_bp_mark = null;
- GC.Collect();
- GC.WaitForPendingFinalizers();
- }
- //-----------------------------------------------------------------------------------------------------------------
- //插入 ElementName
- DataTable ls_ElementName = list_dt.Where(aa => aa.TableName.Contains("ElementName")).ToList()[0];
- for (int i = 0; i < ls_ElementName.Rows.Count; i++)
- {
- string ls_sqlstr = "insert into ElementName (e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14 ) values('"
- + ls_ElementName.Rows[i][0].ToString() + "','"
- + ls_ElementName.Rows[i][1].ToString() + "','"
- + ls_ElementName.Rows[i][2].ToString() + "','"
- + ls_ElementName.Rows[i][3].ToString() + "','"
- + ls_ElementName.Rows[i][4].ToString() + "','"
- + ls_ElementName.Rows[i][5].ToString() + "','"
- + ls_ElementName.Rows[i][6].ToString() + "','"
- + ls_ElementName.Rows[i][7].ToString() + "','"
- + ls_ElementName.Rows[i][8].ToString() + "','"
- + ls_ElementName.Rows[i][9].ToString() + "','"
- + ls_ElementName.Rows[i][10].ToString() + "','"
- + ls_ElementName.Rows[i][11].ToString() + "','"
- + ls_ElementName.Rows[i][12].ToString() + "','"
- + ls_ElementName.Rows[i][13].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 ElementValue
- DataTable ls_ElementValue = list_dt.Where(aa => aa.TableName.Contains("ElementValue")).ToList()[0];
- for (int i = 0; i < ls_ElementValue.Rows.Count; i++)
- {
- string ls_sqlstr = "insert into ElementValue (e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14,PName,Count,AllElements ) values('"
- + ls_ElementValue.Rows[i][0].ToString() + "','"
- + ls_ElementValue.Rows[i][1].ToString() + "','"
- + ls_ElementValue.Rows[i][2].ToString() + "','"
- + ls_ElementValue.Rows[i][3].ToString() + "','"
- + ls_ElementValue.Rows[i][4].ToString() + "','"
- + ls_ElementValue.Rows[i][5].ToString() + "','"
- + ls_ElementValue.Rows[i][6].ToString() + "','"
- + ls_ElementValue.Rows[i][7].ToString() + "','"
- + ls_ElementValue.Rows[i][8].ToString() + "','"
- + ls_ElementValue.Rows[i][9].ToString() + "','"
- + ls_ElementValue.Rows[i][10].ToString() + "','"
- + ls_ElementValue.Rows[i][11].ToString() + "','"
- + ls_ElementValue.Rows[i][12].ToString() + "','"
- + ls_ElementValue.Rows[i][13].ToString() + "','"
- + ls_ElementValue.Rows[i][14].ToString() + "','"
- + ls_ElementValue.Rows[i][15].ToString() + "','"
- + ls_ElementValue.Rows[i][16].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 PartSize
- DataTable ls_PartSize = list_dt.Where(aa => aa.TableName.Contains("PartSize")).ToList()[0];
- for (int i = 0; i < ls_PartSize.Rows.Count; i++)
- {
- string ls_sqlstr = "insert into PartSize (c1, c2, c3, c4, c5, c6, c7, c8, c9 ) values('"
- + ls_PartSize.Rows[i][0].ToString() + "','"
- + ls_PartSize.Rows[i][1].ToString() + "','"
- + ls_PartSize.Rows[i][2].ToString() + "','"
- + ls_PartSize.Rows[i][3].ToString() + "','"
- + ls_PartSize.Rows[i][4].ToString() + "','"
- + ls_PartSize.Rows[i][5].ToString() + "','"
- + ls_PartSize.Rows[i][6].ToString() + "','"
- + ls_PartSize.Rows[i][7].ToString() + "','"
- + ls_PartSize.Rows[i][8].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 Particel
- DataTable ls_Particel = list_dt.Where(aa => aa.TableName.Contains("Particel")).ToList()[0];
- for (int i = 0; i < ls_Particel.Rows.Count; i++)
- {
- string ls_sqlstr = "insert into Particel (c1, c2, c3, c4, c5, c6, c7, c8, c9,SName,total ) values('"
- + ls_Particel.Rows[i][0].ToString() + "','"
- + ls_Particel.Rows[i][1].ToString() + "','"
- + ls_Particel.Rows[i][2].ToString() + "','"
- + ls_Particel.Rows[i][3].ToString() + "','"
- + ls_Particel.Rows[i][4].ToString() + "','"
- + ls_Particel.Rows[i][5].ToString() + "','"
- + ls_Particel.Rows[i][6].ToString() + "','"
- + ls_Particel.Rows[i][7].ToString() + "','"
- + ls_Particel.Rows[i][8].ToString() + "','"
- + ls_Particel.Rows[i][9].ToString() + "','"
- + ls_Particel.Rows[i][10].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 PicKL
- DataTable ls_PicKL = list_dt.Where(aa => aa.TableName.Contains("PicKL")).ToList()[0];
- for (int i = 0; i < ls_PicKL.Rows.Count; i++)
- {
- if (ls_PicKL.Rows[i][0] == null)
- {
- continue;
- }
- if (ls_PicKL.Rows[i][0] == DBNull.Value)
- {
- continue;
- }
- string ls_sqlstr = "insert into PicKL (pict) values(:pict)";
- byte[] byte_p1 = (byte[])ls_PicKL.Rows[i][0];
- int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", byte_p1, tr);
- }
- //插入 Pic_InclusionAreaRatio
- DataTable ls_PicInclusionAreaRatio = list_dt.Where(aa => aa.TableName.Contains("Pic_InclusionAreaRatio")).ToList()[0];
- for (int i = 0; i < ls_PicInclusionAreaRatio.Rows.Count; i++)
- {
- if (ls_PicInclusionAreaRatio.Rows[i][0] == null)
- {
- continue;
- }
- if (ls_PicInclusionAreaRatio.Rows[i][0] == DBNull.Value)
- {
- continue;
- }
- string ls_sqlstr = "insert into PicInclusionAreaRatio (pict) values(:pict)";
- byte[] byte_p1 = (byte[])ls_PicInclusionAreaRatio.Rows[i][0];
- int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", byte_p1, tr);
- }
- //插入 PicYS
- DataTable ls_PicYS = list_dt.Where(aa => aa.TableName.Contains("PicYS")).ToList()[0];
- for (int i = 0; i < ls_PicYS.Rows.Count; i++)
- {
- if (ls_PicYS.Rows[i][0] == null)
- {
- continue;
- }
- if (ls_PicYS.Rows[i][0] == DBNull.Value)
- {
- continue;
- }
- string ls_sqlstr = "insert into PicYS (pict) values(:pict)";
- byte[] byte_p1 = (byte[])ls_PicYS.Rows[i][0];
- int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", byte_p1, tr);
- }
- //插入 PicSYXT2T
- DataTable ls_PicSYXT2T = list_dt.Where(aa => aa.TableName.Contains("PicSYXT2T")).ToList()[0];
- for (int i = 0; i < ls_PicSYXT2T.Rows.Count; i++)
- {
- if (ls_PicSYXT2T.Rows[i][0] == null)
- {
- continue;
- }
- if (ls_PicSYXT2T.Rows[i][0] == DBNull.Value)
- {
- continue;
- }
- string ls_sqlstr = "insert into PicSYXT2T (pict,pict2) values(:pict,:pict2)";
- byte[] byte_p1 = (byte[])ls_PicSYXT2T.Rows[i][0];
- byte[] byte_p2 = (byte[])ls_PicSYXT2T.Rows[i][1];
- int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", byte_p1, "pict2", byte_p2, tr);
- }
- //插入 PicSYXT3T
- DataTable ls_PicSYXT3T = list_dt.Where(aa => aa.TableName.Contains("PicSYXT3T")).ToList()[0];
- for (int i = 0; i < ls_PicSYXT3T.Rows.Count; i++)
- {
- if (ls_PicSYXT3T.Rows[i][0] == null)
- {
- continue;
- }
- if (ls_PicSYXT3T.Rows[i][0] == DBNull.Value)
- {
- continue;
- }
- string ls_sqlstr = "insert into PicSYXT3T (pict,pict2,pict3) values(:pict,:pict2,:pict3)";
- byte[] byte_p1 = (byte[])ls_PicSYXT3T.Rows[i][0];
- byte[] byte_p2 = (byte[])ls_PicSYXT3T.Rows[i][1];
- byte[] byte_p3 = (byte[])ls_PicSYXT3T.Rows[i][2];
- int iresult = sh.ExecuteQuery(ls_sqlstr, "pict", byte_p1, "pict2", byte_p2, "pict3", byte_p3, tr);
- }
- //事务提交
- sh.TranscationCommit(tr);
- }
- catch (Exception ee)
- {
- //回滚
- sh.TranscationRollback(tr);
- }
- finally
- {
- //最后关闭连接
- tr.Dispose();
- tr = null;
- sh.CloseConnection();
- }
- }
- #endregion
- #region 导出工作线程部份
- private void backgroundWorker2_DoWork(object sender, DoWorkEventArgs e)
- {
- BackgroundWorker worker = sender as BackgroundWorker;
- //主任务的实现
- #region //获取模板设置的导出的内容-------------------------------------------------
- //获取报告模板设置内容
- worker.ReportProgress(0, table["rictbox4"].ToString());
- System.Threading.Thread.Sleep(1);
- //更新进度
- worker.ReportProgress(5);
- #endregion //设置模板导出内容结束--------------------------------------------------------
- int processvalue = 12;//各功能模块从进度条为15时开始依次调用
- #region //依次循环调用各功能模块-------------------------------------------------------------
- int i_zz = 0;//增值
- i_zz = 80 / 9;
- //首先将测量结果信息表导出,在表头------------------------------------------------
- worker.ReportProgress(0, table["rictbox5"].ToString());
- worker.ReportProgress(0, table["rictbox6"].ToString());
- //更新进度条
- processvalue = processvalue + 1;
- worker.ReportProgress(processvalue);
- lock (m_thread_flag)
- m_thread_flag = table["rictbox7"].ToString();
- while (m_thread_flag == table["rictbox7"].ToString())
- {
- System.Threading.Thread.Sleep(500);
- }
- worker.ReportProgress(0, table["rictbox8"].ToString());
- //-------------------------------------------------------------------------
- //调用输出,颗粒列表----------------------------------------
- worker.ReportProgress(0, table["rictbox9"].ToString());
- worker.ReportProgress(0, table["rictbox10"].ToString());
- //更新进度条
- processvalue = processvalue + i_zz;
- worker.ReportProgress(processvalue);
- lock (m_thread_flag)
- m_thread_flag = table["rictbox7"].ToString();
- while (m_thread_flag == table["rictbox7"].ToString())
- {
- System.Threading.Thread.Sleep(500);
- }
- worker.ReportProgress(0, table["rictbox14"].ToString());
- //调用输出,平均元素含量表---------------------------------------
- worker.ReportProgress(0, table["rictbox15"].ToString());
- worker.ReportProgress(0, table["rictbox16"].ToString());
- //更新进度条
- processvalue = processvalue + i_zz;
- worker.ReportProgress(processvalue);
- lock (m_thread_flag)
- m_thread_flag = table["rictbox7"].ToString();
- while (m_thread_flag == table["rictbox7"].ToString())
- {
- System.Threading.Thread.Sleep(500);
- }
- worker.ReportProgress(0, table["rictbox17"].ToString());
- //调用输出,颗粒尺寸表--------------------------------------
- worker.ReportProgress(0, table["rictbox19"].ToString());
- worker.ReportProgress(0, table["rictbox20"].ToString());
- //更新进度条
- processvalue = processvalue + i_zz;
- worker.ReportProgress(processvalue);
- lock (m_thread_flag)
- m_thread_flag = table["rictbox7"].ToString();
- while (m_thread_flag == table["rictbox7"].ToString())
- {
- System.Threading.Thread.Sleep(500);
- }
- worker.ReportProgress(0, table["rictbox21"].ToString());
- //调用,颗粒成份图------------------------------------------------
- worker.ReportProgress(0, table["rictbox23"].ToString());
- worker.ReportProgress(0, table["rictbox24"].ToString());
- //更新进度条
- processvalue = processvalue + i_zz;
- worker.ReportProgress(processvalue);
- lock (m_thread_flag)
- m_thread_flag = table["rictbox7"].ToString();
- while (m_thread_flag == table["rictbox7"].ToString())
- {
- System.Threading.Thread.Sleep(500);
- }
- worker.ReportProgress(0, table["rictbox25"].ToString());
- //调用,元素成份图---------------------------------------------
- worker.ReportProgress(0, table["rictbox27"].ToString());
- worker.ReportProgress(0, table["rictbox28"].ToString());
- //更新进度条
- processvalue = processvalue + i_zz;
- worker.ReportProgress(processvalue);
- lock (m_thread_flag)
- m_thread_flag = table["rictbox7"].ToString();
- while (m_thread_flag == table["rictbox7"].ToString())
- {
- System.Threading.Thread.Sleep(500);
- }
- worker.ReportProgress(0, table["rictbox29"].ToString());
- //调用,三元相图----------------------------------------------
- worker.ReportProgress(0, table["rictbox31"].ToString());
- worker.ReportProgress(0, table["rictbox32"].ToString());
- //更新进度条
- processvalue = processvalue + i_zz;
- worker.ReportProgress(processvalue);
- lock (m_thread_flag)
- m_thread_flag = table["rictbox7"].ToString();
- while (m_thread_flag == table["rictbox7"].ToString())
- {
- System.Threading.Thread.Sleep(500);
- }
- worker.ReportProgress(0, table["rictbox33"].ToString());
- //生成,模板临时数据库文件----------------------------------------------
- worker.ReportProgress(0, table["rictbox35"].ToString());
- worker.ReportProgress(0, table["rictbox36"].ToString());
- //更新进度条
- processvalue = processvalue + i_zz;
- worker.ReportProgress(processvalue);
- lock (m_thread_flag)
- m_thread_flag = table["rictbox7"].ToString();
- while (m_thread_flag == table["rictbox7"].ToString())
- {
- System.Threading.Thread.Sleep(500);
- }
- worker.ReportProgress(0, table["rictbox37"].ToString());
- #endregion 依将循环调用各功能模块结束-------------------------------------------------------
- }
- private string AnalyticGraphics(int a_Indexes)
- {
- if (a_Indexes == 0)
- return "pie";//饼图
- else if (a_Indexes == 1)
- return "radius";//圈图
- else if (a_Indexes == 2)
- return "bar";//柱状图
- else if (a_Indexes == 3)
- return "line";//线状图
- else return "stack";//堆叠图
- }
- private void backgroundWorker2_ProgressChanged(object sender, ProgressChangedEventArgs e)
- {
- string strNill = table["rictbox40"].ToString();
- BackgroundWorker worker = sender as BackgroundWorker;
-
- //更新进度条的进度
- if (e.UserState != null)
- {
- string ls_str = (string)e.UserState;
- WriteRictBox((string)e.UserState);
-
- string s= AnalyticGraphics(m_mbszclass.M_KLFXJG.index_cb_jzwfl_xstx);
- if (ls_str.IndexOf(table["rictbox12"].ToString()) > -1)
- {
- if (ls_str.IndexOf(table["rictbox11"].ToString()) > -1)
- {
- m_export_reporttemplate.InsertReportTemplateTable_ResultGrid();
- lock (m_thread_flag)
- m_thread_flag = strNill;
- }
- if (ls_str.IndexOf(table["rictbox13"].ToString()) > -1)
- {
- m_export_reporttemplate.InsertReportTemplateTable_ParticlesGridDevidePage();
- lock (m_thread_flag)
- m_thread_flag = strNill;
- }
- if (ls_str.IndexOf(table["rictbox18"].ToString()) > -1)
- {
- m_export_reporttemplate.InsertReportTemplateTable_ElementCompositionAvgGrid();
- m_export_reporttemplate.InsertReportTemplateChart_InclusionAreaRatio("pie");
- lock (m_thread_flag)
- m_thread_flag = strNill;
- }
- if (ls_str.IndexOf(table["rictbox22"].ToString()) > -1)
- {
- m_export_reporttemplate.InsertReportTemplateTable_ParticleSizeGrid();
- lock (m_thread_flag)
- m_thread_flag = strNill;
- }
- if (ls_str.IndexOf(table["rictbox26"].ToString()) > -1)
- {
- m_export_reporttemplate.InsertReportTemplateChart_ParticlesCompositionChart(AnalyticGraphics(m_mbszclass.M_KLFXJG.index_cb_jzwfl_xstx));
- lock (m_thread_flag)
- m_thread_flag = strNill;
- }
- if (ls_str.IndexOf(table["rictbox30"].ToString()) > -1)
- {
- m_export_reporttemplate.InsertReportTemplateChart_ElementCompositionChart(AnalyticGraphics(m_mbszclass.M_YSFXJG.index_cb_yscf_xstx));
- lock (m_thread_flag)
- m_thread_flag = strNill;
- }
- if (ls_str.IndexOf(table["rictbox34"].ToString()) > -1)
- {
- m_export_reporttemplate.InsertReportTemplateChart_Trianglediagram();
- lock (m_thread_flag)
- m_thread_flag = strNill;
- }
- if (ls_str.IndexOf(table["rictbox38"].ToString()) > -1)
- {
- //导出到数据库文件中
- SaveReportTemplateDBFile();
- lock (m_thread_flag)
- m_thread_flag = strNill;
- }
- }
- }
- else
- {
- progressBar1.Value = e.ProgressPercentage;
- WriteRictBox(table["rictbox39"].ToString() + e.ProgressPercentage.ToString() + "%");
- }
- }
- private void backgroundWorker2_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
- {
- WriteRictBox(table["rictbox41"].ToString() + m_export_reporttemplate.m_list_dt.Count.ToString() + table["rictbox42"].ToString(), Color.Red);
- //处理结束后,再将button的状态更新回去
- progressBar1.Value = 100;
- WriteRictBox("-----------------"+ table["rictbox43"].ToString() + "--------------------", Color.Red);
- MemoryManagementClass.FlushMemory();
- //导出完成,打开报表
- OpenOTSINcAreportTemplateAPP();
- m_ReportApp.m_conditionChoose.ShowsTheDefaultPic();
- this.Close();
- }
- #endregion
- #region 读取文件
- private void LoadControlsToXml()
- {
- string path = string.Empty;
- OpenFileDialog Load = new OpenFileDialog();
- Load.Filter = "XML File|*.xml";
- Load.InitialDirectory = @System.Windows.Forms.Application.StartupPath + "\\Config\\ProData";
- if (Load.ShowDialog() == DialogResult.OK)
- path = Load.FileName;//赋值目录
- if (path != string.Empty)
- {
- tb_mblj.Text = path;
- m_mbszclass.M_DZ.route = path;
- OTSIncAReportApp.Controls.XmlConfigUtil xmlutil = new OTSIncAReportApp.Controls.XmlConfigUtil(path);
- //首页
- m_mbszclass.M_SY.str_tb_ZBT = xmlutil.Read("M_SY", "str_tb_ZBT");
- m_mbszclass.M_SY.str_tb_FBT = xmlutil.Read("M_SY", "str_tb_FBT");
- m_mbszclass.M_SY.str_tb_YPBH = xmlutil.Read("M_SY", "str_tb_YPBH");
- m_mbszclass.M_SY.str_tb_CKBZ = xmlutil.Read("M_SY", "str_tb_CKBZ");
- m_mbszclass.M_SY.b_ck_ypsm = Convert.ToBoolean(xmlutil.Read("M_SY", "b_ck_ypsm"));
- m_mbszclass.M_SY.b_ck_jggk = Convert.ToBoolean(xmlutil.Read("M_SY", "b_ck_jggk"));
- //页眉页脚
- m_mbszclass.M_YMYJ.str_tb_ymwb = xmlutil.Read("M_YMYJ", "str_tb_ymwb");
- m_mbszclass.M_YMYJ.str_tb_KHH = xmlutil.Read("M_YMYJ", "str_tb_KHH");
- m_mbszclass.M_YMYJ.b_ck_ym = Convert.ToBoolean(xmlutil.Read("M_YMYJ", "b_ck_ym"));
- m_mbszclass.M_YMYJ.str_tb_yjwb = xmlutil.Read("M_YMYJ", "str_tb_yjwb");
- //颗粒分析结果
- m_mbszclass.M_KLFXJG.b_ck_klcc_xsmk = Convert.ToBoolean(xmlutil.Read("M_KLFXJG", "b_ck_klcc_xsmk"));//是否显示模块
- m_mbszclass.M_KLFXJG.index_cb_klcc_jsfs = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_klcc_jsfs"));//计算方式
- m_mbszclass.M_KLFXJG.index_cb_klcc_ljb = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_klcc_ljb"));//粒级表
- m_mbszclass.M_KLFXJG.index_cb_klcc_klfw = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_klcc_klfw"));//颗粒范围
- m_mbszclass.M_KLFXJG.b_cb_jzwfl_xsmk = Convert.ToBoolean(xmlutil.Read("M_KLFXJG", "b_cb_jzwfl_xsmk"));//是否显示该模块
- m_mbszclass.M_KLFXJG.index_cb_jzwfl_xstx = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_jzwfl_xstx"));//选择图像
- m_mbszclass.M_KLFXJG.index_cb_jzwfl_jsfs = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_jzwfl_jsfs"));//计算方式
- m_mbszclass.M_KLFXJG.index_cb_jzwfl_ljb = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_jzwfl_ljb"));//粒级表
- m_mbszclass.M_KLFXJG.index_cb_jzwfl_klfw = Convert.ToInt32(xmlutil.Read("M_KLFXJG", "index_cb_jzwfl_klfw"));//颗粒范围
- //元素分析结果
- m_mbszclass.M_YSFXJG.b_ck_ysfx_xsmk = Convert.ToBoolean(xmlutil.Read("M_YSFXJG", "b_ck_ysfx_xsmk")); //是否显示模块
- m_mbszclass.M_YSFXJG.index_cb_yxfx_jsfs = Convert.ToInt32(xmlutil.Read("M_YSFXJG", "index_cb_yxfx_jsfs")); //计算方式
- m_mbszclass.M_YSFXJG.index_cb_ysfx_klfw = Convert.ToInt32(xmlutil.Read("M_YSFXJG", "index_cb_ysfx_klfw")); //颗粒范围
- m_mbszclass.M_YSFXJG.str_tb_ysfx_xsys = xmlutil.Read("M_YSFXJG", "str_tb_ysfx_xsys"); //显示元素
- m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys.Clear();
- for (int i = 0; i < 100; i++) //取得所有元素列表
- {
- string str = xmlutil.Read("M_YSFXJG", "list_str_tb_ysfx_xsys", "YS" + i.ToString());
- if (str == null)
- {
- break;
- }
- else
- {
- m_mbszclass.M_YSFXJG.list_str_tb_ysfx_xsys.Add(str);
- }
- }
- m_mbszclass.M_YSFXJG.b_ck_yscf_xsmk = Convert.ToBoolean(xmlutil.Read("M_YSFXJG", "b_ck_yscf_xsmk")); //是否显示模块
- m_mbszclass.M_YSFXJG.index_cb_yscf_xstx = Convert.ToInt32(xmlutil.Read("M_YSFXJG", "index_cb_yscf_xstx")); //显示图形
- m_mbszclass.M_YSFXJG.index_cb_yscf_jsfs = Convert.ToInt32(xmlutil.Read("M_YSFXJG", "index_cb_yscf_jsfs")); //计算方式
- m_mbszclass.M_YSFXJG.index_cb_yscf_klfw = Convert.ToInt32(xmlutil.Read("M_YSFXJG", "index_cb_yscf_klfw")); //颗粒范围
- m_mbszclass.M_YSFXJG.str_tb_yscf_ysxx = xmlutil.Read("M_YSFXJG", "str_tb_yscf_ysxx"); //显示元素
- m_mbszclass.M_YSFXJG.list_str_tb_yscf_ysxx.Clear();
- for (int i = 0; i < 100; i++) //取得所有元素列表
- {
- string str = xmlutil.Read("M_YSFXJG", "list_str_tb_yscf_ysxx", "YS" + i.ToString());
- if (str == null)
- {
- break;
- }
- else
- {
- m_mbszclass.M_YSFXJG.list_str_tb_yscf_ysxx.Add(str);
- }
- }
- //三元相图
- m_mbszclass.M_SYXT.b_ck_syxt_xsmk = Convert.ToBoolean(xmlutil.Read("M_SYXT", "b_ck_syxt_xsmk")); //是否显示模块
- m_mbszclass.M_SYXT.index_cb_syxt_jsfs = Convert.ToInt32(xmlutil.Read("M_SYXT", "index_cb_syxt_jsfs")); //计算方式
- m_mbszclass.M_SYXT.index_cb_syxt_klfw = Convert.ToInt32(xmlutil.Read("M_SYXT", "index_cb_syxt_klfw")); //颗粒范围
- m_mbszclass.M_SYXT.str_cb_syxt_mhxssl = xmlutil.Read("M_SYXT", "str_cb_syxt_mhxssl"); //每行显示数量
- m_mbszclass.M_SYXT.list_lbv_syxt_mblb.Clear();
- for (int i = 0; i < 100; i++) //取得所有模板列表
- {
- string str = xmlutil.Read("M_SYXT", "list_lbv_syxt_mblb", "MB" + i.ToString());
- if (str == null)
- {
- break;
- }
- else
- {
- m_mbszclass.M_SYXT.list_lbv_syxt_mblb.Add(str);
- }
- }
- m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Clear();
- for (int i = 0; i < 100; i++) //取得所有模板列表 索引
- {
- string str = xmlutil.Read("M_SYXT", "list_lbv_syxt_mblb_index", "MBIndex" + i.ToString());
- if (str == null)
- {
- break;
- }
- else
- {
- m_mbszclass.M_SYXT.list_lbv_syxt_mblb_index.Add(Convert.ToInt32(str));
- }
- }
- //颗粒列表信息
- m_mbszclass.M_KLLBXX.b_ck_kllb_xsmk = Convert.ToBoolean(xmlutil.Read("M_KLLBXX", "b_ck_kllb_xsmk")); //是否显示模块
- m_mbszclass.M_KLLBXX.index_cb_kllb_jsfs = Convert.ToInt32(xmlutil.Read("M_KLLBXX", "index_cb_kllb_jsfs")); //计算方式
- m_mbszclass.M_KLLBXX.index_cb_kllb_klfw = Convert.ToInt32(xmlutil.Read("M_KLLBXX", "index_cb_kllb_klfw")); //颗粒范围
- m_mbszclass.M_KLLBXX.int_tb_kllb_ylsx = Convert.ToInt32(xmlutil.Read("M_KLLBXX", "int_tb_kllb_ylsx")); //数量上限
- m_mbszclass.M_KLLBXX.str_tb_kllb_sxys = xmlutil.Read("M_KLLBXX", "str_tb_kllb_sxys"); //显示元素
- m_mbszclass.M_KLLBXX.list_str_tb_lllb_sxys.Clear();
- for (int i = 0; i < 100; i++) //取得所有元素列表
- {
- string str = xmlutil.Read("M_KLLBXX", "list_str_tb_lllb_sxys", "YS" + i.ToString());
- if (str == null)
- {
- break;
- }
- else
- {
- m_mbszclass.M_KLLBXX.list_str_tb_lllb_sxys.Add(str);
- }
- }
- m_mbszclass.M_KLLBXX.b_ck_kllb_ystx = Convert.ToBoolean(xmlutil.Read("M_KLLBXX", "b_ck_kllb_ystx")); //原始图像
- m_mbszclass.M_KLLBXX.b_ck_kllb_fdtx = Convert.ToBoolean(xmlutil.Read("M_KLLBXX", "b_ck_kllb_fdtx")); //放大图像
- m_mbszclass.M_KLLBXX.b_ck_kllb_npxx = Convert.ToBoolean(xmlutil.Read("M_KLLBXX", "b_ck_kllb_npxx")); //能谱图像
- }
- }
- #endregion
- private void button7_Click(object sender, EventArgs e)
- {
- //为防止重复打开报告后,显示数据库占用错误,先确保报告模板进程已关闭
- Process[] processes = Process.GetProcesses();
- foreach (Process proc in processes)
- {
- if (proc.ProcessName == "OTSIncAReportTemplate")
- {
- DialogResult dr = MessageBox.Show(table["rictbox44"].ToString(), table["rictbox45"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
- if (dr == DialogResult.OK)
- {
- return;
- }
- }
- }
- //通过底层CLR运算,获取国标参数信息
- string resultfile = m_ReportApp.m_rstDataMgr.ResultFilesList[m_ReportApp.m_rstDataMgr.GetWorkingResult()].FilePath + "\\"
- + m_ReportApp.m_rstDataMgr.ResultFilesList[m_ReportApp.m_rstDataMgr.GetWorkingResult()].FileName;
- m_ReportApp.m_rstDataMgr.m_ReportMgr.AddASmplMsrResultMgr(resultfile);
- OTSCLRINTERFACE.CPropParamClr clr_prop = m_ReportApp.m_rstDataMgr.m_ReportMgr.GetPropertyParamTable();
- List<DataTable> GB1 = m_export_reporttemplate.InsertReportTemplateTable_ChineseStandardABCDDS(clr_prop);
- List<DataTable> GB2 = m_export_reporttemplate.InsertReportTemplateTable_NationalStandardMethodTwo(clr_prop);
- DataTable ResultGrid = m_export_reporttemplate.InsertReportTemplateTable_ResultGrid();
- SaveReportGBTemplateDBFile(GB1, GB2, ResultGrid);//将国标信息存储到数据库中
- OpenOTSINcAreportGBTemplateAPP();//打开报告模板程序
- m_ReportApp.m_conditionChoose.ShowsTheDefaultPic();
- this.Close();
- }
- /// <summary>
- /// 将国标数据保存至DB数据中
- /// </summary>
- private void SaveReportGBTemplateDBFile(List<DataTable> GB1, List<DataTable> GB2, DataTable ResultGrid)
- {
- File.Delete(m_strDBpathGB);//测试时删除数据库文件,为防止第二次打开报告提示数据库占用,挪到方法开始处
- SqlHelper.CreateNewDatabase(m_strDBpathGB);
- SqlHelper sh = new SqlHelper("data source='" + m_strDBpathGB + "'");
- //开始事务
- SQLiteTransaction tr = sh.BeginTranscation();
- try
- {
- //创建表 ResultGrid
- string[] strcolumns_ResultGrid = { "CLJGMC", "YXSJ", "SCZS", "FLFA", "YJCTZ", "SCMJ", "CKBZ" };
- string[] strcoltypes_ResultGrid = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("ResultGrid", strcolumns_ResultGrid, strcoltypes_ResultGrid);
- //创建表 GB1_A
- string[] strcolumns_GB1_A = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
- string[] strcoltypes_GB1_A = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("GB1_A", strcolumns_GB1_A, strcoltypes_GB1_A);
- //创建表 GB1_B
- string[] strcolumns_GB1_B = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
- string[] strcoltypes_GB1_B = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("GB1_B", strcolumns_GB1_B, strcoltypes_GB1_B);
- //创建表 GB1_C
- string[] strcolumns_GB1_C = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
- string[] strcoltypes_GB1_C = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("GB1_C", strcolumns_GB1_C, strcoltypes_GB1_C);
- //创建表 GB1_D
- string[] strcolumns_GB1_D = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
- string[] strcoltypes_GB1_D = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("GB1_D", strcolumns_GB1_D, strcoltypes_GB1_D);
- //创建表 GB1_DS
- string[] strcolumns_GB1_DS = { "No", "Area", "MaxFeret", "X", "Y", "Grade" };
- string[] strcoltypes_GB1_DS = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("GB1_DS", strcolumns_GB1_DS, strcoltypes_GB1_DS);
- //创建表 GB2_A
- string[] strcolumns_GB2_A = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
- string[] strcoltypes_GB2_A = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("GB2_A", strcolumns_GB2_A, strcoltypes_GB2_A);
- //创建表 GB2_B
- string[] strcolumns_GB2_B = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
- string[] strcoltypes_GB2_B = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("GB2_B", strcolumns_GB2_B, strcoltypes_GB2_B);
- //创建表 GB2_C
- string[] strcolumns_GB2_C = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
- string[] strcoltypes_GB2_C = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("GB2_C", strcolumns_GB2_C, strcoltypes_GB2_C);
- //创建表 GB2_D
- string[] strcolumns_GB2_D = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
- string[] strcoltypes_GB2_D = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("GB2_D", strcolumns_GB2_D, strcoltypes_GB2_D);
- //创建表 GB2_D_sulfide
- string[] strcolumns_GB2_D_sulfide = { "Class", "Width", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11" };
- string[] strcoltypes_GB2_D_sulfide = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("GB2_D_sulfide", strcolumns_GB2_D_sulfide, strcoltypes_GB2_D_sulfide);
- //创建表 GB2_DS
- string[] strcolumns_GB2_DS = { "No", "Area", "MaxFeret", "X", "Y", "Grade" };
- string[] strcoltypes_GB2_DS = { "TEXT", "TEXT", "TEXT", "TEXT", "TEXT", "TEXT" };
- sh.CreateTable("GB2_DS", strcolumns_GB2_DS, strcoltypes_GB2_DS);
- for (int i = 0; i < ResultGrid.Rows.Count; i++)
- {
- string ls_sqlstr = "insert into ResultGrid (CLJGMC, YXSJ, SCZS, FLFA, YJCTZ, SCMJ, CKBZ) values('"
- + ResultGrid.Rows[i][0].ToString() + "','"
- + ResultGrid.Rows[i][1].ToString() + "','"
- + ResultGrid.Rows[i][2].ToString() + "','"
- + ResultGrid.Rows[i][3].ToString() + "','"
- + ResultGrid.Rows[i][4].ToString() + "','"
- + ResultGrid.Rows[i][5].ToString() + "','"
- + ResultGrid.Rows[i][6].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 GB1_A
- for (int i = 0; i < GB1[0].Rows.Count; i++)
- {
- string ls_sqlstr = "insert into GB1_A (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
- + GB1[0].Rows[i][0].ToString() + "','"
- + GB1[0].Rows[i][1].ToString() + "','"
- + GB1[0].Rows[i][2].ToString() + "','"
- + GB1[0].Rows[i][3].ToString() + "','"
- + GB1[0].Rows[i][4].ToString() + "','"
- + GB1[0].Rows[i][5].ToString() + "','"
- + GB1[0].Rows[i][6].ToString() + "','"
- + GB1[0].Rows[i][7].ToString() + "','"
- + GB1[0].Rows[i][8].ToString() + "','"
- + GB1[0].Rows[i][9].ToString() + "','"
- + GB1[0].Rows[i][10].ToString() + "','"
- + GB1[0].Rows[i][11].ToString() + "','"
- + GB1[0].Rows[i][12].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 GB1_B
- for (int i = 0; i < GB1[1].Rows.Count; i++)
- {
- string ls_sqlstr = "insert into GB1_B (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
- + GB1[1].Rows[i][0].ToString() + "','"
- + GB1[1].Rows[i][1].ToString() + "','"
- + GB1[1].Rows[i][2].ToString() + "','"
- + GB1[1].Rows[i][3].ToString() + "','"
- + GB1[1].Rows[i][4].ToString() + "','"
- + GB1[1].Rows[i][5].ToString() + "','"
- + GB1[1].Rows[i][6].ToString() + "','"
- + GB1[1].Rows[i][7].ToString() + "','"
- + GB1[1].Rows[i][8].ToString() + "','"
- + GB1[1].Rows[i][9].ToString() + "','"
- + GB1[1].Rows[i][10].ToString() + "','"
- + GB1[1].Rows[i][11].ToString() + "','"
- + GB1[1].Rows[i][12].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 GB1_C
- for (int i = 0; i < GB1[2].Rows.Count; i++)
- {
- string ls_sqlstr = "insert into GB1_C (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
- + GB1[2].Rows[i][0].ToString() + "','"
- + GB1[2].Rows[i][1].ToString() + "','"
- + GB1[2].Rows[i][2].ToString() + "','"
- + GB1[2].Rows[i][3].ToString() + "','"
- + GB1[2].Rows[i][4].ToString() + "','"
- + GB1[2].Rows[i][5].ToString() + "','"
- + GB1[2].Rows[i][6].ToString() + "','"
- + GB1[2].Rows[i][7].ToString() + "','"
- + GB1[2].Rows[i][8].ToString() + "','"
- + GB1[2].Rows[i][9].ToString() + "','"
- + GB1[2].Rows[i][10].ToString() + "','"
- + GB1[2].Rows[i][11].ToString() + "','"
- + GB1[2].Rows[i][12].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 GB1_D
- for (int i = 0; i < GB1[3].Rows.Count; i++)
- {
- string ls_sqlstr = "insert into GB1_D (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
- + GB1[3].Rows[i][0].ToString() + "','"
- + GB1[3].Rows[i][1].ToString() + "','"
- + GB1[3].Rows[i][2].ToString() + "','"
- + GB1[3].Rows[i][3].ToString() + "','"
- + GB1[3].Rows[i][4].ToString() + "','"
- + GB1[3].Rows[i][5].ToString() + "','"
- + GB1[3].Rows[i][6].ToString() + "','"
- + GB1[3].Rows[i][7].ToString() + "','"
- + GB1[3].Rows[i][8].ToString() + "','"
- + GB1[3].Rows[i][9].ToString() + "','"
- + GB1[3].Rows[i][10].ToString() + "','"
- + GB1[3].Rows[i][11].ToString() + "','"
- + GB1[3].Rows[i][12].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 GB1_DS
- for (int i = 0; i < GB1[4].Rows.Count; i++)
- {
- string ls_sqlstr = "insert into GB1_DS (No, Area, MaxFeret, X, Y, Grade ) values('"
- + GB1[4].Rows[i][0].ToString() + "','"
- + GB1[4].Rows[i][1].ToString() + "','"
- + GB1[4].Rows[i][2].ToString() + "','"
- + GB1[4].Rows[i][3].ToString() + "','"
- + GB1[4].Rows[i][4].ToString() + "','"
- + GB1[4].Rows[i][5].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 GB2_A
- for (int i = 0; i < GB2[0].Rows.Count; i++)
- {
- string ls_sqlstr = "insert into GB2_A (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
- + GB2[0].Rows[i][0].ToString() + "','"
- + GB2[0].Rows[i][1].ToString() + "','"
- + GB2[0].Rows[i][2].ToString() + "','"
- + GB2[0].Rows[i][3].ToString() + "','"
- + GB2[0].Rows[i][4].ToString() + "','"
- + GB2[0].Rows[i][5].ToString() + "','"
- + GB2[0].Rows[i][6].ToString() + "','"
- + GB2[0].Rows[i][7].ToString() + "','"
- + GB2[0].Rows[i][8].ToString() + "','"
- + GB2[0].Rows[i][9].ToString() + "','"
- + GB2[0].Rows[i][10].ToString() + "','"
- + GB2[0].Rows[i][11].ToString() + "','"
- + GB2[0].Rows[i][12].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 GB2_B
- for (int i = 0; i < GB2[1].Rows.Count; i++)
- {
- string ls_sqlstr = "insert into GB2_B (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
- + GB2[1].Rows[i][0].ToString() + "','"
- + GB2[1].Rows[i][1].ToString() + "','"
- + GB2[1].Rows[i][2].ToString() + "','"
- + GB2[1].Rows[i][3].ToString() + "','"
- + GB2[1].Rows[i][4].ToString() + "','"
- + GB2[1].Rows[i][5].ToString() + "','"
- + GB2[1].Rows[i][6].ToString() + "','"
- + GB2[1].Rows[i][7].ToString() + "','"
- + GB2[1].Rows[i][8].ToString() + "','"
- + GB2[1].Rows[i][9].ToString() + "','"
- + GB2[1].Rows[i][10].ToString() + "','"
- + GB2[1].Rows[i][11].ToString() + "','"
- + GB2[1].Rows[i][12].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 GB2_C
- for (int i = 0; i < GB2[2].Rows.Count; i++)
- {
- string ls_sqlstr = "insert into GB2_C (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
- + GB2[2].Rows[i][0].ToString() + "','"
- + GB2[2].Rows[i][1].ToString() + "','"
- + GB2[2].Rows[i][2].ToString() + "','"
- + GB2[2].Rows[i][3].ToString() + "','"
- + GB2[2].Rows[i][4].ToString() + "','"
- + GB2[2].Rows[i][5].ToString() + "','"
- + GB2[2].Rows[i][6].ToString() + "','"
- + GB2[2].Rows[i][7].ToString() + "','"
- + GB2[2].Rows[i][8].ToString() + "','"
- + GB2[2].Rows[i][9].ToString() + "','"
- + GB2[2].Rows[i][10].ToString() + "','"
- + GB2[2].Rows[i][11].ToString() + "','"
- + GB2[2].Rows[i][12].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 GB1_D
- for (int i = 0; i < GB2[3].Rows.Count; i++)
- {
- string ls_sqlstr = "insert into GB2_D (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
- + GB2[3].Rows[i][0].ToString() + "','"
- + GB2[3].Rows[i][1].ToString() + "','"
- + GB2[3].Rows[i][2].ToString() + "','"
- + GB2[3].Rows[i][3].ToString() + "','"
- + GB2[3].Rows[i][4].ToString() + "','"
- + GB2[3].Rows[i][5].ToString() + "','"
- + GB2[3].Rows[i][6].ToString() + "','"
- + GB2[3].Rows[i][7].ToString() + "','"
- + GB2[3].Rows[i][8].ToString() + "','"
- + GB2[3].Rows[i][9].ToString() + "','"
- + GB2[3].Rows[i][10].ToString() + "','"
- + GB2[3].Rows[i][11].ToString() + "','"
- + GB2[3].Rows[i][12].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 GB2_D_sulfide
- for (int i = 0; i < GB2[4].Rows.Count; i++)
- {
- string ls_sqlstr = "insert into GB2_D_sulfide (Class, Width, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11 ) values('"
- + GB2[4].Rows[i][0].ToString() + "','"
- + GB2[4].Rows[i][1].ToString() + "','"
- + GB2[4].Rows[i][2].ToString() + "','"
- + GB2[4].Rows[i][3].ToString() + "','"
- + GB2[4].Rows[i][4].ToString() + "','"
- + GB2[4].Rows[i][5].ToString() + "','"
- + GB2[4].Rows[i][6].ToString() + "','"
- + GB2[4].Rows[i][7].ToString() + "','"
- + GB2[4].Rows[i][8].ToString() + "','"
- + GB2[4].Rows[i][9].ToString() + "','"
- + GB2[4].Rows[i][10].ToString() + "','"
- + GB2[4].Rows[i][11].ToString() + "','"
- + GB2[4].Rows[i][12].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //插入 GB1_DS
- for (int i = 0; i < GB2[5].Rows.Count; i++)
- {
- string ls_sqlstr = "insert into GB2_DS (No, Area, MaxFeret, X, Y, Grade ) values('"
- + GB1[5].Rows[i][0].ToString() + "','"
- + GB1[5].Rows[i][1].ToString() + "','"
- + GB1[5].Rows[i][2].ToString() + "','"
- + GB1[5].Rows[i][3].ToString() + "','"
- + GB1[5].Rows[i][4].ToString() + "','"
- + GB1[5].Rows[i][5].ToString() + "')";
- int iresult = sh.ExecuteQueryResult(ls_sqlstr, tr);
- }
- //事务提交
- sh.TranscationCommit(tr);
- }
- catch (Exception ee)
- {
- //回滚
- sh.TranscationRollback(tr);
- }
- finally
- {
- //最后关闭连接
- tr.Dispose();
- tr = null;
- sh.CloseConnection();
- }
- }
- /// <summary>
- /// 打开国标导出
- /// </summary>
- private void OpenOTSINcAreportGBTemplateAPP()
- {
- ProcessStartInfo process = new ProcessStartInfo();
- process.FileName = "ReportTemplateExe\\OTSIncAReportTemplate.exe";//打开app的路径
- string arg1 = m_strDBpathGB.Replace(" ", "^");//参数1,是需要打开db数据库的路径
- string arg2 = tb_mblj.Text.Trim().Replace(" ", "^");//参数2,是模板文件的路径
- string arg3 = "GBReport";//主体报表
- string arg4 = "100";//夹杂物数量
- string arg5 = "0-100";//打开的标记帧图图像数量
- process.Arguments = string.Format("{0} {1} {2} {3} {4}", arg1, arg2, arg3, arg4, arg5); //多个参数用空格隔开
- process.WindowStyle = ProcessWindowStyle.Normal;
- Process.Start(process);
-
- }
- private void OTSReport_Export_FormClosed(object sender, FormClosedEventArgs e)
- {
-
- }
- }
-
- }
|