144 lines
4.9 KiB
C#
144 lines
4.9 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.IBLL.Csvr;
|
|
|
|
namespace WX.CRM.BLL.Csvr
|
|
{
|
|
public class CSVR_VIPNUMBER_BL : ICSVR_VIPNUMBER_Q, ICSVR_VIPNUMBER
|
|
{
|
|
public List<WX.CRM.Model.Entity.CSVR_VIPNUMBER> GetPagingData(ref Pager pager, string resId, string type)
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
var list = db.CSVR_VIPNUMBER.AsQueryable();
|
|
if (!string.IsNullOrWhiteSpace(resId))
|
|
{
|
|
list = list.Where(p => p.RESID.Trim() == resId);
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(type))
|
|
{
|
|
list = list.Where(p => p.VIPTYPE == type);
|
|
}
|
|
list = list.OrderByDescending(p => p.CTIME);
|
|
PagerUtil.SetPager<WX.CRM.Model.Entity.CSVR_VIPNUMBER>(ref list, ref pager);
|
|
return list.ToList();
|
|
}
|
|
}
|
|
|
|
|
|
public bool CreateEntities(ref ValidationErrors errors, List<WX.CRM.Model.Entity.CSVR_VIPNUMBER> entities)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
|
|
foreach (var entity in entities)
|
|
{
|
|
entity.PKID = new SEQUENCES_BL().Seq_base_get();
|
|
db.CSVR_VIPNUMBER.Add(entity);
|
|
}
|
|
|
|
bool result = db.SaveChanges().GetResult(); ;
|
|
return result;
|
|
|
|
}
|
|
}
|
|
catch (Exception ex) { errors.Add(ex.Message); return false; }
|
|
}
|
|
|
|
#region 添加
|
|
public bool Create(ref ValidationErrors errors, WX.CRM.Model.Entity.CSVR_VIPNUMBER model)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
|
|
model.PKID = new SEQUENCES_BL().Seq_base_get();
|
|
model.CTIME = DateTime.Now;
|
|
db.CSVR_VIPNUMBER.Add(model);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
#endregion
|
|
#region 删除
|
|
public bool Delete(ref ValidationErrors errors, decimal id)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
WX.CRM.Model.Entity.CSVR_VIPNUMBER entry = db.CSVR_VIPNUMBER.FirstOrDefault(m => m.PKID == id);
|
|
if (entry == null)
|
|
{
|
|
errors.Add("数据已经被删除!");
|
|
return false;
|
|
}
|
|
db.CSVR_VIPNUMBER.Remove(entry);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex) { errors.Add(ex.Message); return false; }
|
|
}
|
|
#endregion
|
|
|
|
public bool IsVipNumber(ref ValidationErrors errors, string resid, string line)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
var entr = db.BAS_SUBCOMTYPE.FirstOrDefault(m => m.TYPECODE == "VipCusType" && m.EDITFORM == line);
|
|
if (entr == null)
|
|
{
|
|
errors.Add("oh no,number is wrong !");
|
|
return false;
|
|
}
|
|
WX.CRM.Model.Entity.CSVR_VIPNUMBER entry = db.CSVR_VIPNUMBER.FirstOrDefault(m => m.RESID == resid && m.VIPTYPE == entr.SUBTYPECODE);
|
|
if (entry == null)
|
|
{
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex.ToString());
|
|
errors.Add("系统错误!");
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否存在
|
|
/// </summary>
|
|
/// <param name="resId"></param>
|
|
/// <param name="viptype"></param>
|
|
/// <returns></returns>
|
|
public List<WX.CRM.Model.Entity.CSVR_VIPNUMBER> GetByResIds(string[] resId, string viptype)
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
return db.CSVR_VIPNUMBER.Where(m => m.VIPTYPE == viptype).Where(p => resId.Contains(p.RESID)).ToList();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|