131 lines
5.7 KiB
C#
131 lines
5.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.Entity;
|
|
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;
|
|
using WX.CRM.Model.QueryMap;
|
|
|
|
namespace WX.CRM.BLL.Csvr
|
|
{
|
|
public class CSVR_HGRECORD_BL : ICSVR_HGRECORD, ICSVR_HGRECORD_Q
|
|
{
|
|
public void Create(WX.CRM.Model.Entity.CSVR_HGRECORD model)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
if (model.PKID == 0)
|
|
{
|
|
model.PKID = new SEQUENCES_BL().Seq_base_get();
|
|
model.CTIME = DateTime.Now;
|
|
}
|
|
db.CSVR_HGRECORD.Add(model);
|
|
db.SaveChanges();
|
|
}
|
|
}
|
|
|
|
public void Update(WX.CRM.Model.Entity.CSVR_HGRECORD model)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
db.CSVR_HGRECORD.Attach(model);
|
|
db.Entry<CSVR_HGRECORD>(model).State = EntityState.Modified;
|
|
db.SaveChanges();
|
|
}
|
|
}
|
|
|
|
public WX.CRM.Model.Entity.CSVR_HGRECORD GetHgrecord(decimal recordid, decimal recordtype, string resid, decimal? orderid)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
if (string.IsNullOrEmpty(resid) && !orderid.HasValue)
|
|
return db.CSVR_HGRECORD.FirstOrDefault(p => p.RECORDID == recordid && p.RECORDTYPE == recordtype);
|
|
else
|
|
return db.CSVR_HGRECORD.FirstOrDefault(p => p.RECORDID == recordid && p.RECORDTYPE == recordtype && p.RESID == resid && p.ORDERID == orderid.Value);
|
|
}
|
|
}
|
|
|
|
|
|
public List<HGRecordModel> GetListHgrecord(ref Pager pager, decimal? recordid, decimal? memoid, DateTime? ctime, DateTime? etime, decimal? isdown)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
var csvrRecord = db.CSVR_HGRECORD.Where(m => m.RECORDTYPE == 1).AsQueryable();
|
|
if (recordid.HasValue)
|
|
csvrRecord = csvrRecord.Where(p => p.RECORDID == recordid);
|
|
if (memoid.HasValue)
|
|
csvrRecord = csvrRecord.Where(p => p.MEMOID == memoid);
|
|
if (ctime.HasValue)
|
|
csvrRecord = csvrRecord.Where(p => p.CTIME > ctime);
|
|
if (etime.HasValue)
|
|
csvrRecord = csvrRecord.Where(p => p.CTIME < etime);
|
|
if (isdown.HasValue)
|
|
csvrRecord = csvrRecord.Where(p => p.ISDOWN == isdown);
|
|
var queryData = (from memo in db.ORD_SERVICEMEMO
|
|
join b in db.ORD_MEMOCONTENT on memo.MEMOCONTENTID equals b.CONTENTID
|
|
join cord in csvrRecord on memo.MEMOID equals cord.MEMOID
|
|
select new HGRecordModel()
|
|
{
|
|
record = cord,
|
|
MEMOTYPEID = memo.MEMOTYPEID,
|
|
MEMOSUBTYPEID = memo.MEMOSUBTYPEID,
|
|
BUSINESSID = memo.BUSINESSID,
|
|
STRCONTENT = b.STRCONTENT,
|
|
MEMOCONTENTID = memo.MEMOCONTENTID
|
|
});
|
|
queryData = queryData.OrderByDescending(p => p.record.CTIME);
|
|
PagerUtil.SetPager<HGRecordModel>(ref queryData, ref pager);//分页
|
|
return queryData.ToList();
|
|
}
|
|
}
|
|
|
|
public List<CSVR_HGRECORD> GetListOrderHgrecord(ref Pager pager, decimal? recordid, decimal? orderid, DateTime? ctime, DateTime? etime, decimal? isdown)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
var csvrRecord = db.CSVR_HGRECORD.Where(m => m.RECORDTYPE == 1).AsQueryable();
|
|
if (recordid.HasValue)
|
|
csvrRecord = csvrRecord.Where(p => p.RECORDID == recordid);
|
|
if (orderid.HasValue)
|
|
csvrRecord = csvrRecord.Where(p => p.ORDERID == orderid);
|
|
if (ctime.HasValue)
|
|
csvrRecord = csvrRecord.Where(p => p.CTIME > ctime);
|
|
if (etime.HasValue)
|
|
{
|
|
etime = etime.Value.AddDays(1);
|
|
csvrRecord = csvrRecord.Where(p => p.CTIME < etime);
|
|
}
|
|
if (isdown.HasValue)
|
|
csvrRecord = csvrRecord.Where(p => p.ISDOWN == isdown);
|
|
|
|
csvrRecord = csvrRecord.OrderByDescending(p => p.CTIME);
|
|
PagerUtil.SetPager<CSVR_HGRECORD>(ref csvrRecord, ref pager);//分页
|
|
return csvrRecord.ToList();
|
|
}
|
|
}
|
|
|
|
public List<CSVR_HGRECORD> GetListComplainrecord(ref Pager pager, decimal? recordid, DateTime? ctime, DateTime? etime, decimal? isdown)
|
|
{
|
|
using (var db = new crmContext())
|
|
{
|
|
var csvrRecord = db.CSVR_HGRECORD.Where(m => m.RECORDTYPE == 2).AsQueryable();
|
|
if (recordid.HasValue)
|
|
csvrRecord = csvrRecord.Where(p => p.RECORDID == recordid);
|
|
if (ctime.HasValue)
|
|
csvrRecord = csvrRecord.Where(p => p.CTIME > ctime);
|
|
if (etime.HasValue)
|
|
csvrRecord = csvrRecord.Where(p => p.CTIME < etime);
|
|
if (isdown.HasValue)
|
|
csvrRecord = csvrRecord.Where(p => p.ISDOWN == isdown);
|
|
csvrRecord = csvrRecord.OrderByDescending(p => p.CTIME);
|
|
PagerUtil.SetPager<CSVR_HGRECORD>(ref csvrRecord, ref pager);//分页
|
|
return csvrRecord.ToList();
|
|
}
|
|
}
|
|
}
|
|
}
|