123 lines
3.6 KiB
C#
123 lines
3.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using WX.CRM.BLL.Base;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.DAL.Qc;
|
|
using WX.CRM.IBLL.Base;
|
|
using WX.CRM.Model.Entity;
|
|
|
|
namespace WX.CRM.BLL.Quality
|
|
{
|
|
public class QC_BASEUSERSCORE_BL : IQC_BASEUSERSCORE
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public List<WX.CRM.Model.Entity.QC_BASEUSERSCORE> GetList()
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
return db.QC_BASEUSERSCORE.ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加
|
|
/// </summary>
|
|
/// <param name="model"></param>
|
|
/// <returns></returns>
|
|
public bool Create(ref ValidationErrors errors, WX.CRM.Model.Entity.QC_BASEUSERSCORE model)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
WX.CRM.Model.Entity.BAS_INNERUSER entry = db.BAS_INNERUSER.FirstOrDefault(m => m.EID == model.SCORENO);
|
|
if (entry != null)
|
|
{
|
|
errors.Add("分值代码已经使用!");
|
|
return false;
|
|
}
|
|
db.Configuration.ValidateOnSaveEnabled = false;
|
|
model.PKID = new SEQUENCES_BL().Seq_base_get();
|
|
db.QC_BASEUSERSCORE.Add(model);
|
|
db.SaveChanges();
|
|
return true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public bool Delete(ref ValidationErrors errors, decimal id)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
var delobj = db.QC_BASEUSERSCORE.FirstOrDefault(obj => obj.PKID == id);
|
|
if (null != delobj)
|
|
{
|
|
db.QC_BASEUSERSCORE.Remove(delobj);
|
|
db.SaveChanges();
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新基础表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool UpdateBaserUserCore(List<QC_BASEUSERSCORE> list)
|
|
{
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
foreach (QC_BASEUSERSCORE item in list)
|
|
{
|
|
db.QC_BASEUSERSCORE.Add(item);
|
|
}
|
|
db.SaveChanges();
|
|
}
|
|
}
|
|
catch { throw; }
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除 员工主管分值表数据
|
|
/// </summary>
|
|
public void DeleteScoreData()
|
|
{
|
|
new UserScore_DL().DeleteScoreData("BASEUSERSCORE", null, null);
|
|
}
|
|
}
|
|
}
|