128 lines
4.0 KiB
C#
128 lines
4.0 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.Soft;
|
|
using WX.CRM.Model.Entity;
|
|
|
|
namespace WX.CRM.BLL.Soft
|
|
{
|
|
public class SOFT_ACTIVEREVAPPLY_BL : ISOFT_ACTIVEREVAPPLY_Q, ISOFT_ACTIVEREVAPPLY
|
|
{
|
|
|
|
|
|
public bool Create(ref ValidationErrors errors, WX.CRM.Model.Entity.SOFT_ACTIVEREVAPPLY model)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
|
|
model.PKID = new SEQUENCES_BL().Seq_base_get();
|
|
db.SOFT_ACTIVEREVAPPLY.Add(model);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool Update(ref ValidationErrors errors, WX.CRM.Model.Entity.SOFT_ACTIVEREVAPPLY model)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
db.SOFT_ACTIVEREVAPPLY.Attach(model);
|
|
db.Entry<WX.CRM.Model.Entity.SOFT_ACTIVEREVAPPLY>(model).State = EntityState.Modified;
|
|
db.SaveChanges();
|
|
return true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 审核列表
|
|
/// </summary>
|
|
/// <param name="pg"></param>
|
|
/// <param name="status"></param>
|
|
/// <param name="stime"></param>
|
|
/// <param name="etime"></param>
|
|
/// <returns></returns>
|
|
public List<SOFT_ACTIVEREVAPPLY> getOrderList(ref Pager pg, DateTime? stime, DateTime? etime, int productId, string resid, string orderid, string username)
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
|
|
var List = db.SOFT_ACTIVEREVAPPLY.AsQueryable();
|
|
|
|
if (!string.IsNullOrWhiteSpace(resid))
|
|
{
|
|
List = List.Where(m => m.RESID == resid);
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(username))
|
|
{
|
|
string name = username.Trim();
|
|
List = List.Where(m => m.USERNAME == name);
|
|
}
|
|
|
|
if (!string.IsNullOrWhiteSpace(orderid))
|
|
{
|
|
decimal id = Convert.ToDecimal(orderid);
|
|
List = List.Where(m => m.ORDERID == id);
|
|
}
|
|
if (productId != -1)
|
|
{
|
|
List = List.Where(m => m.PRODUCTID == productId);
|
|
}
|
|
|
|
|
|
if (stime != null && stime != null)
|
|
{
|
|
List = List.Where(m => m.APPLYTIME >= stime && m.APPLYTIME < etime);
|
|
}
|
|
var queryList = (from a in List
|
|
where a.ISCHECK == 0
|
|
select a);
|
|
|
|
queryList = queryList.OrderByDescending(m => m.APPLYTIME);
|
|
PagerUtil.SetPager<SOFT_ACTIVEREVAPPLY>(ref queryList, ref pg);
|
|
return queryList.ToList();
|
|
}
|
|
}
|
|
|
|
|
|
public SOFT_ACTIVEREVAPPLY getOrderRevApplyById(decimal pkid)
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
return db.SOFT_ACTIVEREVAPPLY.FirstOrDefault(p => p.PKID == pkid);
|
|
}
|
|
}
|
|
public SOFT_ACTIVEREVAPPLY getOrderRevApplyByOrderid(decimal orderid)
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
return db.SOFT_ACTIVEREVAPPLY.FirstOrDefault(p => p.ORDERID == orderid);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|