234 lines
8.1 KiB
C#
234 lines
8.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using WX.CRM.BLL.Base;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.DAL.Csvr;
|
|
using WX.CRM.IBLL.Csvr;
|
|
using WX.CRM.Model.Entity;
|
|
|
|
namespace WX.CRM.BLL.Csvr
|
|
{
|
|
public class CSVR_APPLYVIP_BL : DbContextRepository<CSVR_APPLYVIP>, ICSVR_APPLYVIP, ICSVR_APPLYVIP_Q
|
|
{
|
|
#region 添加
|
|
/// <summary>
|
|
/// 添加
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public bool Create(ref ValidationErrors errors, WX.CRM.Model.Entity.CSVR_APPLYVIP model)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
model.PKID = new SEQUENCES_BL().Seq_base_get();
|
|
db.CSVR_APPLYVIP.Add(model);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 修改
|
|
/// <summary>
|
|
/// 数据的修改
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public bool Update(ref ValidationErrors errors, WX.CRM.Model.Entity.CSVR_APPLYVIP model)
|
|
{
|
|
try
|
|
{
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
WX.CRM.Model.Entity.CSVR_APPLYVIP entry = db.CSVR_APPLYVIP.FirstOrDefault(m => m.PKID == model.PKID);
|
|
if (entry == null)
|
|
return false;
|
|
entry.RESID = model.RESID;
|
|
entry.ISLOCAL = model.ISLOCAL;
|
|
entry.MEMO = model.MEMO;
|
|
entry.STATUS = model.STATUS;
|
|
entry.CTIME = model.CTIME;
|
|
entry.UTIME = model.UTIME;
|
|
entry.INNERUSERID = model.INNERUSERID;
|
|
entry.OPERATORID = model.OPERATORID;
|
|
entry.PHONE = model.PHONE;
|
|
db.SaveChanges();
|
|
return true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public bool Delete(ref ValidationErrors errors, decimal id)
|
|
{
|
|
try
|
|
{
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
WX.CRM.Model.Entity.CSVR_APPLYVIP entry = db.CSVR_APPLYVIP.FirstOrDefault(m => m.PKID == id);
|
|
if (entry == null)
|
|
{
|
|
errors.Add("数据已经被删除!");
|
|
return false;
|
|
}
|
|
db.CSVR_APPLYVIP.Remove(entry);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex) { errors.Add(ex.Message); return false; }
|
|
}
|
|
#endregion
|
|
|
|
#region 获取单条信息
|
|
/// <summary>
|
|
/// 获取实体
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public WX.CRM.Model.Entity.CSVR_APPLYVIP GetModel(decimal id)
|
|
{
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
WX.CRM.Model.Entity.CSVR_APPLYVIP entry = db.CSVR_APPLYVIP.FirstOrDefault(m => m.PKID == id);
|
|
return entry;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="resId"></param>
|
|
/// <returns></returns>
|
|
public bool IsExistApplyNumber(string resId)
|
|
{
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
resId = resId.Trim();
|
|
WX.CRM.Model.Entity.CSVR_APPLYVIP applyVIP = db.CSVR_APPLYVIP.FirstOrDefault(m => m.RESID == resId);
|
|
if (applyVIP != null && applyVIP.STATUS != (decimal)WX.CRM.Model.Enum.EnumApplyModifyPrimayNumberStatus.删除审核)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 修改状态
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool UpdateStatus(ref ValidationErrors errors, decimal pkid, decimal optionId, decimal status)
|
|
{
|
|
try
|
|
{
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
WX.CRM.Model.Entity.CSVR_APPLYVIP entry = db.CSVR_APPLYVIP.FirstOrDefault(m => m.PKID == pkid);
|
|
if (entry == null)
|
|
return false;
|
|
entry.UTIME = DateTime.Now;
|
|
entry.OPERATORID = optionId;
|
|
entry.STATUS = status;
|
|
db.SaveChanges();
|
|
return true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
#region 获取分页数据列表
|
|
public List<WX.CRM.Model.Entity.CSVR_APPLYVIP> GetList(ref Pager pager, string resid, bool isCheck)
|
|
{
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
var queryData = db.CSVR_APPLYVIP.AsQueryable();
|
|
decimal delCheck = (decimal)WX.CRM.Model.Enum.EnumApplyModifyPrimayNumberStatus.删除审核;
|
|
decimal alreadyCheck = (decimal)WX.CRM.Model.Enum.EnumApplyModifyPrimayNumberStatus.审核通过;
|
|
decimal unCheck = (decimal)WX.CRM.Model.Enum.EnumApplyModifyPrimayNumberStatus.未审核;
|
|
if (isCheck)// 查找出已经处理过的 申请
|
|
{
|
|
queryData = queryData.Where(m => m.STATUS == delCheck || m.STATUS == alreadyCheck);
|
|
}
|
|
else
|
|
queryData = queryData.Where(m => m.STATUS == unCheck);
|
|
if (!string.IsNullOrWhiteSpace(resid))
|
|
queryData = queryData.Where(m => m.RESID == resid);
|
|
queryData = queryData.OrderByDescending(m => m.CTIME);
|
|
PagerUtil.SetPager<WX.CRM.Model.Entity.CSVR_APPLYVIP>(ref queryData, ref pager);
|
|
return queryData.ToList();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region CTI添加 VIP数据
|
|
/// <summary>
|
|
/// CTI添加 VIP数据
|
|
/// </summary>
|
|
/// <param name="errors"></param>
|
|
/// <param name="username"></param>
|
|
/// <param name="TelNum"></param>
|
|
/// <param name="type"></param>
|
|
/// <param name="dateFrom"></param>
|
|
/// <param name="dateTo"></param>
|
|
/// <param name="memo"></param>
|
|
/// <param name="level"></param>
|
|
/// <param name="agentId"></param>
|
|
/// <returns></returns>
|
|
public bool AddBWList(ref ValidationErrors errors, string username, string TelNum, string type, DateTime dateFrom, DateTime dateTo, string memo, int level, string agentId)
|
|
{
|
|
try
|
|
{
|
|
new CSVR_APPLYVIP_DAL().AddBWList(username, TelNum, type, dateFrom, dateTo, memo, level, agentId);
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool AddBCHVIP(ref ValidationErrors errors, string TelNum, DateTime dateFrom, DateTime dateTo, string OutNumber)
|
|
{
|
|
try
|
|
{
|
|
new CSVR_APPLYVIP_DAL().AddBCHVIP(TelNum, dateFrom, dateTo, OutNumber);
|
|
return true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|