using Common.Model;
using CoreEntity.Entity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using ZcPeng.PublicLibrary;
namespace CoreEntity.DAL
{
public class ContactDAL
{
///
/// //
///
///
public static Dictionary UpdatePushContactState(string GoodsId,string ContactId ,string SuppliersId,string State = "Y",List listcmd = null)
{
Dictionary resultdic = new Dictionary(2);
#region
string commandText = "Update k_contactsp set PushFlag = '"+ State + "' " +
" Where 1=1 " +
" and GoodsId=@GoodsId " +
" and ContactId=@ContactId "
//+" and SuppliersId=@SuppliersId "
;
string result;
List> parameters = new List>();
parameters.Add(new List() { "GoodsId", GoodsId });
parameters.Add(new List() { "ContactId", ContactId });
//parameters.Add(new List() { "SuppliersId", SuppliersId });
List list = new List();
#endregion
if(listcmd == null) {
list.Add(new DataAccessCommand(commandText, DataAccess.ToParameters(parameters), CommandType.Text, false));
bool success = DataAccess.ExecuteBatchCommands(list, out result);
resultdic.Add("success", success);
resultdic.Add("result", result);
}
else
{
listcmd.Add(new DataAccessCommand(commandText, DataAccess.ToParameters(parameters), CommandType.Text, false));
}
return resultdic;
}
///
///
/// ContactId
///
///
///
///
public static List getContactorByAccountId(string PushAccountId)
{
string commandTextContact = "Select ContactId From CONTACTDOC " +
"Where UserId=@Id and focusMicNo !='' and focusMicNo is not null";
DataTable dt = new DataTable();
String ContactId = string.Empty;
string result;
List list = new List(0);
List> parametersContact = new List>();
if (PushAccountId != null)
{
parametersContact.Add(new List() { "Id", PushAccountId });
bool success = DataAccess.GetValues(commandTextContact, ref dt, DataAccess.ToParameters(parametersContact).ToArray(), out result);
}
else
{
return null;
}
if (dt != null && dt.Rows.Count > 0)
{
list = (List)ModelConvertHelper.ConvertToModel(dt);
}
return list;
}
///
///
/// ContactId
///
///
///
public static ContactDoc getContactor(string ContactId)
{
string commandTextContact = "Select * From CONTACTDOC " +
"Where ContactId=@ContactId ";
string resultContact;
DataTable dt = new DataTable();
List> parametersContact = new List>();
if (ContactId != null && ContactId != null)
{
parametersContact.Add(new List() { "ContactId", ContactId });
bool valueContact = DataAccess.GetValues(commandTextContact, ref dt, DataAccess.ToParameters(parametersContact).ToArray(), out resultContact);
}
if (dt != null && dt.Rows.Count > 0)
{
List d = (List)ModelConvertHelper.ConvertToModel(dt);
return d.ToArray()[0];
}
return null;
}
///
/// 条件 isyw='Y' and IsSaleDelegate='N'
/// 供应商业务员默认第一个 ContactId
///
///
///
public static ContactDoc getOppContactor(string BusinessId)
{
string commandTextContact = "Select * From CONTACTDOC " +
"Where BusinessId=@BusinessId " +
"and isyw='Y' and IsSaleDelegate='N'";
string resultContact;
DataTable dt = new DataTable();
List> parametersContact = new List>();
if (BusinessId != null && BusinessId != null)
{
parametersContact.Add(new List() { "BusinessId", BusinessId });
bool valueContact = DataAccess.GetValues(commandTextContact, ref dt, DataAccess.ToParameters(parametersContact).ToArray(), out resultContact);
}
if (dt != null && dt.Rows.Count > 0)
{
List d = (List)ModelConvertHelper.ConvertToModel(dt);
return d.ToArray()[0];
}
return null;
}
}
}