FrmOfflineProcessAudit.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. using com.steering.mes.zgmil.entity;
  2. using Core.Mes.Client.Comm.Control;
  3. using Core.Mes.Client.Comm.Format;
  4. using Core.Mes.Client.Comm.Server;
  5. using Core.Mes.Client.Comm.Tool;
  6. using Core.StlMes.Client.ZGMil.Common;
  7. using Core.StlMes.Client.ZGMil.Entity;
  8. using Core.StlMes.Client.ZGMil.NodeResultQuery;
  9. using Core.StlMes.Client.ZGMil.Popup;
  10. using Core.StlMes.Client.ZGMil.Report;
  11. using Core.StlMes.Client.ZGMil.ResultConrtrol;
  12. using CoreFS.CA06;
  13. using Infragistics.Win.UltraWinGrid;
  14. using System;
  15. using System.Collections;
  16. using System.Collections.Generic;
  17. using System.ComponentModel;
  18. using System.Data;
  19. using System.Drawing;
  20. using System.Linq;
  21. using System.Text;
  22. using System.Windows.Forms;
  23. namespace Core.StlMes.Client.ZGMil.Signature
  24. {
  25. public partial class FrmOfflineProcessAudit : FrmBase
  26. {
  27. public FrmOfflineProcessAudit()
  28. {
  29. InitializeComponent();
  30. EntityHelper.ShowGridCaption<OfflineProcessAuditEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  31. }
  32. /// <summary>
  33. /// 重写基类方法
  34. /// </summary>
  35. /// <param name="sender"></param>
  36. /// <param name="ToolbarKey"></param>
  37. public override void ToolBar_Click(object sender, string ToolbarKey)
  38. {
  39. switch (ToolbarKey)
  40. {
  41. case "Query":
  42. doQuery();
  43. break;
  44. case "Audit1":
  45. doSave("1");
  46. break;
  47. case "Audit2":
  48. doSave("2");
  49. break;
  50. case "Audit3":
  51. doSave("3");
  52. break;
  53. case "Close":
  54. if (MessageUtil.ShowYesNoAndQuestion("是否确认关闭页面?") == DialogResult.Yes)
  55. {
  56. this.Close();
  57. }
  58. break;
  59. }
  60. }
  61. private void doQuery()
  62. {
  63. string StartTime = "";
  64. string EndTime = "";
  65. string isAudit = "";
  66. String id = "";
  67. if (ultraGrid1.ActiveRow != null) id = ultraGrid1.ActiveRow.Cells["ID"].Value.ToString();
  68. if (chkTim.Checked )
  69. {
  70. if (DateTime.Parse(startTime.Value.ToString()) > DateTime.Parse(endTime.Value.ToString()))
  71. {
  72. MessageUtil.ShowTips("选择的前面时间不能大于后面的时间!");
  73. return;
  74. }
  75. else
  76. {
  77. StartTime = this.startTime.Value.ToString("yyyy-MM-dd");
  78. EndTime = this.endTime.Value.ToString("yyyy-MM-dd");
  79. }
  80. }
  81. if (shr1.Checked)
  82. {
  83. isAudit = proc_chekedAudit(shr1.Checked, this.isAudit.Text.Trim());
  84. }
  85. dataSet1.Clear();
  86. this.dataTable1.Clear();
  87. this.dataTable2.Clear();
  88. DataTable dt = ServerHelper.GetData("com.steering.mes.signature.FrmOfflineProcessAudit.QueryOfflineProcessAudit", new object[] { StartTime, EndTime, isAudit }, ob);
  89. GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
  90. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  91. {
  92. if (ultraGrid1.Rows[i].Cells["ID"].Value.ToString().Equals(id))
  93. {
  94. ultraGrid1.ActiveRow = ultraGrid1.Rows[i];
  95. //ulgridSteelPlan.Rows[i].Selected = true;
  96. return;
  97. }
  98. //else
  99. //{
  100. // ulgridSteelPlan.ActiveRow = ulgridSteelPlan.Rows[i];
  101. // //ulgridSteelPlan.Rows[i].Selected = true;
  102. // return;
  103. //}
  104. }
  105. }
  106. private void FrmOfflineProcessAudit_Load(object sender, EventArgs e)
  107. {
  108. doQuery();
  109. }
  110. private void doSave(string ToolbarKey)
  111. {
  112. this.ultraGrid1.UpdateData();
  113. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  114. if (checkMagRows.Count() == 0)
  115. {
  116. MessageUtil.ShowTips("请选择需要提交的信息!");
  117. return;
  118. }
  119. ArrayList parmList = new ArrayList();
  120. foreach (UltraGridRow row in checkMagRows)
  121. {
  122. OfflineProcessAuditEntity entity = new OfflineProcessAuditEntity();
  123. if (String.IsNullOrEmpty(row.Cells["ID"].Value.ToString()))
  124. continue;
  125. if (ToolbarKey.Equals("1"))
  126. {
  127. entity.Id = row.Cells["id"].Value.ToString();
  128. entity.AuditDep2 = UserInfo.GetDepartment();
  129. entity.Memo2 = memo2.Text;
  130. entity.AuditMan2 = UserInfo.GetUserName();
  131. entity.AuditTime2 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  132. entity.AuditState2 = "1";
  133. entity.ResultNo = row.Cells["result_no"].Value.ToString();
  134. }
  135. if (ToolbarKey.Equals("2"))
  136. {
  137. entity.Id = row.Cells["ID"].Value.ToString();
  138. entity.AuditDep2 = "质保部";
  139. entity.Memo2 = memo2.Text;
  140. entity.AuditMan2 = UserInfo.GetUserName();
  141. entity.AuditTime2 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  142. entity.AuditState2 = "2";
  143. entity.ResultNo = row.Cells["result_no"].Value.ToString();
  144. }
  145. //entity.RecRevisor = UserInfo.GetUserName();
  146. string baseEntity = JSONFormat.Format(entity);
  147. parmList.Add(baseEntity);
  148. }
  149. if (parmList.Count > 0)
  150. {
  151. CoreClientParam ccp = new CoreClientParam();
  152. ccp.ServerName = "com.steering.mes.signature.FrmOfflineProcessAudit";
  153. ccp.MethodName = "doAddAudits";
  154. ccp.ServerParams = new object[] { parmList };
  155. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  156. if (ccp.ReturnCode != -1)
  157. {
  158. if (ccp.ReturnInfo.Equals("操作成功"))
  159. {
  160. // DoQueryInList();
  161. doQuery();
  162. MessageUtil.ShowTips(ccp.ReturnInfo);
  163. }
  164. else
  165. {
  166. MessageUtil.ShowTips(ccp.ReturnInfo);
  167. }
  168. }
  169. }
  170. //if (ToolbarKey.Equals("1"))
  171. //{
  172. // MessageUtil.ShowTips("质检标准类型不能为空!");
  173. // return;
  174. //}
  175. //if (text_inspectStandName.Text == null || text_inspectStandName.Text.Equals(""))
  176. //{
  177. // MessageUtil.ShowTips("质检标准名称不能为空!");
  178. // return;
  179. //}
  180. //if (text_standStartDate.Text == null || text_standStartDate.Text.Equals(""))
  181. //{
  182. // MessageUtil.ShowTips("标准开始日期不能为空!");
  183. // return;
  184. //}
  185. //if (text_standEndDate.Text == null || text_standEndDate.Text.Equals(""))
  186. //{
  187. // MessageUtil.ShowTips("标准结束日期不能为空!");
  188. // return;
  189. //}
  190. //if (text_elmCode.Text == null || text_elmCode.Text.Equals(""))
  191. //{
  192. // MessageUtil.ShowTips("元素代码不能为空!");
  193. // return;
  194. //}
  195. //if (text_elmName.Text == null || text_elmName.Text.Equals(""))
  196. //{
  197. // MessageUtil.ShowTips("元素名称不能为空!");
  198. // return;
  199. //}
  200. //Tpopi26Entity entity = new Tpopi26Entity();
  201. //entity.InspectStandType = text_inspectStandType.Text;
  202. //entity.InspectStandName = text_inspectStandName.Text;
  203. //entity.StandStartDate = text_standStartDate.DateTime.ToString("yyyymmddHHmmss");
  204. //entity.StandEndDate = text_standEndDate.DateTime.ToString("yyyymmddHHmmss");
  205. //entity.ElmCode = text_elmCode.Text;
  206. //entity.ElmName = text_elmName.Text;
  207. //entity.InspectStandShort = text_inspectStandShort.Text;
  208. //entity.InspectOperatType = text_InspectOperatType.Text;
  209. //entity.JdeLevel = text_jdeLevel.Text;
  210. //entity.InspectStandDesc = text_InspectStandDesc.Text;
  211. //entity.RecCreator = UserInfo.GetUserName();
  212. //entity.RecRevisor = UserInfo.GetUserName();
  213. //entity.InspectStandCode = text_InspectStandCode.Text;
  214. //string baseEntity = JSONFormat.Format(entity);
  215. //if (ToolbarKey.Equals("ADD"))
  216. //{
  217. // CoreClientParam ccp = new CoreClientParam();
  218. // ccp.ServerName = "com.steering.lims.data.pipe.Tpopi26";
  219. // ccp.MethodName = "doAdd";
  220. // ccp.ServerParams = new object[] { new ArrayList { baseEntity } };
  221. // ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  222. // if (ccp.ReturnCode != -1)
  223. // {
  224. // doQuery();
  225. // MessageUtil.ShowTips("新增成功!");
  226. // }
  227. //}
  228. //if (ToolbarKey.Equals("Update"))
  229. //{
  230. // CoreClientParam ccp = new CoreClientParam();
  231. // ccp.ServerName = "com.steering.lims.data.pipe.Tpopi26";
  232. // ccp.MethodName = "doUpdate";
  233. // ccp.ServerParams = new object[] { new ArrayList { baseEntity } };
  234. // ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  235. // if (ccp.ReturnCode != -1)
  236. // {
  237. // doQuery();
  238. // MessageUtil.ShowTips("保存成功!");
  239. // }
  240. //}
  241. }
  242. private string proc_chekedAudit(bool cheked, string str)
  243. {
  244. switch (str)
  245. {
  246. case "等待评审":
  247. return "0";
  248. case "开始评审":
  249. return "1";
  250. case "评审通过":
  251. return "2";
  252. default:
  253. return "";
  254. }
  255. }
  256. private void doUpdate()
  257. {
  258. //this.ultraGrid1.UpdateData();
  259. //IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  260. //if (checkMagRows.Count() == 0)
  261. //{
  262. // MessageUtil.ShowTips("请选择需要修改的信息!");
  263. // return;
  264. //}
  265. //ArrayList parmList = new ArrayList();
  266. //foreach (UltraGridRow row in checkMagRows)
  267. //{
  268. // Tpopi26Entity entity = row.ListObject as Tpopi26Entity;
  269. // if (String.IsNullOrEmpty(entity.InspectStandCode) || String.IsNullOrEmpty(entity.JdeLevel) || String.IsNullOrEmpty(entity.ElmCode))
  270. // continue;
  271. // //entity.RecRevisor = UserInfo.GetUserName();
  272. // string baseEntity = JSONFormat.Format(entity);
  273. // parmList.Add(baseEntity);
  274. //}
  275. //if (parmList.Count > 0)
  276. //{
  277. // CoreClientParam ccp = new CoreClientParam();
  278. // ccp.ServerName = "com.steering.lims.data.pipe.Tpopi26";
  279. // ccp.MethodName = "doUpdate";
  280. // ccp.ServerParams = new object[] { parmList };
  281. // ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  282. // if (ccp.ReturnCode != -1)
  283. // {
  284. // doQuery();
  285. // MessageUtil.ShowTips("修改成功!");
  286. // }
  287. //}
  288. }
  289. private void doDelete()
  290. {
  291. //this.ultraGrid1.UpdateData();
  292. //IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  293. //if (checkMagRows.Count() == 0)
  294. //{
  295. // MessageUtil.ShowTips("请选择需要删除的信息!");
  296. // return;
  297. //}
  298. //ArrayList parmList = new ArrayList();
  299. //foreach (UltraGridRow row in checkMagRows)
  300. //{
  301. // Tpopi26Entity entity = row.ListObject as Tpopi26Entity;
  302. // if (String.IsNullOrEmpty(entity.InspectStandCode) || String.IsNullOrEmpty(entity.JdeLevel) || String.IsNullOrEmpty(entity.ElmCode))
  303. // continue;
  304. // string baseEntity = JSONFormat.Format(entity);
  305. // parmList.Add(baseEntity);
  306. //}
  307. //if (parmList.Count > 0)
  308. //{
  309. // CoreClientParam ccp = new CoreClientParam();
  310. // ccp.ServerName = "com.steering.lims.data.pipe.Tpopi26";
  311. // ccp.MethodName = "doDelete";
  312. // ccp.ServerParams = new object[] { parmList };
  313. // ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  314. // if (ccp.ReturnCode != -1)
  315. // {
  316. // doQuery();
  317. // MessageUtil.ShowTips("删除成功!");
  318. // }
  319. //}
  320. }
  321. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  322. {
  323. //try
  324. //{
  325. // if (ultraGrid1.ActiveRow == null)
  326. // return;
  327. // Infragistics.Win.UltraWinGrid.UltraGridRow ulRow = ultraGrid1.ActiveRow;
  328. // text_inspectStandType.Text = Convert.ToString(ulRow.Cells["InspectStandType"].Value);
  329. // text_inspectStandName.Text = Convert.ToString(ulRow.Cells["InspectStandName"].Value);
  330. // text_inspectStandShort.Text = Convert.ToString(ulRow.Cells["InspectStandShort"].Value);
  331. // text_InspectStandCode.Text = Convert.ToString(ulRow.Cells["InspectStandCode"].Value);
  332. // text_InspectOperatType.Text = Convert.ToString(ulRow.Cells["InspectOperatType"].Value);
  333. // text_jdeLevel.Text = Convert.ToString(ulRow.Cells["JdeLevel"].Value);
  334. // text_standStartDate.Text = Convert.ToString(ulRow.Cells["StandStartDate"].Value);
  335. // text_standEndDate.Text = Convert.ToString(ulRow.Cells["StandEndDate"].Value);
  336. // text_InspectStandDesc.Text = Convert.ToString(ulRow.Cells["InspectStandDesc"].Value);
  337. // text_elmCode.Text = Convert.ToString(ulRow.Cells["ElmCode"].Value);
  338. // text_elmName.Text = Convert.ToString(ulRow.Cells["ElmName"].Value);
  339. // // text_inspectStandCode.Text = Convert.ToString(ulRow.Cells["InspectStandCode"].Value);
  340. //}
  341. //catch (Exception ex)
  342. //{
  343. // MessageBox.Show(ex.Message, "提示");
  344. //}
  345. }
  346. private void ultraGrid1_AfterRowExpanded(object sender, RowEventArgs e)
  347. {
  348. e.Row.Activated = true;
  349. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  350. {
  351. if (ultraGrid1.Rows[i].Expanded == true && ultraGrid1.Rows[i].Activated == false)
  352. {
  353. ultraGrid1.Rows[i].Expanded = false;
  354. }
  355. }
  356. string id = e.Row.Cells["ID"].Value.ToString();
  357. DataTable dt = ServerHelper.GetData("com.steering.mes.signature.FrmOfflineProcessAudit.QueryOfflineAudit", new object[] { id }, ob);
  358. GridHelper.CopyDataToDatatable(ref dt, ref dataTable2, true);
  359. for (int idx = this.dataTable2.Rows.Count - 1; idx >= 0; idx--)
  360. {
  361. if (Convert.ToString(this.dataTable2.Rows[idx]["ID"]) == id)
  362. this.dataTable2.Rows[idx].Delete();
  363. }
  364. this.dataTable2.AcceptChanges();
  365. DataRow newRow = null;
  366. foreach (DataRow row in dt.Rows)
  367. {
  368. newRow = this.dataTable2.NewRow();
  369. foreach (DataColumn col in dt.Columns)
  370. {
  371. if (this.dataTable2.Columns.Contains(col.ColumnName))
  372. newRow[col.ColumnName] = row[col.ColumnName];
  373. }
  374. this.dataTable2.Rows.Add(newRow);
  375. }
  376. this.dataTable2.AcceptChanges();
  377. //ClsControlPack.RefreshAndAutoSize(ulgridSteelPlan);
  378. }
  379. }
  380. }