frmReportSysConfig.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. using OTSCommon;
  2. using OTSIncAReportApp;
  3. using OTSIncAReportApp.Controls;
  4. using OTSIncAReportApp.OTSRstMgrFunction;
  5. using OTSIncAReportApp.OTSMgrInfo;
  6. using OTSIncAReportApp.SysMgrTools;
  7. using System;
  8. using System.Data;
  9. using System.IO;
  10. using System.Windows.Forms;
  11. using Language = OTSIncAReportApp.SysMgrTools.Language;
  12. namespace OTSIncAReprotCharts
  13. {
  14. public partial class frmReportSysConfig : Form
  15. {
  16. #region 变量
  17. public ResultDataMgr m_DataMgrFun = null;
  18. //粒级文件夹路径
  19. public static string m_PathName = "";
  20. //粒级文件夹获取
  21. public static string m_strPath = "";
  22. /// <summary>
  23. /// 保存的全局主窗体对象
  24. /// </summary>
  25. frmReportApp m_ReportApp;
  26. #endregion
  27. #region 构造函数及窗体加载
  28. public frmReportSysConfig(frmReportApp ReportApp)
  29. {
  30. InitializeComponent();
  31. //粒级部分
  32. this.m_DataMgrFun = ReportApp.m_rstDataMgr;
  33. m_ReportApp = ReportApp;
  34. //参数设置
  35. tb_sjtmbwj.Text = "";
  36. #region 国际化语言
  37. Language lan = new Language(this);
  38. #endregion
  39. }
  40. private void ReportMgrInfoForm_Load(object sender, EventArgs e)
  41. {
  42. //初始化数据
  43. InitMyComponent();
  44. InitData();
  45. }
  46. #endregion
  47. #region 自定义方法
  48. public void InitData()
  49. {
  50. DirectoryInfo theFolder = new DirectoryInfo(tb_PartiSizeFileFolder.Text);
  51. if (!theFolder.Exists)
  52. return;
  53. comboBox_PartiSizeFileFolder.Items.Clear();
  54. //读取遍历粒级文件信息
  55. foreach (FileInfo nextifile in theFolder.GetFiles())
  56. {
  57. //找出粒级文件
  58. if (nextifile.Name.Contains(".psf") == true || nextifile.Name.Contains(".PSF") == true)
  59. {
  60. comboBox_PartiSizeFileFolder.Items.Add(nextifile.Name);
  61. }
  62. }
  63. cB_sjtmbwj.Items.Clear();
  64. //三元相图模板配置文件
  65. string path = m_DataMgrFun.m_RptConfigFile.TrigTemplateFileFolder + "\\" + m_DataMgrFun.m_RptConfigFile.TriTempFile;
  66. DataSet ds = XMLoperate.GetXmlData(path, "XMLData");
  67. DataTable dt = ds.Tables["Member"];
  68. for (int i = 0; i < dt.Rows.Count; i++)
  69. {
  70. cB_sjtmbwj.Items.Add(dt.Rows[i]["TemplateName"].ToString());
  71. }
  72. cB_SIZE_CAL_METHOD_TYPE.Items.Clear();
  73. cB_SIZE_CAL_METHOD_TYPE.Items.AddRange(m_DataMgrFun.GetSizeCalMethodTypeList().ToArray());
  74. DataSet ds1 = XMLoperate.GetXmlData(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "XMLData");
  75. DataTable dt1 = ds1.Tables["Member"];
  76. foreach (DataRow element in dt1.Rows)
  77. {
  78. string RegName = element["RegName"].ToString();
  79. if (RegName == "PartSizeFile")
  80. {
  81. comboBox_PartiSizeFileFolder.SelectedIndex = comboBox_PartiSizeFileFolder.Items.IndexOf(element["name"].ToString());
  82. }
  83. if (RegName == "TRIO_CHART_TYPE")
  84. {
  85. cB_sjtmbwj.SelectedIndex = cB_sjtmbwj.Items.IndexOf(element["strValue"].ToString());
  86. }
  87. if (RegName == "SIZE_CAL_METHOD_TYPE")
  88. {
  89. cB_SIZE_CAL_METHOD_TYPE.SelectedIndex = cB_SIZE_CAL_METHOD_TYPE.Items.IndexOf(element["strValue"].ToString());
  90. }
  91. }
  92. }
  93. public void InitMyComponent()
  94. {
  95. string imagepath;
  96. //显示程序管理对话框参数设置
  97. string strbpath = ".\\Config\\ProData\\";
  98. tb_PartiSizeFileFolder.Text = strbpath;
  99. imagepath = strbpath;
  100. tb_sjtmb.Text = strbpath;
  101. tb_sjtmbwj.Text = "DefaultTriTemplateFile.tpf";
  102. //一般参数内的所有textbox不可修改
  103. tb_sjtmb.ReadOnly = true;
  104. tb_sjtmbwj.ReadOnly = true;
  105. tb_PartiSizeFileFolder.ReadOnly = true;
  106. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXmlData(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "XMLData");
  107. DataTable dt = ds.Tables["Member"];
  108. string str_scale="";
  109. foreach (DataRow element in dt.Rows)
  110. {
  111. string RegName = element["RegName"].ToString();
  112. if (RegName == "Scale")
  113. {
  114. str_scale = element["strValue"].ToString();
  115. }
  116. }
  117. //比例因子
  118. tb_blyz.Text = str_scale;
  119. }
  120. private void tb_blyz_KeyPress(object sender, KeyPressEventArgs e)
  121. {
  122. if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8 && (int)e.KeyChar != 46)
  123. e.Handled = true;
  124. //小数点的处理。
  125. if ((int)e.KeyChar == 46) //小数点
  126. {
  127. if (tb_blyz.Text.Length <= 0)
  128. e.Handled = true; //小数点不能在第一位
  129. else
  130. {
  131. float f;
  132. float oldf;
  133. bool b1 = false, b2 = false;
  134. b1 = float.TryParse(tb_blyz.Text, out oldf);
  135. b2 = float.TryParse(tb_blyz.Text + e.KeyChar.ToString(), out f);
  136. if (b2 == false)
  137. {
  138. if (b1 == true)
  139. e.Handled = true;
  140. else
  141. e.Handled = false;
  142. }
  143. }
  144. }
  145. }
  146. #endregion
  147. #region 三元相图相关
  148. //三元相图模板文件夹
  149. private void btn_klljwjj_Click(object sender, EventArgs e)
  150. {
  151. if (tb_PartiSizeFileFolder.Text == ".\\Config\\ProData\\")
  152. {
  153. string strb = ".\\Config\\ProData\\";
  154. folderBrowserDialog1.SelectedPath = strb;
  155. if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
  156. {
  157. tb_PartiSizeFileFolder.Text = folderBrowserDialog1.SelectedPath;
  158. }
  159. }
  160. else
  161. {
  162. if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
  163. {
  164. tb_PartiSizeFileFolder.Text = folderBrowserDialog1.SelectedPath;
  165. }
  166. else
  167. {
  168. tb_PartiSizeFileFolder.Text = folderBrowserDialog1.SelectedPath;
  169. }
  170. }
  171. }
  172. private void btn_sjtwj_Click(object sender, EventArgs e)
  173. {
  174. Triangulation_List tl = new Triangulation_List(m_ReportApp);
  175. tl.ShowDialog();
  176. }
  177. #endregion
  178. #region 粒级相关
  179. //颗粒粒级文件夹
  180. private void btn_sjtmbwjj_Click(object sender, EventArgs e)
  181. {
  182. //点击颗粒粒级文件夹按钮
  183. folderBrowserDialog1.ShowDialog();
  184. tb_sjtmb.Text = folderBrowserDialog1.SelectedPath;
  185. }
  186. private void btn_PartSize_Click(object sender, EventArgs e)
  187. {
  188. frmPartSizeEditorNew fPSEN = new frmPartSizeEditorNew(m_ReportApp, tb_PartiSizeFileFolder.Text);
  189. if (fPSEN.ShowDialog() == DialogResult.OK)
  190. {
  191. }
  192. }
  193. #endregion
  194. #region 报告模板相关
  195. //报表模板
  196. private void btn_bbmbwjj_Click(object sender, EventArgs e)
  197. {
  198. FolderBrowserDialog ofd = new FolderBrowserDialog();
  199. if (ofd.ShowDialog() == DialogResult.OK)
  200. {
  201. //tb_bgmb.Text = ofd.SelectedPath + @"\";
  202. }
  203. }
  204. //参数设置,报告模板文件
  205. private void button2_Click(object sender, EventArgs e)
  206. {
  207. //if (tb_bgmb.Text != "")
  208. //{
  209. // OpenFileDialog op = new OpenFileDialog();
  210. // string strpath = "";
  211. // op.InitialDirectory = tb_bgmb.Text;
  212. // if (op.ShowDialog() == DialogResult.OK)
  213. // {
  214. // strpath = op.FileName;
  215. // tb_bgmbwj.Text = strpath;
  216. // }
  217. //}
  218. }
  219. #endregion
  220. #region 报告参数设置相关
  221. //取消
  222. private void btn_ybcsqx_Click(object sender, EventArgs e)
  223. {
  224. this.Close();
  225. }
  226. public string strParSizeFile = "";
  227. //保存报告文件
  228. private void btn_ybcsbc_Click(object sender, EventArgs e)
  229. {
  230. double blyz = 0;
  231. if (!double.TryParse(tb_blyz.Text.ToString(), out blyz))
  232. {
  233. MessageBox.Show("please check params!");
  234. }
  235. //参数设置保存功能粒级文件
  236. strParSizeFile = tb_PartiSizeFileFolder.Text;
  237. String strTritempFile = tb_sjtmb.Text;
  238. string strTritemp = tb_sjtmbwj.Text;
  239. //根据xml读取内容
  240. XmlOperateUtil xmlutil = new XmlOperateUtil(".\\Config\\ProData\\"+comboBox_PartiSizeFileFolder.Text.ToString());
  241. string PartiSize=xmlutil.GetAttribute("Name", "XMLData");
  242. //比例因子
  243. OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.EditXmlInfo(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "Scale", "strValue", tb_blyz.Text.ToString());
  244. OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.EditXmlInfo(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "PartSizeFile", "name", comboBox_PartiSizeFileFolder.Text.ToString());
  245. //OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.EditXmlInfo(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "PartSize", "strValue", PartiSize);
  246. OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.EditXmlInfo(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "TRIO_CHART_TYPE", "strValue", cB_sjtmbwj.Text.ToString());
  247. OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.EditXmlInfo(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "SIZE_CAL_METHOD_TYPE", "strValue", cB_SIZE_CAL_METHOD_TYPE.Text.ToString());
  248. if (m_ReportApp.m_rstDataMgr.CurResultFile != null)
  249. {
  250. m_ReportApp.m_conditionChoose.SetDefaultConditionValue();
  251. }
  252. this.Close();
  253. }
  254. #endregion
  255. }
  256. }