using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CY.IDAL;
using System.Data.SqlClient;
using System.Data;
using CY.Model;
using System.Transactions;
namespace CY.SQLDAL
{
//招聘信息
public class OA_StaffRecruitmentsDAL : IOA_StaffRecruitmentsDAL
{
private Database _dataBase = null;
public OA_StaffRecruitmentsDAL()
{
_dataBase = new Database();
}
public OA_StaffRecruitmentsDAL(Database dataBase)
{
_dataBase = dataBase;
}
///
/// 新增
///
///
///
public bool InserModel(Infrastructure.Domain.IAggregateRoot model)
{
Model.OA_StaffRecruitments trueModel = model as Model.OA_StaffRecruitments;
if (trueModel == null)
{
return false;
}
IList sqlParms = new List()
{ new SqlParameter("@FirmId", trueModel.FirmId) ,
new SqlParameter("@Postid", trueModel.Postid) ,
new SqlParameter("@R_WorkProvence", trueModel.R_WorkProvence) ,
new SqlParameter("@R_WorkCity", trueModel.R_WorkCity) ,
new SqlParameter("@R_StartTime", trueModel.R_StartTime) ,
new SqlParameter("@R_EndTime", trueModel.R_EndTime) ,
new SqlParameter("@R_PostDetail", trueModel.R_PostDetail) ,
new SqlParameter("@R_PostNeed", trueModel.R_PostNeed) ,
new SqlParameter("@R_Vacancies", trueModel.R_Vacancies) ,
new SqlParameter("@R_Salary", trueModel.R_Salary) ,
new SqlParameter("@R_Status", trueModel.R_Status) ,
new SqlParameter("@R_ResumeAllCount", trueModel.R_ResumeAllCount) ,
new SqlParameter("@R_ResumeNewCount", trueModel.R_ResumeNewCount) ,
new SqlParameter("@LastUpdateTime", trueModel.LastUpdateTime) ,
new SqlParameter("@Operator", trueModel.Operator) ,
new SqlParameter("@Remark", trueModel.Remark)
};
try
{
_dataBase.Query("sp_OA_StaffRecruitments_Insert", CommandType.StoredProcedure, sqlParms.ToArray());
}
catch (Exception ex)
{
throw ex;
}
return true;
}
///
/// 修改
///
///
///
public bool UpdateModel(Infrastructure.Domain.IAggregateRoot model)
{
Model.OA_StaffRecruitments trueModel = model as Model.OA_StaffRecruitments;
if (trueModel == null)
{
return false;
}
IList sqlParms = new List()
{ new SqlParameter("@Keyid", trueModel.Keyid) ,
new SqlParameter("@FirmId", trueModel.FirmId) ,
new SqlParameter("@Postid", trueModel.Postid) ,
new SqlParameter("@R_WorkProvence", trueModel.R_WorkProvence) ,
new SqlParameter("@R_WorkCity", trueModel.R_WorkCity) ,
new SqlParameter("@R_StartTime", trueModel.R_StartTime) ,
new SqlParameter("@R_EndTime", trueModel.R_EndTime) ,
new SqlParameter("@R_PostDetail", trueModel.R_PostDetail) ,
new SqlParameter("@R_PostNeed", trueModel.R_PostNeed) ,
new SqlParameter("@R_Vacancies", trueModel.R_Vacancies) ,
new SqlParameter("@R_Salary", trueModel.R_Salary) ,
new SqlParameter("@R_Status", trueModel.R_Status) ,
new SqlParameter("@R_ResumeAllCount", trueModel.R_ResumeAllCount) ,
new SqlParameter("@R_ResumeNewCount", trueModel.R_ResumeNewCount) ,
new SqlParameter("@LastUpdateTime", trueModel.LastUpdateTime) ,
new SqlParameter("@Operator", trueModel.Operator) ,
new SqlParameter("@Remark", trueModel.Remark)
};
try
{
_dataBase.Query("sp_OA_StaffRecruitments_Update", CommandType.StoredProcedure, sqlParms.ToArray());
}
catch (Exception ex)
{
throw ex;
}
return true;
}
///
/// 删除
///
///
///
public bool DeleteModel(Infrastructure.Domain.IAggregateRoot model)
{
Model.OA_StaffRecruitments trueModel = model as Model.OA_StaffRecruitments;
if (trueModel == null)
{
return false;
}
IList sqlParms = new List()
{
new SqlParameter("@Keyid",trueModel.Keyid)
};
try
{
_dataBase.Query("sp_OA_StaffRecruitments_DeleteRow", CommandType.StoredProcedure, sqlParms.ToArray());
}
catch (Exception ex)
{
throw ex;
}
return true;
}
///
/// 分页查询
///
///
///
///
public IEnumerable SelectModelPage(Infrastructure.Query.Query query, Infrastructure.Query.Pagination pagination)
{
throw new NotImplementedException();
}
///
/// 单个查询
///
///
///
public IEnumerable SelectAllModel(Infrastructure.Query.Query query)
{
throw new NotImplementedException();
}
///
/// 根据编号获得信息
///
/// 编号
///
public OA_StaffRecruitments GetModelByKeyid(int? Keyid)
{
try
{
if (Keyid == null || Keyid < 0)
return null;//错误数据返会空
IList result = _dataBase.SelectModel(" a.*,b.P_Name as PostName,c.MP_CompanyName as MP_CompanyName,c.MP_ResumeIndustry as MP_ResumeIndustry ", " OA_StaffRecruitments as a left join OA_StaffPost as b on a.Postid = b.Keyid left join OA_StaffFirmProfile as c on a.FirmId = c.FirmId ", string.Format(" a.Keyid='{0}' and a.R_Status = '2' and CAST(a.R_EndTime AS DATE) >= '"+DateTime.Now.Date+"'", Keyid)) as IList;//执行查询
return (null == result || result.Count == 0) ? null : result[0];//返回结果
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 分页查询
///
///
///
public IEnumerable SelectModelPage(Infrastructure.Query.Pagination pagination, Guid _FirmId, int? _Postid, string _R_WorkProvence, string _R_WorkCity, DateTime? _BeginR_StartTime, DateTime? _EndR_StartTime, DateTime? _BeginR_EndTime, DateTime? _EndR_EndTime, string _R_PostDetail, string _R_PostNeed, int? _R_Vacancies, string _R_Salary, int? _R_Status, int? _R_ResumeAllCount, int? _R_ResumeNewCount, DateTime? _BeginLastUpdateTime, DateTime? _EndLastUpdateTime, string _Operator, string _Remark)
{
try
{
string condition = " 1=1 ";
if (_FirmId != Guid.Empty)
condition += " and a.FirmId = '" + _FirmId + "'";
if (_Postid.HasValue)
condition += " and a.Postid = '" + _Postid + "'";
if (!string.IsNullOrEmpty(_R_WorkProvence))
condition += " and a.R_WorkProvence = '" + _R_WorkProvence + "'";
if (!string.IsNullOrEmpty(_R_WorkCity))
condition += " and a.R_WorkCity = '" + _R_WorkCity + "'";
if (_BeginR_StartTime.HasValue)
condition += string.Format(" and CAST(a.R_StartTime AS DATE) >='{0}'", _BeginR_StartTime);
if (_EndR_StartTime.HasValue)
condition += string.Format(" and CAST(a.R_StartTime AS DATE) <='{0}'", _EndR_StartTime);
if (_BeginR_EndTime.HasValue)
condition += string.Format(" and CAST(a.R_EndTime AS DATE) >='{0}'", _BeginR_EndTime);
if (_EndR_EndTime.HasValue)
condition += string.Format(" and CAST(a.R_EndTime AS DATE) <='{0}'", _EndR_EndTime);
if (!string.IsNullOrEmpty(_R_PostDetail))
condition += " and a.R_PostDetail = '" + _R_PostDetail + "'";
if (!string.IsNullOrEmpty(_R_PostNeed))
condition += " and a.R_PostNeed = '" + _R_PostNeed + "'";
if (_R_Vacancies.HasValue)
condition += " and a.R_Vacancies = '" + _R_Vacancies + "'";
if (!string.IsNullOrEmpty(_R_Salary))
condition += " and a.R_Salary = '" + _R_Salary + "'";
if (_R_Status.HasValue)
condition += " and a.R_Status = '" + _R_Status + "'";
return _dataBase.SelectModelPage(pagination, " a.*,b.P_Name as PostName ", " OA_StaffRecruitments as a left join OA_StaffPost as b on a.Postid = b.Keyid ", " a.Keyid desc", " Keyid desc ", condition);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 分页查询(职位搜索)
///
///
///
public IEnumerable SelectModelPage(Infrastructure.Query.Pagination pagination, int? _Postid, string _R_WorkProvence, string _R_WorkCity, DateTime? _BeginR_StartTime, string MP_ResumeIndustry)
{
try
{
string condition = " 1=1 ";
if (_Postid.HasValue)
condition += " and a.Postid = '" + _Postid + "'";
if (!string.IsNullOrEmpty(_R_WorkProvence))
condition += " and a.R_WorkProvence = '" + _R_WorkProvence + "'";
if (!string.IsNullOrEmpty(_R_WorkCity))
condition += " and a.R_WorkCity = '" + _R_WorkCity + "'";
if (_BeginR_StartTime.HasValue)
condition += string.Format(" and CAST(a.R_StartTime AS DATE) >='{0}'", _BeginR_StartTime);
if (!string.IsNullOrEmpty(MP_ResumeIndustry))
condition += " and c.MP_ResumeIndustry = '" + MP_ResumeIndustry + "'";
condition += " and a.R_Status = '2' and CAST(a.R_EndTime AS DATE) >= '"+DateTime.Now.Date+"'";
return _dataBase.SelectModelPage(pagination, " a.*,b.P_Name as PostName,c.MP_CompanyName as MP_CompanyName,c.MP_ResumeIndustry as MP_ResumeIndustry ", " OA_StaffRecruitments as a left join OA_StaffPost as b on a.Postid = b.Keyid left join OA_StaffFirmProfile as c on a.FirmId = c.FirmId ", " a.Keyid desc", " Keyid desc ", condition);
}
catch (Exception ex)
{
throw ex;
}
}
}
}