ContactDAL.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using Common.Model;
  2. using CoreEntity.Entity;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Data;
  6. using System.Text;
  7. using ZcPeng.PublicLibrary;
  8. namespace CoreEntity.DAL
  9. {
  10. public class ContactDAL
  11. {
  12. /// <summary>
  13. /// //
  14. /// </summary>
  15. /// <returns></returns>
  16. public static Dictionary<string, Object> UpdatePushContactState(string GoodsId,string ContactId ,string SuppliersId,string State = "Y",List<DataAccessCommand> listcmd = null)
  17. {
  18. Dictionary<string, Object> resultdic = new Dictionary<string, Object>(2);
  19. #region
  20. string commandText = "Update k_contactsp set PushFlag = '"+ State + "' " +
  21. " Where 1=1 " +
  22. " and GoodsId=@GoodsId " +
  23. " and ContactId=@ContactId "
  24. //+" and SuppliersId=@SuppliersId "
  25. ;
  26. string result;
  27. List<List<Object>> parameters = new List<List<Object>>();
  28. parameters.Add(new List<Object>() { "GoodsId", GoodsId });
  29. parameters.Add(new List<Object>() { "ContactId", ContactId });
  30. //parameters.Add(new List<Object>() { "SuppliersId", SuppliersId });
  31. List<DataAccessCommand> list = new List<DataAccessCommand>();
  32. #endregion
  33. if(listcmd == null) {
  34. list.Add(new DataAccessCommand(commandText, DataAccess.ToParameters(parameters), CommandType.Text, false));
  35. bool success = DataAccess.ExecuteBatchCommands(list, out result);
  36. resultdic.Add("success", success);
  37. resultdic.Add("result", result);
  38. }
  39. else
  40. {
  41. listcmd.Add(new DataAccessCommand(commandText, DataAccess.ToParameters(parameters), CommandType.Text, false));
  42. }
  43. return resultdic;
  44. }
  45. /// <summary>
  46. ///
  47. /// ContactId
  48. /// </summary>
  49. /// <param name="PushAccountId"></param>
  50. /// <param name="BusinessId"></param>
  51. /// <returns></returns>
  52. public static List<ContactDocExt> getContactorByAccountId(string PushAccountId)
  53. {
  54. string commandTextContact = "Select ContactId From CONTACTDOC " +
  55. "Where UserId=@Id and focusMicNo !='' and focusMicNo is not null";
  56. DataTable dt = new DataTable();
  57. String ContactId = string.Empty;
  58. string result;
  59. List<ContactDocExt> list = new List<ContactDocExt>(0);
  60. List<List<Object>> parametersContact = new List<List<Object>>();
  61. if (PushAccountId != null)
  62. {
  63. parametersContact.Add(new List<Object>() { "Id", PushAccountId });
  64. bool success = DataAccess.GetValues(commandTextContact, ref dt, DataAccess.ToParameters(parametersContact).ToArray(), out result);
  65. }
  66. else
  67. {
  68. return null;
  69. }
  70. if (dt != null && dt.Rows.Count > 0)
  71. {
  72. list = (List<ContactDocExt>)ModelConvertHelper<ContactDocExt>.ConvertToModel(dt);
  73. }
  74. return list;
  75. }
  76. /// <summary>
  77. ///
  78. /// ContactId
  79. /// </summary>
  80. /// <param name="ContactId"></param>
  81. /// <returns></returns>
  82. public static ContactDoc getContactor(string ContactId)
  83. {
  84. string commandTextContact = "Select * From CONTACTDOC " +
  85. "Where ContactId=@ContactId ";
  86. string resultContact;
  87. DataTable dt = new DataTable();
  88. List<List<Object>> parametersContact = new List<List<Object>>();
  89. if (ContactId != null && ContactId != null)
  90. {
  91. parametersContact.Add(new List<Object>() { "ContactId", ContactId });
  92. bool valueContact = DataAccess.GetValues(commandTextContact, ref dt, DataAccess.ToParameters(parametersContact).ToArray(), out resultContact);
  93. }
  94. if (dt != null && dt.Rows.Count > 0)
  95. {
  96. List<ContactDoc> d = (List<ContactDoc>)ModelConvertHelper<ContactDoc>.ConvertToModel(dt);
  97. return d.ToArray()[0];
  98. }
  99. return null;
  100. }
  101. /// <summary>
  102. /// 条件 isyw='Y' and IsSaleDelegate='N'
  103. /// 供应商业务员默认第一个 ContactId
  104. /// </summary>
  105. /// <param name="ContactId"></param>
  106. /// <returns></returns>
  107. public static ContactDoc getOppContactor(string BusinessId)
  108. {
  109. string commandTextContact = "Select * From CONTACTDOC " +
  110. "Where BusinessId=@BusinessId " +
  111. "and isyw='Y' and IsSaleDelegate='N'";
  112. string resultContact;
  113. DataTable dt = new DataTable();
  114. List<List<Object>> parametersContact = new List<List<Object>>();
  115. if (BusinessId != null && BusinessId != null)
  116. {
  117. parametersContact.Add(new List<Object>() { "BusinessId", BusinessId });
  118. bool valueContact = DataAccess.GetValues(commandTextContact, ref dt, DataAccess.ToParameters(parametersContact).ToArray(), out resultContact);
  119. }
  120. if (dt != null && dt.Rows.Count > 0)
  121. {
  122. List<ContactDoc> d = (List<ContactDoc>)ModelConvertHelper<ContactDoc>.ConvertToModel(dt);
  123. return d.ToArray()[0];
  124. }
  125. return null;
  126. }
  127. }
  128. }