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

98 lines
3.3 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. using ICSSoft.Base.Config.DBHelper;
  11. namespace ICSSoft.Frame.Data.DAL
  12. {
  13. public class ICSOP2RESDAL
  14. {
  15. #region AddandEdit
  16. public static void AddandEdit(DataTable dt,string opid,string code, string Appconstr)
  17. {
  18. FramDataContext db = new FramDataContext(Appconstr);
  19. db.Connection.Open();
  20. db.Transaction = db.Connection.BeginTransaction();
  21. try
  22. {
  23. int seq = 0;
  24. string sql = @"SELECT MAX(RESSEQ) as RESSEQ FROM dbo.ICSOP2RES WHERE OPID='{0}'";
  25. sql = string.Format(sql,opid);
  26. DataTable seqDt = DBHelper.ExecuteDataset(Appconstr,CommandType.Text,sql).Tables[0];
  27. if (seqDt.Rows[0]["RESSEQ"].ToString()!="")
  28. {
  29. seq = int.Parse(seqDt.Rows[0]["RESSEQ"].ToString());
  30. }
  31. for (int i = 0; i < dt.Rows.Count; i++)
  32. {
  33. seq++;
  34. ICSOP2RES lines = new ICSOP2RES();
  35. lines.OPID = opid;
  36. lines.RESID = dt.Rows[i]["ID"].ToString();
  37. lines.OPCODE = code;
  38. lines.RESCODE = dt.Rows[i]["资源代码"].ToString();
  39. lines.RESSEQ = seq;
  40. lines.MUSER = AppConfig.UserId;
  41. lines.MUSERName = AppConfig.UserName;
  42. lines.WorkPoint = AppConfig.WorkPointCode;
  43. lines.MTIME = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString();
  44. db.ICSOP2RES.InsertOnSubmit(lines);
  45. }
  46. db.SubmitChanges();
  47. db.Transaction.Commit();
  48. }
  49. catch (Exception ex)
  50. {
  51. db.Transaction.Rollback();
  52. throw new Exception(ex.Message);
  53. }
  54. }
  55. #endregion
  56. #region delete
  57. public static void delete(List<String> guidList,string conn)
  58. {
  59. FramDataContext db = new FramDataContext(conn);
  60. db.Connection.Open();
  61. db.Transaction = db.Connection.BeginTransaction();
  62. try
  63. {
  64. var line = db.ICSOP2RES.Where(a => guidList.Contains(a.RESID));
  65. db.ICSOP2RES.DeleteAllOnSubmit(line);
  66. db.SubmitChanges();
  67. db.Transaction.Commit();
  68. }
  69. catch (Exception ex)
  70. {
  71. db.Transaction.Rollback();
  72. throw ex;
  73. }
  74. }
  75. #endregion
  76. public static void Edit(List<string> idList, List<string> seqList)
  77. {
  78. try
  79. {
  80. for(int i=0;i<idList.Count;i++){
  81. string sql = @"UPDATE dbo.ICSOP2RES SET RESSEQ='{0}' WHERE RESID='{1}'";
  82. sql = string.Format(sql,seqList[i],idList[i]);
  83. DBHelper.ExecuteNonQuery(AppConfig.AppConnectString,CommandType.Text,sql);
  84. }
  85. }
  86. catch (Exception ex)
  87. {
  88. throw ex;
  89. }
  90. }
  91. }
  92. }