PurPlanDAL.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. using Common.Model;
  2. using Common.Wechat;
  3. using CoreEntity.Entity;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Data.SqlClient;
  8. using System.Text;
  9. using ZcPeng.PublicLibrary;
  10. namespace CoreEntity.DAL
  11. {
  12. public class PurPlanDAL
  13. {
  14. public static List<PurPlanDT> GetPlanDT(int BillNo,string PushFeedbackId)
  15. {
  16. #region 获取 plan
  17. string commandTextContact = "Select * From PurPlanDT " +
  18. "Where PushFeedbackId = @PushFeedbackId " +
  19. " and BillNo = @BillNo";
  20. string resultContact;
  21. DataTable dt = new DataTable();
  22. List<PurPlanDT> feedbacks = new List<PurPlanDT>();
  23. List<List<Object>> parametersContact = new List<List<Object>>();
  24. if (PushFeedbackId != null)
  25. {
  26. parametersContact.Add(new List<Object>() { "PushFeedbackId",PushFeedbackId });
  27. parametersContact.Add(new List<Object>() { "BillNo", BillNo });
  28. DataAccess.GetValues(commandTextContact, ref dt, DataAccess.ToParameters(parametersContact).ToArray(), out resultContact);
  29. }
  30. if(dt!=null && dt.Rows.Count > 0)
  31. {
  32. feedbacks = (List<PurPlanDT>)ModelConvertHelper<PurPlanDT>.ConvertToModel(dt);
  33. }
  34. #endregion
  35. return feedbacks;
  36. }
  37. public static List<PurPlanMT> GetPlanMT(string PushRecordId, string PushFeedbackId, Int32 PushAccountId,string SuppliersId)
  38. {
  39. #region 获取 plan
  40. string commandTextContact = "Select * From PurPlanMT " +
  41. " Where PushRecordId = @PushRecordId " +
  42. " and BillState = 0 " +
  43. " and PurObj = @PushAccountId" +
  44. " and SuppliersId = @SuppliersId "
  45. //+" and PushFeedBackId in ( select Id from " + Config.TablePrefix+ "PushFeedback B " +
  46. //" where 1= 1" +
  47. //" and state = 3 " +
  48. //" and B.Id = @PushFeedbackId " +
  49. //" and B.SuppliersId = @SuppliersId" +
  50. //") "
  51. ;
  52. string resultContact;
  53. DataTable dt = new DataTable();
  54. List<PurPlanMT> feedbacks = new List<PurPlanMT>(0);
  55. List<List<Object>> parametersContact = new List<List<Object>>();
  56. if (PushRecordId != null)
  57. {
  58. //parametersContact.Add(new List<Object>() { "PushFeedbackId", Guid.Parse(PushFeedbackId) });
  59. parametersContact.Add(new List<Object>() { "PushRecordId", Guid.Parse(PushRecordId) });
  60. parametersContact.Add(new List<Object>() { "PushAccountId", PushAccountId });
  61. parametersContact.Add(new List<Object>() { "SuppliersId", SuppliersId });
  62. DataAccess.GetValues(commandTextContact, ref dt, DataAccess.ToParameters(parametersContact).ToArray(), out resultContact);
  63. }
  64. if (dt != null && dt.Rows.Count > 0)
  65. {
  66. feedbacks = (List<PurPlanMT>)ModelConvertHelper<PurPlanMT>.ConvertToModel(dt);
  67. }
  68. #endregion
  69. return feedbacks;
  70. }
  71. //IsComplete 1
  72. public static int UpdateRecordPlanState(string RecordId, string LoginAccountId,out string resultState)
  73. {
  74. int accountid = Convert.ToInt32(LoginAccountId);
  75. #region 更新记录
  76. string commandTextFeed = "UPDATE " + Config.TablePrefix + "PushRecord " +
  77. " SET IsComplete = @IsComplete, " +
  78. " ConfirmPuchaseTime = @ConfirmPuchaseTime," +
  79. " ConfirmPuchaser = @ConfirmPuchaser," +
  80. " State = 3 " +
  81. " WHERE Id= @RecordId AND (IsComplete IS NULL OR IsComplete = 0 ) ";
  82. string resultFeed;
  83. //准备参数
  84. List<List<Object>> parametersFeed = new List<List<Object>>();
  85. parametersFeed.Add(new List<Object>() { "RecordId", Guid.Parse(RecordId) });
  86. parametersFeed.Add(new List<Object>() { "IsComplete", 1 });
  87. parametersFeed.Add(new List<Object>() { "ConfirmPuchaseTime", DateTime.Now });
  88. parametersFeed.Add(new List<Object>() { "ConfirmPuchaser", accountid });
  89. List<SqlParameter> parametersFeed1 = DataAccess.ToParameters(parametersFeed);
  90. int successFeed = DataAccess.ExecuteCommand(commandTextFeed, parametersFeed1, out resultFeed);
  91. resultState = resultFeed;
  92. #endregion
  93. return successFeed;
  94. }
  95. //IsComplete 1
  96. public static int UpdatePlanState(string FeedbackId,string RecordId,string LoginAccountId,out string result ,string fieldExt="")
  97. {
  98. int accountid = Convert.ToInt32(LoginAccountId);
  99. //#region 更新记录
  100. //string commandTextFeed = "UPDATE " + Config.TablePrefix + "PushRecord " +
  101. // " SET IsComplete = @IsComplete, " +
  102. // " ConfirmPuchaseTime = @ConfirmPuchaseTime," +
  103. // " ConfirmPuchaser = @ConfirmPuchaser," +
  104. // " State = 3 " +
  105. // " WHERE Id= @RecordId AND (IsComplete = 0 ) ";
  106. //string resultFeed;
  107. ////准备参数
  108. //List<List<Object>> parametersFeed = new List<List<Object>>();
  109. //parametersFeed.Add(new List<Object>() { "RecordId", RecordId });
  110. //parametersFeed.Add(new List<Object>() { "IsComplete", 1 });
  111. //parametersFeed.Add(new List<Object>() { "ConfirmPuchaseTime", DateTime.Now });
  112. //parametersFeed.Add(new List<Object>() { "ConfirmPuchaser", accountid });
  113. //List<SqlParameter> parametersFeed1 = DataAccess.ToParameters(parametersFeed);
  114. //int successFeed = DataAccess.ExecuteCommand(commandTextFeed, parametersFeed1, out resultFeed);
  115. //#endregion
  116. #region 更新明细
  117. string commandTextRecord = "UPDATE " + Config.TablePrefix + "PushFeedback " +
  118. " SET " +
  119. " IsComplete = @IsComplete, " +
  120. " ConfirmPuchaseTime = @ConfirmPuchaseTime," +
  121. " ConfirmPuchaser = @ConfirmPuchaser," +
  122. fieldExt+
  123. " State = 3 " +
  124. " WHERE Id= @FeedbackId AND State in(1,2) ";
  125. string resultRecord;
  126. //准备参数
  127. List<List<Object>> parametersRecord = new List<List<Object>>();
  128. parametersRecord.Add(new List<Object>() { "FeedbackId", Guid.Parse(FeedbackId) });
  129. parametersRecord.Add(new List<Object>() { "IsComplete", 1 });
  130. parametersRecord.Add(new List<Object>() { "ConfirmPuchaseTime", DateTime.Now });
  131. parametersRecord.Add(new List<Object>() { "ConfirmPuchaser", accountid });
  132. List<SqlParameter> parametersRecord1 = DataAccess.ToParameters(parametersRecord);
  133. int successRecord = DataAccess.ExecuteCommand(commandTextRecord, parametersRecord1, out resultRecord);
  134. result = resultRecord;
  135. #endregion
  136. if ( successRecord > 0)
  137. return 1;
  138. else
  139. return 0;
  140. }
  141. //IsDelete 1
  142. public static int UpdatePlanDelete(string SuppliersId, string RecordId,int PushAccountId,List<DataAccessCommand> listcmd = null)
  143. {
  144. #region 更新明细
  145. string commandTextRecord = "UPDATE PurPlanMT " +
  146. " SET " +
  147. " BillState = @BillState " +
  148. " WHERE PushRecordId= @RecordId" +
  149. " and SuppliersId= @SuppliersId " +
  150. " AND (BillState = 0) " +
  151. " and PurObj = @PurObj "
  152. ;
  153. string resultRecord;
  154. //准备参数
  155. List<List<Object>> parametersRecord = new List<List<Object>>();
  156. parametersRecord.Add(new List<Object>() { "RecordId", RecordId });
  157. parametersRecord.Add(new List<Object>() { "SuppliersId", SuppliersId });
  158. parametersRecord.Add(new List<Object>() { "BillState", 1 });
  159. parametersRecord.Add(new List<Object>() { "PurObj", PushAccountId });
  160. List<SqlParameter> parametersRecord1 = DataAccess.ToParameters(parametersRecord);
  161. #endregion
  162. if(listcmd == null) {
  163. int successRecord = DataAccess.ExecuteCommand(commandTextRecord, parametersRecord1, out resultRecord);
  164. if (successRecord > 0)
  165. return 1;
  166. else
  167. return 0;
  168. }
  169. else
  170. {
  171. listcmd.Add(new DataAccessCommand(commandTextRecord, parametersRecord1,CommandType.Text,true));
  172. return 1;
  173. }
  174. }
  175. }
  176. }