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

100 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.DBHelper;
  7. using System.Data;
  8. using System.Data.SqlClient;
  9. using ICSSoft.Base.Config.AppConfig;
  10. using ICSSoft.Frame.APP.Entity;
  11. namespace ICSSoft.Frame.Data.DAL
  12. {
  13. public class ICSOPHoursDAL
  14. {
  15. #region 新增和修改List
  16. public static string AddList(List<ICSHoursCost> InfoList, string dsconn)
  17. {
  18. FramDataContext db = new FramDataContext(dsconn);
  19. db.Connection.Open();
  20. db.Transaction = db.Connection.BeginTransaction();
  21. try
  22. {
  23. string str = "";
  24. string ID = "";
  25. foreach (ICSHoursCost info in InfoList)
  26. {
  27. if (ID != info.Organization + info.CostCenter + info.Month)
  28. {
  29. ID = info.Organization + info.CostCenter + info.Month;
  30. var lines = db.ICSHoursCost.Where(a => a.Organization + a.CostCenter + a.Month == ID);
  31. ICSHoursCost first = lines.FirstOrDefault();
  32. if (first != null && first.Status)
  33. {
  34. throw new Exception("已审核不能修改!");
  35. }
  36. db.ICSHoursCost.DeleteAllOnSubmit(lines);
  37. }
  38. ICSHoursCost line = new ICSHoursCost();
  39. line.ID = AppConfig.GetGuid();
  40. line.Status = false;
  41. line.Organization = info.Organization;
  42. line.CostCenter = info.CostCenter;
  43. line.Month = info.Month;
  44. line.Hours = info.Hours;
  45. line.Type = info.Type;
  46. line.Cost = info.Cost;
  47. line.MUSER = info.MUSER;
  48. line.MUSERNAME = info.MUSERNAME;
  49. line.MTIME = info.MTIME;
  50. line.WorkPoint = info.WorkPoint;
  51. line.EATTRIBUTE1 = info.EATTRIBUTE1;
  52. db.ICSHoursCost.InsertOnSubmit(line);
  53. db.SubmitChanges();
  54. }
  55. db.Transaction.Commit();
  56. return str;
  57. }
  58. catch (Exception ex)
  59. {
  60. db.Transaction.Rollback();
  61. throw ex;
  62. }
  63. }
  64. #endregion
  65. #region 审核
  66. public static void checkInfo(List<string> codeList,bool status, string dsconn)
  67. {
  68. FramDataContext db = new FramDataContext(dsconn);
  69. db.Connection.Open();
  70. db.Transaction = db.Connection.BeginTransaction();
  71. try
  72. {
  73. var lines = db.ICSHoursCost.Where(a => codeList.Contains(a.Organization + a.CostCenter+a.Month));
  74. foreach (var line in lines)
  75. {
  76. if (line.Status && status)
  77. throw new Exception("选中行已审核,不能再次审核!");
  78. else if (!line.Status && !status)
  79. throw new Exception("选中行未审核,不能弃审!");
  80. line.Status = status;
  81. }
  82. db.SubmitChanges();
  83. db.Transaction.Commit();
  84. }
  85. catch (Exception ex)
  86. {
  87. db.Transaction.Rollback();
  88. throw ex;
  89. }
  90. }
  91. #endregion
  92. }
  93. }