frmReportSysConfig.cs 11 KB

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