锐腾搅拌上料功能
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
3.9 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using ICSSoft.Frame.Data.Entity;
  6. namespace ICSSoft.Frame.Data.DAL
  7. {
  8. public class ICSEqpSuspendDetailDAL
  9. {
  10. public static void Begin(Entity.ICSEqpSuspendDetail info, string conn)
  11. {
  12. FramDataContext db = new FramDataContext(conn);
  13. db.Connection.Open();
  14. db.Transaction = db.Connection.BeginTransaction();
  15. try
  16. {
  17. int i = db.ICSEqpSuspendDetail.Where(a => a.PAUSEID == info.PAUSEID && a.BeginTime != null && a.EndTime == null).Count();
  18. if (i > 0)
  19. {
  20. throw new Exception("本次暂停过程中,上次调机未结束, 你的账号是否在多处登录报工界面并对同一[跟踪单-工序]进行操作?请退出所有此[跟踪单-工序]的报工,重新登陆");
  21. }
  22. db.ICSEqpSuspendDetail.InsertOnSubmit(info);
  23. db.SubmitChanges();
  24. db.Transaction.Commit();
  25. }
  26. catch (Exception ex)
  27. {
  28. db.Transaction.Rollback();
  29. throw new Exception(ex.Message);
  30. }
  31. finally
  32. {
  33. db.Connection.Close();
  34. }
  35. }
  36. public static void End(Entity.ICSEqpSuspendDetail info, string conn)
  37. {
  38. FramDataContext db = new FramDataContext(conn);
  39. db.Connection.Open();
  40. db.Transaction = db.Connection.BeginTransaction();
  41. try
  42. {
  43. var line = db.ICSEqpSuspendDetail.SingleOrDefault(a => a.LOTNO == info.LOTNO
  44. && a.ROUTECODE == info.ROUTECODE
  45. && a.OPCODE == info.OPCODE
  46. && a.OPUserCode == info.OPUserCode
  47. && a.SuspendState == "BEGIN"
  48. && a.WorkPoint == info.WorkPoint
  49. );
  50. line.EndTime = info.EndTime;
  51. line.SuspendState = info.SuspendState;
  52. db.SubmitChanges();
  53. db.Transaction.Commit();
  54. }
  55. catch (Exception ex)
  56. {
  57. db.Transaction.Rollback();
  58. throw new Exception(ex.Message);
  59. }
  60. }
  61. public static void EndSus(Entity.ICSEqpSuspendDetail info, string conn)
  62. {
  63. FramDataContext db = new FramDataContext(conn);
  64. db.Connection.Open();
  65. db.Transaction = db.Connection.BeginTransaction();
  66. try
  67. {
  68. var line = db.ICSEqpSuspendDetail.SingleOrDefault(a => a.ID == info.ID && a.SuspendState == "BEGIN");
  69. if (line != null)
  70. {
  71. line.EndTime = info.EndTime;
  72. line.SuspendState = info.SuspendState;
  73. db.SubmitChanges();
  74. }
  75. db.Transaction.Commit();
  76. }
  77. catch (Exception ex)
  78. {
  79. db.Transaction.Rollback();
  80. throw new Exception(ex.Message);
  81. }
  82. finally
  83. {
  84. db.Connection.Close();
  85. }
  86. }
  87. public static void End(string ID, string conn)
  88. {
  89. FramDataContext db = new FramDataContext(conn);
  90. db.Connection.Open();
  91. db.Transaction = db.Connection.BeginTransaction();
  92. try
  93. {
  94. var line = db.ICSEqpSuspendDetail.SingleOrDefault(a => a.ID == ID);
  95. line.EndTime = DateTime.Now;
  96. line.SuspendState = "END";
  97. db.SubmitChanges();
  98. db.Transaction.Commit();
  99. }
  100. catch (Exception ex)
  101. {
  102. db.Transaction.Rollback();
  103. throw new Exception(ex.Message);
  104. }
  105. finally
  106. {
  107. db.Connection.Close();
  108. }
  109. }
  110. }
  111. }