锐腾搅拌上料功能
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.

109 lines
3.5 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 System.Data.Sql;
  9. using System.Data.Linq;
  10. namespace ICSSoft.Frame.Data.DAL
  11. {
  12. public class ICSSOLUTIONDAL
  13. {
  14. #region AddandEdit
  15. public static void AddandEdit(ICSSOLUTION ItemLot, string Appconstr)
  16. {
  17. FramDataContext db = new FramDataContext(Appconstr);
  18. db.Connection.Open();
  19. db.Transaction = db.Connection.BeginTransaction();
  20. try
  21. {
  22. bool isNew = false;
  23. var line = db.ICSSOLUTION.SingleOrDefault(a => a.ID == ItemLot.ID);
  24. if (line == null)
  25. {
  26. isNew = true;
  27. line = new ICSSOLUTION();
  28. line.ID = AppConfig.GetGuid();
  29. }
  30. var codes = db.ICSSOLUTION.Where(a => a.SOLCODE == ItemLot.SOLCODE && a.ID != line.ID);
  31. if (codes.ToList().Count > 0)
  32. {
  33. throw new Exception("解决方案代码已存在");
  34. }
  35. line.SOLCODE = ItemLot.SOLCODE;
  36. line.SOLDESC = ItemLot.SOLDESC;
  37. line.SOLIMP = ItemLot.SOLIMP;
  38. line.MUSER = ItemLot.MUSER;
  39. line.MUSERName = ItemLot.MUSERName;
  40. line.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
  41. line.WorkPoint = AppConfig.WorkPointCode;
  42. if (isNew) db.ICSSOLUTION.InsertOnSubmit(line);
  43. db.SubmitChanges();
  44. db.Transaction.Commit();
  45. }
  46. catch (Exception ex)
  47. {
  48. db.Transaction.Rollback();
  49. throw new Exception(ex.Message);
  50. }
  51. }
  52. #endregion
  53. #region select
  54. public static ICSSOLUTION select(String guid, String Appconstr)
  55. {
  56. FramDataContext db = new FramDataContext(Appconstr);
  57. db.Connection.Open();
  58. db.Transaction = db.Connection.BeginTransaction();
  59. ICSSOLUTION entity = new ICSSOLUTION();
  60. try
  61. {
  62. var line = db.ICSSOLUTION.SingleOrDefault(a => a.ID == guid);
  63. return (ICSSOLUTION)line;
  64. }
  65. catch (Exception ex)
  66. {
  67. throw new Exception(ex.Message);
  68. }
  69. }
  70. #endregion
  71. #region delete
  72. public static void delete(List<String> guidList,List<string> codeList)
  73. {
  74. FramDataContext db = new FramDataContext(AppConfig.AppConnectString);
  75. db.Connection.Open();
  76. db.Transaction = db.Connection.BeginTransaction();
  77. try
  78. {
  79. var lines = db.ICSSOLUTION.Where(a => guidList.Contains(a.ID));
  80. //var line = db.ICSECG2EC.Where(a => codeList.Contains(a.ECODE));
  81. //if (line.Count() != 0)
  82. //{
  83. // throw new Exception("该不良代码在不良代码组与不良代码关系维护中已经使用,无法删除!");
  84. //}
  85. db.ICSSOLUTION.DeleteAllOnSubmit(lines);
  86. db.SubmitChanges();
  87. db.Transaction.Commit();
  88. }
  89. catch (Exception ex)
  90. {
  91. db.Transaction.Rollback();
  92. throw ex;
  93. }
  94. }
  95. #endregion
  96. }
  97. }