华恒Mes鼎捷代码
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.

115 lines
4.1 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. using ICSSoft.Base.Config.AppConfig;
  7. using System.Data;
  8. using ICSSoft.Base.Config.DBHelper;
  9. namespace ICSSoft.Frame.Data.DAL
  10. {
  11. public class ICSITEMROUTE2OPDAL
  12. {
  13. #region 删除
  14. public static void deleteInfo(List<string> codeList, string dsconn)
  15. {
  16. FramDataContext db = new FramDataContext(dsconn);
  17. db.Connection.Open();
  18. db.Transaction = db.Connection.BeginTransaction();
  19. try
  20. {
  21. var lines = db.ICSITEMROUTE2OP.Where(a => codeList.Contains(a.OPCODE));
  22. db.ICSITEMROUTE2OP.DeleteAllOnSubmit(lines);
  23. db.SubmitChanges();
  24. db.Transaction.Commit();
  25. }
  26. catch (Exception ex)
  27. {
  28. db.Transaction.Rollback();
  29. throw ex;
  30. }
  31. }
  32. #endregion
  33. #region 新增和修改
  34. public static void Add(List<FormICSITEMROUTE2OPUIModel> InfoList, string dsconn)
  35. {
  36. FramDataContext db = new FramDataContext(dsconn);
  37. db.Connection.Open();
  38. db.Transaction = db.Connection.BeginTransaction();
  39. try
  40. {
  41. foreach (FormICSITEMROUTE2OPUIModel info in InfoList)
  42. {
  43. //bool isNew = false;
  44. //var line = db.ICSITEMROUTE2OP.SingleOrDefault(a => a.OPCODE == tbinfo.OPCODE);
  45. //if (line == null)
  46. //{
  47. // isNew = true;
  48. // line = new ICSOP();
  49. // line.ID = AppConfig.GetGuid();
  50. // line.OPCODE = tbinfo.OPCODE;
  51. //}
  52. var line = db.ICSITEMROUTE2OP.SingleOrDefault(a => a.ITEMCODE == info.ITEMCODE && a.ROUTECODE == info.ROUTECODE && a.OPCODE == info.OPCODE);
  53. line.OPCONTROL = info.ro.OPCONTROL;
  54. line.OPTIONALOP = info.OPTIONALOP;
  55. line.IDMERGETYPE = info.IDMERGETYPE;
  56. line.IDMERGERULE = Convert.ToInt32(info.IDMERGERULE);
  57. line.MUSER = AppConfig.UserId;
  58. line.MUSERName = AppConfig.UserName;
  59. line.MTIME = DateTime.Now;
  60. line.WorkPoint = AppConfig.WorkPointCode;
  61. //if (isNew)
  62. // db.ICSOP.InsertOnSubmit(line);
  63. db.SubmitChanges();
  64. }
  65. db.Transaction.Commit();
  66. }
  67. catch (Exception ex)
  68. {
  69. db.Transaction.Rollback();
  70. throw ex;
  71. }
  72. }
  73. #endregion
  74. //0819 GJ lin ye 的自动分批
  75. #region 根据工艺路线编码和产品编码获取工序信息
  76. public static List<ICSITEMROUTE2OP> selectinfobycode(string ItemCode, string RouteCode, string dsconn)
  77. {
  78. try
  79. {
  80. List<ICSITEMROUTE2OP> infolist = new List<ICSITEMROUTE2OP>();
  81. string sql = @"select ITEMCODE,ROUTECODE,OPCODE,OPSEQ from ICSITEMROUTE2OP
  82. WHERE ITEMCODE='{0}' AND ROUTECODE='{1}'
  83. AND WorkPoint='{2}'";
  84. sql = string.Format(sql, ItemCode, RouteCode, AppConfig.WorkPointCode);
  85. DataTable dt = DBHelper.ExecuteDataset(dsconn, CommandType.Text, sql).Tables[0];
  86. for (int i = 0; i < dt.Rows.Count; i++)
  87. {
  88. ICSITEMROUTE2OP info = new ICSITEMROUTE2OP();
  89. info.ITEMCODE = dt.Rows[i]["ITEMCODE"].ToString();
  90. info.ROUTECODE = dt.Rows[i]["ROUTECODE"].ToString();
  91. info.OPCODE = dt.Rows[i]["OPCODE"].ToString();
  92. info.OPSEQ = Convert.ToInt32(dt.Rows[i]["OPSEQ"].ToString());
  93. infolist.Add(info);
  94. }
  95. return infolist;
  96. }
  97. catch (Exception ex)
  98. {
  99. throw ex;
  100. }
  101. }
  102. #endregion
  103. }
  104. }