frmReportSysConfig.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. string strbpath = ".\\Config\\ProData\\";
  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. #region 国际化语言
  36. Language lan = new Language(this);
  37. #endregion
  38. }
  39. private void ReportMgrInfoForm_Load(object sender, EventArgs e)
  40. {
  41. //初始化数据
  42. InitMyComponent();
  43. InitData();
  44. }
  45. #endregion
  46. #region 自定义方法
  47. public void InitData()
  48. {
  49. DirectoryInfo theFolder = new DirectoryInfo(strbpath);
  50. if (!theFolder.Exists)
  51. return;
  52. comboBox_PartiSizeFileFolder.Items.Clear();
  53. //读取遍历粒级文件信息
  54. foreach (FileInfo nextifile in theFolder.GetFiles())
  55. {
  56. //找出粒级文件
  57. if (nextifile.Name.Contains(".psf") == true || nextifile.Name.Contains(".PSF") == true)
  58. {
  59. comboBox_PartiSizeFileFolder.Items.Add(nextifile.Name);
  60. }
  61. }
  62. cB_sjtmbwj.Items.Clear();
  63. //三元相图模板配置文件
  64. string path = m_DataMgrFun.m_RptConfigFile.TrigTemplateFileFolder + "\\" + m_DataMgrFun.m_RptConfigFile.TriTempFile;
  65. DataSet ds = XMLoperate.GetXmlData(path, "XMLData");
  66. DataTable dt = ds.Tables["Member"];
  67. for (int i = 0; i < dt.Rows.Count; i++)
  68. {
  69. cB_sjtmbwj.Items.Add(dt.Rows[i]["TemplateName"].ToString());
  70. }
  71. cB_SIZE_CAL_METHOD_TYPE.Items.Clear();
  72. cB_SIZE_CAL_METHOD_TYPE.Items.AddRange(m_DataMgrFun.GetSizeCalMethodTypeList().ToArray());
  73. DataSet ds1 = XMLoperate.GetXmlData(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "XMLData");
  74. DataTable dt1 = ds1.Tables["Member"];
  75. foreach (DataRow element in dt1.Rows)
  76. {
  77. string RegName = element["RegName"].ToString();
  78. if (RegName == "PartSizeFile")
  79. {
  80. comboBox_PartiSizeFileFolder.SelectedIndex = comboBox_PartiSizeFileFolder.Items.IndexOf(element["name"].ToString());
  81. }
  82. if (RegName == "TRIO_CHART_TYPE")
  83. {
  84. cB_sjtmbwj.SelectedIndex = cB_sjtmbwj.Items.IndexOf(element["strValue"].ToString());
  85. }
  86. if (RegName == "SIZE_CAL_METHOD_TYPE")
  87. {
  88. cB_SIZE_CAL_METHOD_TYPE.SelectedIndex = cB_SIZE_CAL_METHOD_TYPE.Items.IndexOf(element["strValue"].ToString());
  89. }
  90. }
  91. }
  92. public void InitMyComponent()
  93. {
  94. string imagepath;
  95. //显示程序管理对话框参数设置
  96. imagepath = strbpath;
  97. DataSet ds = OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.GetXmlData(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "XMLData");
  98. DataTable dt = ds.Tables["Member"];
  99. string str_scale="";
  100. foreach (DataRow element in dt.Rows)
  101. {
  102. string RegName = element["RegName"].ToString();
  103. if (RegName == "Scale")
  104. {
  105. str_scale = element["strValue"].ToString();
  106. }
  107. }
  108. //比例因子
  109. tb_blyz.Text = str_scale;
  110. }
  111. private void tb_blyz_KeyPress(object sender, KeyPressEventArgs e)
  112. {
  113. if (((int)e.KeyChar < 48 || (int)e.KeyChar > 57) && (int)e.KeyChar != 8 && (int)e.KeyChar != 46)
  114. e.Handled = true;
  115. //小数点的处理。
  116. if ((int)e.KeyChar == 46) //小数点
  117. {
  118. if (tb_blyz.Text.Length <= 0)
  119. e.Handled = true; //小数点不能在第一位
  120. else
  121. {
  122. float f;
  123. float oldf;
  124. bool b1 = false, b2 = false;
  125. b1 = float.TryParse(tb_blyz.Text, out oldf);
  126. b2 = float.TryParse(tb_blyz.Text + e.KeyChar.ToString(), out f);
  127. if (b2 == false)
  128. {
  129. if (b1 == true)
  130. e.Handled = true;
  131. else
  132. e.Handled = false;
  133. }
  134. }
  135. }
  136. }
  137. #endregion
  138. #region 三元相图相关
  139. //三元相图模板文件夹
  140. private void btn_klljwjj_Click(object sender, EventArgs e)
  141. {
  142. string strb = ".\\Config\\ProData\\";
  143. folderBrowserDialog1.SelectedPath = strb;
  144. }
  145. private void btn_sjtwj_Click(object sender, EventArgs e)
  146. {
  147. Triangulation_List tl = new Triangulation_List(m_ReportApp);
  148. tl.ShowDialog();
  149. }
  150. #endregion
  151. #region 粒级相关
  152. private void btn_PartSize_Click(object sender, EventArgs e)
  153. {
  154. frmPartSizeEditorNew fPSEN = new frmPartSizeEditorNew(m_ReportApp, strbpath, comboBox_PartiSizeFileFolder.Text);
  155. if (fPSEN.ShowDialog() == DialogResult.OK)
  156. {
  157. }
  158. }
  159. #endregion
  160. #region 报告模板相关
  161. //报表模板
  162. private void btn_bbmbwjj_Click(object sender, EventArgs e)
  163. {
  164. FolderBrowserDialog ofd = new FolderBrowserDialog();
  165. if (ofd.ShowDialog() == DialogResult.OK)
  166. {
  167. //tb_bgmb.Text = ofd.SelectedPath + @"\";
  168. }
  169. }
  170. //参数设置,报告模板文件
  171. private void button2_Click(object sender, EventArgs e)
  172. {
  173. //if (tb_bgmb.Text != "")
  174. //{
  175. // OpenFileDialog op = new OpenFileDialog();
  176. // string strpath = "";
  177. // op.InitialDirectory = tb_bgmb.Text;
  178. // if (op.ShowDialog() == DialogResult.OK)
  179. // {
  180. // strpath = op.FileName;
  181. // tb_bgmbwj.Text = strpath;
  182. // }
  183. //}
  184. }
  185. #endregion
  186. #region 报告参数设置相关
  187. //取消
  188. private void btn_ybcsqx_Click(object sender, EventArgs e)
  189. {
  190. this.Close();
  191. }
  192. public string strParSizeFile = "";
  193. //保存报告文件
  194. private void btn_ybcsbc_Click(object sender, EventArgs e)
  195. {
  196. double blyz = 0;
  197. if (!double.TryParse(tb_blyz.Text.ToString(), out blyz))
  198. {
  199. MessageBox.Show("please check params!");
  200. }
  201. //根据xml读取内容
  202. XmlOperateUtil xmlutil = new XmlOperateUtil(".\\Config\\ProData\\"+comboBox_PartiSizeFileFolder.Text.ToString());
  203. string PartiSize=xmlutil.GetAttribute("Name", "XMLData");
  204. //比例因子
  205. OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.EditXmlInfo(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "Scale", "strValue", tb_blyz.Text.ToString());
  206. OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.EditXmlInfo(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "PartSizeFile", "name", comboBox_PartiSizeFileFolder.Text.ToString());
  207. //OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.EditXmlInfo(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "PartSize", "strValue", PartiSize);
  208. OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.EditXmlInfo(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "TRIO_CHART_TYPE", "strValue", cB_sjtmbwj.Text.ToString());
  209. OTSIncAReportApp.DataOperation.DataAccess.XMLoperate.EditXmlInfo(Application.StartupPath + RptConfigFile.m_ReportMgrParamFile, "SIZE_CAL_METHOD_TYPE", "strValue", cB_SIZE_CAL_METHOD_TYPE.Text.ToString());
  210. if (m_ReportApp.m_rstDataMgr.CurResultFile != null)
  211. {
  212. m_ReportApp.m_conditionChoose.SetDefaultConditionValue();
  213. }
  214. this.Close();
  215. }
  216. #endregion
  217. }
  218. }