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_WageSetPieceDAL : IOA_WageSetPieceDAL
{
private Database _dataBase = null;
public OA_WageSetPieceDAL()
{
_dataBase = new Database();
}
public OA_WageSetPieceDAL(Database dataBase)
{
_dataBase = dataBase;
}
///
/// 新增
///
///
///
public bool InserModel(Infrastructure.Domain.IAggregateRoot model)
{
Model.OA_WageSetPiece trueModel = model as Model.OA_WageSetPiece;
if (trueModel == null)
{
return false;
}
IList sqlParms = new List()
{ new SqlParameter("@FirmId", trueModel.FirmId) ,
new SqlParameter("@MemberId", trueModel.MemberId) ,
new SqlParameter("@SPS_Department", trueModel.SPS_Department) ,
new SqlParameter("@SPS_Process", trueModel.SPS_Process) ,
new SqlParameter("@SPS_Unit", trueModel.SPS_Unit) ,
new SqlParameter("@SPS_Wages", trueModel.SPS_Wages) ,
new SqlParameter("@SPS_OvercapacityStandard", trueModel.SPS_OvercapacityStandard) ,
new SqlParameter("@SPS_OvercapacityAccounting", trueModel.SPS_OvercapacityAccounting) ,
new SqlParameter("@SPS_OvercapacityWages", trueModel.SPS_OvercapacityWages) ,
new SqlParameter("@LastUpdateTime", trueModel.LastUpdateTime) ,
new SqlParameter("@Operator", trueModel.Operator)
};
try
{
_dataBase.Query("sp_OA_WageSetPiece_Insert", CommandType.StoredProcedure, sqlParms.ToArray());
}
catch (Exception ex)
{
throw ex;
}
return true;
}
///
/// 修改
///
///
///
public bool UpdateModel(Infrastructure.Domain.IAggregateRoot model)
{
Model.OA_WageSetPiece trueModel = model as Model.OA_WageSetPiece;
if (trueModel == null)
{
return false;
}
IList sqlParms = new List()
{ new SqlParameter("@Keyid", trueModel.Keyid) ,
new SqlParameter("@FirmId", trueModel.FirmId) ,
new SqlParameter("@MemberId", trueModel.MemberId) ,
new SqlParameter("@SPS_Department", trueModel.SPS_Department) ,
new SqlParameter("@SPS_Process", trueModel.SPS_Process) ,
new SqlParameter("@SPS_Unit", trueModel.SPS_Unit) ,
new SqlParameter("@SPS_Wages", trueModel.SPS_Wages) ,
new SqlParameter("@SPS_OvercapacityStandard", trueModel.SPS_OvercapacityStandard) ,
new SqlParameter("@SPS_OvercapacityAccounting", trueModel.SPS_OvercapacityAccounting) ,
new SqlParameter("@SPS_OvercapacityWages", trueModel.SPS_OvercapacityWages) ,
new SqlParameter("@LastUpdateTime", trueModel.LastUpdateTime) ,
new SqlParameter("@Operator", trueModel.Operator)
};
try
{
_dataBase.Query("sp_OA_WageSetPiece_Update", CommandType.StoredProcedure, sqlParms.ToArray());
}
catch (Exception ex)
{
throw ex;
}
return true;
}
///
/// 删除
///
///
///
public bool DeleteModel(Infrastructure.Domain.IAggregateRoot model)
{
Model.OA_WageSetPiece trueModel = model as Model.OA_WageSetPiece;
if (trueModel == null)
{
return false;
}
IList sqlParms = new List()
{
new SqlParameter("@Keyid",trueModel.Keyid)
};
try
{
_dataBase.Query("sp_OA_WageSetPiece_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_WageSetPiece GetModelByKeyid(int? Keyid)
{
try
{
if (Keyid == null || Keyid < 0)
return null;//错误数据返会空
IList result = _dataBase.SelectModel(" a.*,b.Name as SPS_DepartmentName,c.ParName as SPS_ProcessName ", " OA_WageSetPiece as a left join OA_Department as b on a.SPS_Department = b.Keyid left join OA_WageProcess as c on a.SPS_Process = c.Keyid ", string.Format(" a.Keyid='{0}'", 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, Guid _MemberId, int? _SPS_Department, int? _SPS_Process, string _SPS_Unit, decimal? _SPS_Wages, int? _SPS_OvercapacityStandard, string _SPS_OvercapacityAccounting, decimal? _SPS_OvercapacityWages, DateTime? _BeginLastUpdateTime, DateTime? _EndLastUpdateTime, string _Operator)
{
try
{
string condition = " 1=1 ";
if (_FirmId != Guid.Empty)
condition += " and a.FirmId = '" + _FirmId + "'";
if (_MemberId != Guid.Empty)
condition += " and a.MemberId = '" + _MemberId + "'";
if (_SPS_Department.HasValue)
condition += " and a.SPS_Department = '" + _SPS_Department + "'";
if (_SPS_Process.HasValue)
condition += " and a.SPS_Process = '" + _SPS_Process + "'";
return _dataBase.SelectModelPage(pagination, " a.*,b.Name as SPS_DepartmentName,c.ParName as SPS_ProcessName ", " OA_WageSetPiece as a left join OA_Department as b on a.SPS_Department = b.Keyid left join OA_WageProcess as c on a.SPS_Process = c.Keyid ", " a.Keyid desc", " Keyid desc ", condition);
}
catch (Exception ex)
{
throw ex;
}
}
}
}