345 lines
9.3 KiB
C#
345 lines
9.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using DeiNiu.Utils;
|
|
using DeiNiu.wms.Data.Model;
|
|
using System.Data;
|
|
using System.Transactions;
|
|
namespace DeiNiu.wms.Logical
|
|
{
|
|
[Serializable]
|
|
public class LProject
|
|
{
|
|
private Project _pjObj;
|
|
private ProjectDetail _pdObj;
|
|
private ProjectApproveList _paObj = new ProjectApproveList();
|
|
|
|
public LProject()
|
|
{
|
|
|
|
Initialize();
|
|
}
|
|
/// <summary>
|
|
/// 根据项目明细的id初始化
|
|
/// 不是根据项目的id
|
|
/// </summary>
|
|
/// <param name="pjId"></param>
|
|
/// <param name="pdId"></param>
|
|
public void Initialize(int pjId, int pdId)
|
|
{
|
|
_pjObj = pjId != 0 ? new Project(pjId) : new Project();
|
|
_pdObj = pdId != 0 ? new ProjectDetail(pdId) : new ProjectDetail();
|
|
}
|
|
/// <summary>
|
|
/// get a record by project detail id
|
|
/// </summary>
|
|
public void Initialize(int pdId)
|
|
{
|
|
_pdObj = pdId != 0 ? new ProjectDetail(pdId) : new ProjectDetail();
|
|
_pjObj = _pdObj.pd_project != 0 ? new Project(_pdObj.pd_project) : new Project();
|
|
}
|
|
|
|
/// <summary>
|
|
/// get a record by id 0
|
|
/// </summary>
|
|
public void Initialize()
|
|
{
|
|
Initialize(0, 0);
|
|
}
|
|
|
|
|
|
|
|
public Project GetProject
|
|
{
|
|
get
|
|
{
|
|
return _pjObj;
|
|
}
|
|
}
|
|
|
|
public ProjectDetail GetProjectDetail
|
|
{
|
|
get
|
|
{
|
|
return _pdObj;
|
|
}
|
|
}
|
|
|
|
public ProjectApproveList PaObj
|
|
{
|
|
get { return _paObj; }
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// get all data
|
|
/// </summary>
|
|
public DataSet GetAllProject()
|
|
{
|
|
return _pjObj.Query();
|
|
}
|
|
|
|
/// <summary>
|
|
/// get all data
|
|
/// </summary>
|
|
public DataTable GetAllProjectDetail(int prjId)
|
|
{
|
|
return _pdObj.GetProjectDetails(prjId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// get all data
|
|
/// </summary>
|
|
public DataSet GetAllActiveProjects()
|
|
{
|
|
return _pjObj.QueryActived();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// get all data
|
|
/// </summary>
|
|
public DataTable GetAllProjectDetail(int emId, string year, string month)
|
|
{
|
|
switch (month)
|
|
{
|
|
case "0":
|
|
return GetAllProjectDetail(emId, year);
|
|
default:
|
|
return _pjObj.GetProjects(emId, year, month);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// get all data
|
|
/// </summary>
|
|
public DataTable GetAllProjectDetail(int emId, string year)
|
|
{
|
|
return _pjObj.GetProjects(emId, year);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 删除项目及明细,调用时需要事务支持
|
|
/// </summary>
|
|
/// <param name="projId"></param>
|
|
public void Delete()
|
|
{
|
|
DataTable dt = GetAllProjectDetail(_pjObj.ID);
|
|
ProjectDetail pd;
|
|
// using (TransactionScope trans = new TransactionScope())
|
|
{
|
|
try
|
|
{
|
|
foreach (DataRow dr in dt.Rows)
|
|
{
|
|
pd = new ProjectDetail(Convert.ToInt32(dr["pk_projDetail"].ToString()));
|
|
pd.Delete();
|
|
}
|
|
|
|
_pjObj.Delete();
|
|
// trans.Complete();
|
|
}
|
|
catch (MyException)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw new Exception("出现异常,项目删除失败。");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
public void UpdateProject()
|
|
{
|
|
// using (TransactionScope trans = new TransactionScope())
|
|
{
|
|
try
|
|
{
|
|
_pjObj.Update();
|
|
// trans.Complete();
|
|
}
|
|
catch (MyException)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
throw new Exception("出现异常,项目新增失败。");
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增项目及明细,调用时需要事务支持
|
|
/// </summary>
|
|
/// <param name="projId"></param>
|
|
public void AddProject()
|
|
{
|
|
// using (TransactionScope trans = new TransactionScope())
|
|
{
|
|
try
|
|
{
|
|
|
|
ProjectDetail pd;
|
|
_pjObj.Add();
|
|
DateTime dt = new DateTime();
|
|
DateTime dt1 = Convert.ToDateTime(_pjObj.pj_planStartDate);
|
|
DateTime dt2 = Convert.ToDateTime(_pjObj.pj_planEndDate);
|
|
TimeSpan ts = dt2 - dt1;
|
|
pd = new ProjectDetail();
|
|
pd.pd_project = _pjObj.ID;
|
|
pd.pd_year = dt1.Year.ToString();
|
|
pd.pd_month = dt1.Month.ToString();
|
|
pd.pd_status = ProjectDetailStatus.月度未提交;
|
|
pd.Add();
|
|
|
|
while (true)
|
|
{
|
|
if (dt1.Year == dt2.Year && dt1.Month == dt2.Month)
|
|
break;
|
|
|
|
dt1 = dt1.AddMonths(1);
|
|
pd = new ProjectDetail();
|
|
pd.pd_project = _pjObj.ID;
|
|
pd.pd_year = dt1.Year.ToString();
|
|
pd.pd_month = dt1.Month.ToString();
|
|
pd.pd_status = DeiNiu.Utils.ProjectDetailStatus.月度未提交;
|
|
pd.Add();
|
|
|
|
}
|
|
// trans.Complete();
|
|
}
|
|
catch (MyException)
|
|
{
|
|
throw;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
throw new Exception("出现异常,项目新增失败。");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 正负职可以查看本部门的数据
|
|
/// </summary>
|
|
/// <param name="depId"></param>
|
|
/// <param name="year"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetProjectsByDept(int depId, string year)
|
|
{
|
|
return _pjObj.GetProjectsByDept(depId, year);
|
|
}
|
|
/// <summary>
|
|
/// 考核小组可以查看 全部数据
|
|
/// </summary>
|
|
/// <param name="year"></param>
|
|
/// <param name="month"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetProjectsByYearMonth(string year, string month)
|
|
{
|
|
//
|
|
switch (month)
|
|
{
|
|
case "0":
|
|
return GetProjectsByYear(year);
|
|
default:
|
|
return _pjObj.GetProjectsByYearMonth(year, month);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 考核小组考核历史数据
|
|
/// </summary>
|
|
/// <param name="year"></param>
|
|
/// <param name="month"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetKaoHeHistoryProjectsByYearMonth(string year, string month)
|
|
{
|
|
//
|
|
switch (month)
|
|
{
|
|
case "0":
|
|
return GetKaoHeHistoryProjectsByYear(year);
|
|
default:
|
|
return _pjObj.GetKaoHeHistoryProjectsByYearMonth(year, month);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 考核小组考核历史数据
|
|
/// </summary>
|
|
/// <param name="year"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetKaoHeHistoryProjectsByYear(string year)
|
|
{
|
|
// return _pjObj.GetProjectsByYearMonth(year, month); switch (month);
|
|
|
|
return _pjObj.GetKaoHeHistoryProjectsByYear(year);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分管领导和考核小组可以查看 全部数据
|
|
/// </summary>
|
|
/// <param name="year"></param>
|
|
/// <returns></returns>
|
|
public DataTable GetProjectsByYear(string year)
|
|
{
|
|
// return _pjObj.GetProjectsByYearMonth(year, month); switch (month);
|
|
|
|
return _pjObj.GetProjectsByYear(year);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
///按 部门 获得需要其来 审批的项目列表
|
|
/// </summary>
|
|
/// <param name="deptList"> 部门列表</param>
|
|
/// <returns></returns>
|
|
public DataTable Get4ApproveList(ArrayList deptList, string year, string month)
|
|
{
|
|
if (deptList.Count ==0) return new DataTable();
|
|
switch (month)
|
|
{
|
|
case "0":
|
|
return _pjObj.Get4ApproveListYear(deptList, year);
|
|
default:
|
|
return _pjObj.Get4ApproveListYearMonth(deptList, year, month);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public DataTable GetSumProjectsByYearMonth(string year, string month)
|
|
{
|
|
switch (month)
|
|
{
|
|
case "0":
|
|
return GetSumProjectsByYear(year);
|
|
default:
|
|
return _pjObj.GetSumProjectsByYearMonth(year, month);
|
|
}
|
|
}
|
|
public DataTable GetSumProjectsByYear(string year)
|
|
{
|
|
return _pjObj.GetSumProjectsByYear(year);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|