136 lines
4.6 KiB
C#
136 lines
4.6 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;
|
|
using WX.CRM.Model.Entity;
|
|
|
|
namespace WX.CRM.BLL.Csvr
|
|
{
|
|
public class CSVR_APPLYPRIMARYNUMBER_BL : ICSVR_APPLYPRIMARYNUMBER, ICSVR_APPLYPRIMARYNUMBER_Q
|
|
{
|
|
#region 新增
|
|
|
|
/// <summary>
|
|
/// 新增数据
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public bool Create(ref ValidationErrors errors, WX.CRM.Model.Entity.CSVR_APPLYPRIMARYNUMBER model)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
model.PKID = new SEQUENCES_BL().Seq_base_get(WX.CRM.Model.Enum.PKIDType.LargeTable);
|
|
|
|
db.CSVR_APPLYPRIMARYNUMBER.Add(model);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
#endregion 新增
|
|
|
|
#region 查询
|
|
|
|
public List<WX.CRM.Model.Entity.CSVR_APPLYPRIMARYNUMBERView> GetList(ref Pager pager
|
|
)
|
|
{
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
var queryData = from n in db.CSVR_APPLYPRIMARYNUMBER
|
|
join b in db.RES_CUSTOMER
|
|
on n.RESID equals b.RESID
|
|
select new CSVR_APPLYPRIMARYNUMBERView
|
|
{
|
|
PKID = n.PKID,
|
|
RESID = b.UMID,
|
|
MEMO = n.MEMO,
|
|
CTIME = n.CTIME,
|
|
CHECKSTATUS = n.CHECKSTATUS,
|
|
CHECKUSER = n.CHECKUSER,
|
|
CHECKTIME = n.CHECKTIME
|
|
};
|
|
|
|
queryData = queryData.Where(p => p.CHECKSTATUS == 0).OrderByDescending(m => m.CTIME);
|
|
PagerUtil.SetPager<WX.CRM.Model.Entity.CSVR_APPLYPRIMARYNUMBERView>(ref queryData, ref pager);
|
|
var obj = (from a in queryData
|
|
select a
|
|
).ToList();
|
|
return obj;
|
|
}
|
|
}
|
|
|
|
public List<WX.CRM.Model.Entity.CSVR_APPLYPRIMARYNUMBER> GetList(string resid)
|
|
{
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
resid = resid.Trim();
|
|
var obj = (from a in db.CSVR_APPLYPRIMARYNUMBER
|
|
select a
|
|
).Where(p => p.RESID == resid).ToList();
|
|
return obj;
|
|
}
|
|
}
|
|
|
|
#endregion 查询
|
|
|
|
#region 修改
|
|
|
|
public bool UpdateStatus(ref ValidationErrors errors, CSVR_APPLYPRIMARYNUMBER model)
|
|
{
|
|
try
|
|
{
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
var entry = db.CSVR_APPLYPRIMARYNUMBER.FirstOrDefault(m => m.PKID == model.PKID);
|
|
if (entry == null)
|
|
return false;
|
|
entry.CHECKUSER = model.CHECKUSER;
|
|
entry.CHECKTIME = DateTime.Now;
|
|
entry.CHECKSTATUS = model.CHECKSTATUS;
|
|
db.SaveChanges();
|
|
return true;
|
|
}
|
|
}
|
|
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_APPLYPRIMARYNUMBER entry = db.CSVR_APPLYPRIMARYNUMBER.FirstOrDefault(m => m.PKID == id);
|
|
if (entry == null)
|
|
{
|
|
errors.Add("数据已经被删除!");
|
|
return false;
|
|
}
|
|
db.CSVR_APPLYPRIMARYNUMBER.Remove(entry);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex) { errors.Add(ex.Message); return false; }
|
|
}
|
|
|
|
#endregion 删除
|
|
}
|
|
} |