/// <summary> /// 将联系人添加到联系人组 /// </summary> public bool AddContactsToGroup(long groupId, string conIds, long userId) { var thisGroup = GetGroupById(groupId); if (thisGroup == null || string.IsNullOrEmpty(conIds)) { return(false); } var conArr = conIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); var ccgcDal = new crm_contact_group_contact_dal(); foreach (var conId in conArr) { var thisGroupCon = ccgcDal.GetByGroupContact(thisGroup.id, long.Parse(conId)); if (thisGroupCon == null) { thisGroupCon = new crm_contact_group_contact() { id = ccgcDal.GetNextIdCom(), contact_group_id = thisGroup.id, contact_id = long.Parse(conId), create_time = timeNow, update_time = timeNow, create_user_id = userId, update_user_id = userId, }; ccgcDal.Insert(thisGroupCon); } } return(true); }
/// <summary> /// 客户的联系人组 联系人管理 /// </summary> public bool AccountContractGroupManage(long accountId, long groupId, string ids, long userId) { var thisGroup = GetGroupById(groupId); var thisAccount = new CompanyBLL().GetCompany(accountId); if (thisGroup == null || thisAccount == null) { return(false); } var oldConList = GetAccountGroupContact(groupId, accountId); var timeNow = Tools.Date.DateHelper.ToUniversalTimeStamp(DateTime.Now); var ccgcDal = new crm_contact_group_contact_dal(); if (oldConList != null && oldConList.Count > 0) { if (!string.IsNullOrEmpty(ids)) { var idArr = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var id in idArr) { var thisCon = oldConList.FirstOrDefault(_ => _.contact_group_id == groupId && _.contact_id == long.Parse(id)); if (thisCon != null) { oldConList.Remove(thisCon); continue; } thisCon = new crm_contact_group_contact() { id = ccgcDal.GetNextIdCom(), contact_group_id = groupId, contact_id = long.Parse(id), create_time = timeNow, create_user_id = userId, update_time = timeNow, update_user_id = userId, }; ccgcDal.Insert(thisCon); } if (oldConList.Count > 0) { oldConList.ForEach(_ => { ccgcDal.SoftDelete(_, userId); }); } } else { oldConList.ForEach(_ => { ccgcDal.SoftDelete(_, userId); }); } } else { if (!string.IsNullOrEmpty(ids)) { var idArr = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var id in idArr) { var thisCon = ccgcDal.GetByGroupContact(groupId, long.Parse(id)); if (thisCon != null) { continue; } thisCon = new crm_contact_group_contact() { id = ccgcDal.GetNextIdCom(), contact_group_id = groupId, contact_id = long.Parse(id), create_time = timeNow, create_user_id = userId, update_time = timeNow, update_user_id = userId, }; ccgcDal.Insert(thisCon); } } } return(true); }