FrmPhyRStd.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Infragistics.Win.UltraWinGrid;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Drawing;
  9. using System.Windows.Forms;
  10. namespace Core.StlMes.Client.Qcm
  11. {
  12. public partial class FrmPhyRStd : FrmBaseQcm
  13. {
  14. int index = 0;
  15. private string _selectedCode = "";
  16. public FrmPhyRStd()
  17. {
  18. InitializeComponent();
  19. ExceptionHelper.RegistException();
  20. _dtBaseQcm = new DtPhyRStd(this);
  21. }
  22. List<FileBean> fileList = new List<FileBean>();
  23. public List<FileBean> FileList
  24. {
  25. get { return fileList; }
  26. set { fileList = value; }
  27. }
  28. private string filePath = ""; //用于保存上传图片
  29. public string FilePath
  30. {
  31. get { return filePath; }
  32. set { filePath = value; }
  33. }
  34. private string oldfilePath = "";//前一个路径,用于删除。
  35. public string OldfilePath
  36. {
  37. get { return oldfilePath; }
  38. set { oldfilePath = value; }
  39. }
  40. protected override void BeginDoAction(ActionType actionType)
  41. {
  42. if (actionType == ActionType.Add || actionType == ActionType.Modify)
  43. {
  44. _selectedCode = "";
  45. }
  46. else
  47. {
  48. _selectedCode = ultraGrid1.ActiveRow.Cells["PHY_STD_ID"].Value.ToString();
  49. }
  50. }
  51. protected override void SuccessDoAction(ActionType actionType)
  52. {
  53. if (actionType == ActionType.Add)
  54. {
  55. SetGridRowActiveWithKey(ultraGrid1, "PHY_STD_ID", "CREATE_NAME", "CREATE_TIME");
  56. }
  57. else if (actionType == ActionType.Modify)
  58. {
  59. SetGridRowActiveWithKey(ultraGrid1, "PHY_STD_ID", "UPDATE_NAME", "UPDATE_TIME");
  60. }
  61. else
  62. {
  63. SetGridRowActiveWithKey(ultraGrid1, "PHY_STD_ID", _selectedCode);
  64. }
  65. }
  66. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  67. {
  68. //PHY_TYPE
  69. if (ultraGrid1.ActiveRow == null)
  70. return;
  71. cmbPhyType.SelecteValue = ultraGrid1.ActiveRow.Cells["PHY_CODE"].Value.ToString();
  72. cmbStdName.SelecteValue = ultraGrid1.ActiveRow.Cells["STD_CODE"].Value.ToString();
  73. cmbStdAlpha.SelecteValue = ultraGrid1.ActiveRow.Cells["STD_CODE_ALPHA"].Value.ToString();
  74. cmbPhyStd.SelecteValue = ultraGrid1.ActiveRow.Cells["PHY_STD"].Value.ToString();
  75. txtMemo.Text = ultraGrid1.ActiveRow.Cells["MEMO"].Value.ToString();
  76. ultraTextEditor1.Text = ultraGrid1.ActiveRow.Cells["STD_FILE_PATH"].Value.ToString();
  77. index = 1;
  78. }
  79. private void FrmPhyRStd_Load(object sender, EventArgs e)
  80. {
  81. LoadBaseInfo();
  82. GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], "");
  83. }
  84. protected override void OnLoad(EventArgs e)
  85. {
  86. base.OnLoad(e);
  87. this.flowLayoutPanel2.BackColor = Color.Transparent;
  88. cmbStdName.ComboBox.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend;
  89. cmbPhyStd.ComboBox.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend;
  90. cmbPhyType.ComboBox.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend;
  91. cmbPhyType2.ComboBox.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend;
  92. }
  93. protected override void LoadBaseInfo()
  94. {
  95. QcmBaseQuery.NitializeStandardG(cmbStdName, false, ob);
  96. //QcmBaseQuery.NitializeAlphaStandard(cmbStdAlpha, false, ob);
  97. QcmBaseQuery.NitializeStandardSS(cmbPhyStd, false, ob);
  98. QcmBaseQuery.NitializeBasePhyB(cmbPhyType, false, ob);
  99. QcmBaseQuery.NitializeBasePhyB(cmbPhyType2, true, ob);
  100. cmbStdAlpha.ComboBox.DropDownListWidth = 200;
  101. cmbStdName.ComboBox.DropDownListWidth = 200;
  102. ClsBaseInfo.SetComboItemHeight(cmbPhyType.ComboBox);
  103. ClsBaseInfo.SetComboItemHeight(cmbPhyType2.ComboBox);
  104. ClsBaseInfo.SetComboItemHeight(cmbStdName.ComboBox);
  105. ClsBaseInfo.SetComboItemHeight(cmbPhyStd.ComboBox);
  106. //string code = "";
  107. //if (cmbStdName.SelecteValue != null)
  108. // code = cmbStdName.SelecteValue.ToString();
  109. //DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBasePhyRStdMng.getStdAlpha", new object[] { code }, this.ob);
  110. //if (dt != null && dt.Rows.Count > 0)
  111. //{
  112. // DataRow dr = dt.NewRow();
  113. // for (int i = 0; i < dt.Columns.Count; i++)
  114. // {
  115. // dr[i] = "";
  116. // }
  117. // dt.Rows.InsertAt(dr, 0);
  118. //}
  119. //cmbStdAlpha.ComboBox.DataSource = dt;
  120. //cmbStdAlpha.ComboBox.ValueMember = "STD_CODE";
  121. //cmbStdAlpha.ComboBox.DisplayMember = "STD_NAME";
  122. }
  123. private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
  124. {
  125. SetDeleteColor(e, "VALIDFLAG", "0");
  126. }
  127. private void cmbStdName_ComboBox_SelectedValueChanged(object sender, EventArgs e)
  128. {
  129. string code = "";
  130. if (cmbStdName.SelecteValue != null)
  131. {
  132. code = cmbStdName.SelecteValue.ToString();
  133. }
  134. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComBasePhyRStdMng.getStdAlpha", new object[] { code }, this.ob);
  135. if (dt != null && dt.Rows.Count > 0)
  136. {
  137. DataRow dr = dt.NewRow();
  138. for (int i = 0; i < dt.Columns.Count; i++)
  139. {
  140. dr[i] = "";
  141. }
  142. dt.Rows.InsertAt(dr, 0);
  143. }
  144. cmbStdAlpha.ComboBox.DataSource = dt;
  145. cmbStdAlpha.ComboBox.ValueMember = "STD_CODE";
  146. cmbStdAlpha.ComboBox.DisplayMember = "STD_NAME";
  147. ClsBaseInfo.SetComboItemHeight(cmbStdAlpha.ComboBox);
  148. cmbStdAlpha.ComboBox.AutoCompleteMode = Infragistics.Win.AutoCompleteMode.SuggestAppend;
  149. }
  150. private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  151. {
  152. if (e.Button.Key.Equals("2")) //选择上传文件
  153. {
  154. fileList = new List<FileBean>();
  155. FileBean bean = new FileBean();
  156. OpenFileDialog file = new OpenFileDialog();
  157. string filter = "图片文件(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|Word文档(*.doc;*.docx)|*.doc;*.docx|文本文档(*.txt;)|*.txt";
  158. // file.Multiselect = true;
  159. file.Filter = filter;
  160. if (!ultraTextEditor1.Text.Trim().Equals(""))
  161. {
  162. OldfilePath = "PhyRStd/" + ultraTextEditor1.Text;
  163. }
  164. if (file.ShowDialog() == DialogResult.OK)
  165. {
  166. foreach (string fileName in file.FileNames)
  167. {
  168. bean = new FileBean();
  169. string filena = System.IO.Path.GetFileName(fileName);
  170. bean.setFileName(DateTime.Now.ToString("yyyyMMdd") + filena);
  171. bean.setPathName("PhyRStd");
  172. bean.setFile(FileHelper.FileToArray(fileName));
  173. fileList.Add(bean);
  174. ultraTextEditor1.Text = DateTime.Now.ToString("yyyyMMdd") + filena;
  175. FilePath = "PhyRStd/" + filena;
  176. }
  177. index = 2;
  178. }
  179. }
  180. if (e.Button.Key.Equals("1")) //预览
  181. {
  182. if (index == 2)
  183. {
  184. MessageUtil.ShowWarning("此文件尚未上传到服务器!");
  185. return;
  186. }
  187. if (ultraTextEditor1.Text.Trim() == "")
  188. {
  189. MessageUtil.ShowWarning("没有文件可预览!");
  190. return;
  191. }
  192. FrmFilePreview ffp = new FrmFilePreview();
  193. ffp.FilePath = ultraTextEditor1.Text.ToString();
  194. ffp.ShowDialog();
  195. if (ffp.FilePath != "")
  196. System.IO.File.Delete(ffp.FilePath);
  197. }
  198. }
  199. }
  200. }