FrmQualityObjectives.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using CoreFS.CA06;
  10. using Infragistics.Win.UltraWinEditors;
  11. using Core.StlMes.Client.ZGMil.Signature;
  12. using Core.StlMes.Client.ZGMil.Entity;
  13. using Core.Mes.Client.Comm.Control;
  14. using Infragistics.Win.UltraWinGrid;
  15. using Core.Mes.Client.Comm.Tool;
  16. using Core.Mes.Client.Comm.Server;
  17. using CoreFS.SA06;
  18. using System.Collections;
  19. using Infragistics.Win;
  20. using System.IO;
  21. using Core.Mes.Client.Comm.Format;
  22. namespace Core.StlMes.Client.ZGMil
  23. {
  24. public partial class FrmQualityObjectives : FrmBase
  25. {
  26. private string departm = "";
  27. UltraComboEditor ucePline = new UltraComboEditor();//产线名称
  28. private string plineCode;
  29. string year = "";
  30. public FrmQualityObjectives()
  31. {
  32. InitializeComponent();
  33. }
  34. private void FrmQualityObjectives_Load(object sender, EventArgs e)
  35. {
  36. NativeMethodNew na = new NativeMethodNew(this.ob);
  37. departm = UserInfo.GetDepartment();
  38. plineCode = na.GetPCode(departm);//获取 用户 对应的产线
  39. EntityHelper.ShowGridCaption<ComBaseQualityObjectivesEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  40. year = DateTime.Now.Year.ToString();
  41. //plineCode = na.GetPCodePline(this.ValidDataPurviewIds);//获取产线方法
  42. //TubeRoll.InitComboEditorValue(ucePline, "com.steering.mes.signature.FrmQualityObjectives.queryPlineCode", "PLINE_CODE", this.ob, false, plineCode);
  43. //TubeRoll.BindColumn(ucePline, "PLINE_CODE", this.Controls, this.ultraGrid1, 0);
  44. //ultraPlineCode.Items.Remove()
  45. //类别
  46. DataTable dt = TubeRoll.GetComBaseInfo("411001", ob);
  47. ultraType.DataSource = dt;
  48. ultraType.ValueMember = "BASECODE";
  49. ultraType.DisplayMember = "BASENAME";
  50. TubeRoll.SetComboItemHeight(ultraType);
  51. //部门
  52. DataTable dt2 = TubeRoll.GetComBaseInfo("411002", ob);
  53. ultraDepartname.DataSource = dt2;
  54. ultraDepartname.ValueMember = "BASECODE";
  55. ultraDepartname.DisplayMember = "BASENAME";
  56. TubeRoll.SetComboItemHeight(ultraDepartname);
  57. //项目
  58. DataTable dt3 = TubeRoll.GetComBaseInfo("411003", ob);
  59. ultraProject.DataSource = dt3;
  60. ultraProject.ValueMember = "BASECODE";
  61. ultraProject.DisplayMember = "BASENAME";
  62. TubeRoll.SetComboItemHeight(ultraProject);
  63. DoQuery();
  64. }
  65. /// <summary>
  66. /// 重写基类方法
  67. /// </summary>
  68. /// <param name="sender"></param>
  69. /// <param name="ToolbarKey"></param>
  70. public override void ToolBar_Click(object sender, string ToolbarKey)
  71. {
  72. switch (ToolbarKey)
  73. {
  74. case "Query":
  75. DoQuery();
  76. break;
  77. case "Add":
  78. DoAdd();
  79. break;
  80. case "Delete":
  81. DoDelete();
  82. break;
  83. case "Update":
  84. DoUpdare();
  85. break;
  86. case "Close":
  87. this.Close();
  88. break;
  89. }
  90. }
  91. /// <summary>
  92. /// 查询
  93. /// </summary>
  94. private void DoQuery()
  95. {
  96. //DataTable dt = ServerHelper.GetData("com.steering.mes.signature.FrmReportManage.queryReportManage", new Object[] { plineCode, this.UserInfo.GetUserName() }, ob);
  97. //GridHelper.CopyDataToDatatable(dt, this.dataTable1, true);
  98. List<ComBaseQualityObjectivesEntity> listSource = EntityHelper.GetData<ComBaseQualityObjectivesEntity>(
  99. "com.steering.mes.signature.FrmQualityObjectives.doQueryData", new object[] { "1"}, this.ob);
  100. bindingSource1.DataSource = listSource;
  101. // GridHelper.RefreshAndAutoSize(this.ultraGrid1);
  102. }
  103. /// <summary>
  104. /// 新增
  105. /// </summary>
  106. private void DoAdd()
  107. {
  108. ultraGrid1.UpdateData();
  109. IQueryable<UltraGridRow> uGrid = ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  110. if (uGrid.Count() == 0)
  111. {
  112. MessageUtil.ShowTips("请选择要新增的数据!");
  113. return;
  114. }
  115. ArrayList parm = new ArrayList();
  116. foreach (UltraGridRow uRow in uGrid)
  117. {
  118. if (!StringUtil.IsInt(uRow.Cells["qqYear"].Text.ToString()))
  119. {
  120. MessageUtil.ShowTips("请输人正确的年份!");
  121. return;
  122. }
  123. ComBaseQualityObjectivesEntity qualityEntity = (ComBaseQualityObjectivesEntity)uRow.ListObject;
  124. qualityEntity.CreateName = this.UserInfo.GetUserName();
  125. qualityEntity.TypeDesc = uRow.Cells["typeCode"].Text.ToString();
  126. qualityEntity.Departname = uRow.Cells["departid"].Text.ToString();
  127. //qualityEntity.DepartmentDesc = uRow.Cells["departmentCode"].Text.ToString();
  128. qualityEntity.ProjectDesc = uRow.Cells["projectCode"].Text.ToString();
  129. string qualityTity = JSONFormat.Format(qualityEntity);
  130. parm.Add(qualityTity);
  131. }
  132. CoreClientParam ccp = new CoreClientParam();
  133. ccp.ServerName = "com.steering.mes.signature.FrmQualityObjectives";
  134. ccp.MethodName = "doAdd";
  135. ccp.ServerParams = new object[] { parm };
  136. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  137. if (ccp.ReturnCode != -1)
  138. {
  139. MessageUtil.ShowTips(ccp.ReturnInfo);
  140. if (ccp.ReturnInfo.Equals("新增成功!"))
  141. {
  142. DoQuery();
  143. }
  144. }
  145. }
  146. /// <summary>
  147. /// 作废
  148. /// </summary>
  149. private void DoDelete()
  150. {
  151. ultraGrid1.UpdateData();
  152. ArrayList pram1 = new ArrayList();
  153. IQueryable<UltraGridRow> uGrid = ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  154. if (uGrid.Count() == 0)
  155. {
  156. MessageUtil.ShowTips("请选择要作废的数据!");
  157. return;
  158. }
  159. if (MessageUtil.ShowYesNoAndQuestion("是否确认作废信息?") == System.Windows.Forms.DialogResult.No)
  160. {
  161. return;
  162. }
  163. foreach (UltraGridRow ugr in uGrid)
  164. {
  165. ArrayList pram = new ArrayList();
  166. pram.Add(this.UserInfo.GetUserName());
  167. pram.Add(ugr.Cells["sysGuid"].Value.ToString());
  168. pram1.Add(pram);
  169. }
  170. int countinsert = ServerHelper.SetData("com.steering.mes.signature.FrmQualityObjectives.doDelete", new Object[] { pram1 }, this.ob);
  171. if (countinsert > 0)
  172. {
  173. MessageUtil.ShowTips("作废成功!");
  174. }
  175. else
  176. {
  177. MessageUtil.ShowTips("作废失败!"); return;
  178. }
  179. DoQuery();
  180. }
  181. /// <summary>
  182. /// 修改
  183. /// </summary>
  184. private void DoUpdare()
  185. {
  186. ultraGrid1.UpdateData();
  187. IQueryable<UltraGridRow> uGrid = ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  188. if (uGrid.Count() == 0)
  189. {
  190. MessageUtil.ShowTips("请选择修改的数据!");
  191. return;
  192. }
  193. ArrayList parm = new ArrayList();
  194. foreach (UltraGridRow uRow in uGrid)
  195. {
  196. if (!StringUtil.IsInt(uRow.Cells["qqYear"].Text.ToString()))
  197. {
  198. MessageUtil.ShowTips("请输人正确的年份!");
  199. return;
  200. }
  201. ComBaseQualityObjectivesEntity qualityEntity = (ComBaseQualityObjectivesEntity)uRow.ListObject;
  202. qualityEntity.UpdateName = this.UserInfo.GetUserName();
  203. qualityEntity.TypeDesc = uRow.Cells["typeCode"].Text.ToString();
  204. qualityEntity.Departname = uRow.Cells["departid"].Text.ToString();
  205. //qualityEntity.DepartmentDesc = uRow.Cells["departmentCode"].Text.ToString();
  206. qualityEntity.ProjectDesc = uRow.Cells["projectCode"].Text.ToString();
  207. string qualityTity = JSONFormat.Format(qualityEntity);
  208. parm.Add(qualityTity);
  209. }
  210. if (MessageUtil.ShowYesNoAndQuestion("是否修改?") == System.Windows.Forms.DialogResult.No) return;
  211. CoreClientParam ccp = new CoreClientParam();
  212. ccp.ServerName = "com.steering.mes.signature.FrmQualityObjectives";
  213. ccp.MethodName = "doUpdate";
  214. ccp.ServerParams = new object[] { parm };
  215. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  216. if (ccp.ReturnCode != -1)
  217. {
  218. MessageUtil.ShowTips(ccp.ReturnInfo);
  219. if (ccp.ReturnInfo.Equals("修改成功!"))
  220. {
  221. DoQuery();
  222. }
  223. }
  224. }
  225. private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
  226. {
  227. try
  228. {
  229. ultraGrid1.UpdateData();
  230. foreach (UltraGridRow r in ultraGrid1.Rows)
  231. {
  232. r.Cells["CHK"].Value = r.Selected;
  233. }
  234. }
  235. catch { }
  236. }
  237. private void ultraDepartment_EditorButtonClick(object sender, EditorButtonEventArgs e)
  238. {
  239. UltraGridRow row = ultraGrid1.ActiveRow;
  240. if (row == null) return;
  241. string departid = row.Cells["departid"].Value.ToString();
  242. FrmDepartment fpdc = new FrmDepartment(departid, ob);
  243. fpdc.AutoSize = true;
  244. fpdc.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  245. fpdc.Text = "单位";
  246. fpdc.ShowDialog();
  247. if (fpdc.DialogResult == System.Windows.Forms.DialogResult.OK)
  248. {
  249. //获取弹出窗体的属性值
  250. row.Cells["departmentDesc"].Value = fpdc.Basename;
  251. row.Cells["departmentCode"].Value = fpdc.Basecode;
  252. }
  253. }
  254. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  255. {
  256. UltraGridRow row = ultraGrid1.ActiveRow;
  257. if (row.Cells["qqYear"].Value.ToString() == "")
  258. {
  259. row.Cells["qqYear"].Value = year;
  260. }
  261. }
  262. }
  263. }