InitBasfTcc11
This commit is contained in:
@@ -0,0 +1,365 @@
|
||||
namespace BLL
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Model;
|
||||
|
||||
public static class Base_ProjectService
|
||||
{
|
||||
/// <summary>
|
||||
///获取项目信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Model.Base_Project GetProjectByProjectId(string projectId)
|
||||
{
|
||||
return Funs.DB.Base_Project.FirstOrDefault(e => e.ProjectId == projectId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///获取项目编号
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetProjectCode(string projectId)
|
||||
{
|
||||
Model.Base_Project project = Funs.DB.Base_Project.FirstOrDefault(e => e.ProjectId == projectId);
|
||||
if (project == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return project.ProjectCode;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///获取项目简称
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static string GetProjectName(string projectId)
|
||||
{
|
||||
Model.Base_Project project = Funs.DB.Base_Project.FirstOrDefault(e => e.ProjectId == projectId);
|
||||
if (project == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return project.ShortName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断施工号是否存在
|
||||
/// </summary>
|
||||
/// <param name="projectId">项目ID</param>
|
||||
/// <param name="projectCode">施工号</param>
|
||||
/// <returns></returns>
|
||||
public static bool IsExistProjectCode(string projectId, string projectCode)
|
||||
{
|
||||
bool isExitCode = false;
|
||||
var q = from x in Funs.DB.Base_Project where x.ProjectCode == projectCode && x.ProjectId != projectId select x;
|
||||
if (q.Count() > 0)
|
||||
{
|
||||
isExitCode = true;
|
||||
}
|
||||
return isExitCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加项目信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static void AddProject(Model.Base_Project project)
|
||||
{
|
||||
Model.HJGLDB db = Funs.DB;
|
||||
Model.Base_Project newProject = new Base_Project();
|
||||
newProject.ProjectId = project.ProjectId;
|
||||
newProject.ProjectCode = project.ProjectCode;
|
||||
newProject.ProjectName = project.ProjectName;
|
||||
newProject.EnProjectName = project.EnProjectName;
|
||||
newProject.ShortName = project.ShortName;
|
||||
newProject.ProjectAddress = project.ProjectAddress;
|
||||
newProject.StartDate = project.StartDate;
|
||||
newProject.EndDate = project.EndDate;
|
||||
newProject.ProjectTypeId = project.ProjectTypeId;
|
||||
newProject.Area = project.Area;
|
||||
newProject.ProjectAmount = project.ProjectAmount;
|
||||
|
||||
newProject.ProjectPrincipal = project.ProjectPrincipal;
|
||||
newProject.ConstructionPrincipal = project.ConstructionPrincipal;
|
||||
newProject.Remark = project.Remark;
|
||||
newProject.IsClosed = project.IsClosed;
|
||||
newProject.ProjectArea = project.ProjectArea;
|
||||
|
||||
db.Base_Project.InsertOnSubmit(newProject);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///修改项目信息
|
||||
/// </summary>
|
||||
/// <param name="project"></param>
|
||||
public static void UpdateProject(Model.Base_Project project)
|
||||
{
|
||||
Model.HJGLDB db = Funs.DB;
|
||||
Model.Base_Project newProject = db.Base_Project.First(e => e.ProjectId == project.ProjectId);
|
||||
newProject.ProjectCode = project.ProjectCode;
|
||||
newProject.ProjectName = project.ProjectName;
|
||||
newProject.EnProjectName = project.EnProjectName;
|
||||
newProject.ShortName = project.ShortName;
|
||||
newProject.ProjectAddress = project.ProjectAddress;
|
||||
newProject.StartDate = project.StartDate;
|
||||
newProject.EndDate = project.EndDate;
|
||||
newProject.ProjectTypeId = project.ProjectTypeId;
|
||||
newProject.Area = project.Area;
|
||||
newProject.ProjectAmount = project.ProjectAmount;
|
||||
|
||||
newProject.ProjectPrincipal = project.ProjectPrincipal;
|
||||
newProject.ConstructionPrincipal = project.ConstructionPrincipal;
|
||||
newProject.Remark = project.Remark;
|
||||
newProject.IsClosed = project.IsClosed;
|
||||
newProject.ProjectArea = project.ProjectArea;
|
||||
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据项目Id删除一个项目信息
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
public static void DeleteProject(string projectId)
|
||||
{
|
||||
Model.HJGLDB db = Funs.DB;
|
||||
Model.Base_Project project = db.Base_Project.FirstOrDefault(e => e.ProjectId == projectId);
|
||||
|
||||
Model.Sys_Set sysSet=db.Sys_Set.FirstOrDefault(e => e.ProjectId == projectId);
|
||||
Model.Common_ReportServer report=db.Common_ReportServer.FirstOrDefault(e => e.ProjectId == projectId);
|
||||
|
||||
if (report != null)
|
||||
{
|
||||
db.Common_ReportServer.DeleteOnSubmit(report);
|
||||
}
|
||||
if (sysSet != null)
|
||||
{
|
||||
db.Sys_Set.DeleteOnSubmit(sysSet);
|
||||
}
|
||||
|
||||
if (project != null)
|
||||
{
|
||||
db.Base_Project.DeleteOnSubmit(project);
|
||||
}
|
||||
|
||||
var punit = from x in db.Project_Unit where x.ProjectId == projectId select x;
|
||||
if (punit.Count() > 0)
|
||||
{
|
||||
db.Project_Unit.DeleteAllOnSubmit(punit);
|
||||
}
|
||||
|
||||
var puser = from x in db.Project_User where x.ProjectId == projectId select x;
|
||||
if (puser.Count() > 0)
|
||||
{
|
||||
db.Project_User.DeleteAllOnSubmit(puser);
|
||||
}
|
||||
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
public static List<Model.Base_Project> GetOnProjectList()
|
||||
{
|
||||
return (from x in Funs.DB.Base_Project where (x.IsClosed == null || x.IsClosed == false) select x).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据用户加载项目
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="state">true:完工,false:在建</param>
|
||||
/// <returns></returns>
|
||||
public static List<Model.Base_Project> GetProjectListByUserIdAndState(string userId, string state)
|
||||
{
|
||||
if (state == BLL.Const._Null)
|
||||
{
|
||||
if (userId == BLL.Const.GlyId) //管理员
|
||||
{
|
||||
var q = (from x in Funs.DB.Base_Project
|
||||
orderby x.ProjectCode descending
|
||||
select x).ToList();
|
||||
return q;
|
||||
}
|
||||
else
|
||||
{
|
||||
var q = (from x in Funs.DB.Base_Project
|
||||
join y in Funs.DB.Project_User
|
||||
on x.ProjectId equals y.ProjectId
|
||||
where y.UserId == userId
|
||||
select x).Distinct().ToList();
|
||||
return q.OrderByDescending(x => x.ProjectCode).ToList();
|
||||
}
|
||||
}
|
||||
else if (state == BLL.Const._True)
|
||||
{
|
||||
if (userId == BLL.Const.GlyId) //管理员
|
||||
{
|
||||
var q = (from x in Funs.DB.Base_Project
|
||||
where x.IsClosed == true
|
||||
orderby x.ProjectCode descending
|
||||
select x).ToList();
|
||||
return q;
|
||||
}
|
||||
else
|
||||
{
|
||||
var q = (from x in Funs.DB.Base_Project
|
||||
join y in Funs.DB.Project_User
|
||||
on x.ProjectId equals y.ProjectId
|
||||
where y.UserId == userId && x.IsClosed == true
|
||||
select x).Distinct().ToList();
|
||||
return q.OrderByDescending(x => x.ProjectCode).ToList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (userId == BLL.Const.GlyId) //管理员
|
||||
{
|
||||
var q = (from x in Funs.DB.Base_Project
|
||||
where x.IsClosed == false
|
||||
orderby x.ProjectCode descending
|
||||
select x).ToList();
|
||||
return q;
|
||||
}
|
||||
else
|
||||
{
|
||||
var q = (from x in Funs.DB.Base_Project
|
||||
join y in Funs.DB.Project_User
|
||||
on x.ProjectId equals y.ProjectId
|
||||
where y.UserId == userId && x.IsClosed == false
|
||||
select x).Distinct().ToList();
|
||||
return q.OrderByDescending(x => x.ProjectCode).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据用户,状态和项目类型加载项目
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="state"></param>
|
||||
/// <param name="projectType"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Model.Base_Project> GetProjectListByUserIdAndState(string userId, string state, string projectArea)
|
||||
{
|
||||
if (state == BLL.Const._Null)
|
||||
{
|
||||
if (userId == BLL.Const.GlyId) //管理员
|
||||
{
|
||||
var q = (from x in Funs.DB.Base_Project where x.ProjectArea== projectArea
|
||||
orderby x.ProjectCode descending
|
||||
select x).ToList();
|
||||
return q;
|
||||
}
|
||||
else
|
||||
{
|
||||
var q = (from x in Funs.DB.Base_Project
|
||||
join y in Funs.DB.Project_User
|
||||
on x.ProjectId equals y.ProjectId
|
||||
where y.UserId == userId && x.ProjectArea == projectArea
|
||||
select x).Distinct().ToList();
|
||||
return q.OrderByDescending(x => x.ProjectCode).ToList();
|
||||
}
|
||||
}
|
||||
else if (state == BLL.Const._True)
|
||||
{
|
||||
if (userId == BLL.Const.GlyId) //管理员
|
||||
{
|
||||
var q = (from x in Funs.DB.Base_Project
|
||||
where x.IsClosed == true && x.ProjectArea == projectArea
|
||||
orderby x.ProjectCode descending
|
||||
select x).ToList();
|
||||
return q;
|
||||
}
|
||||
else
|
||||
{
|
||||
var q = (from x in Funs.DB.Base_Project
|
||||
join y in Funs.DB.Project_User
|
||||
on x.ProjectId equals y.ProjectId
|
||||
where y.UserId == userId && x.IsClosed == true && x.ProjectArea == projectArea
|
||||
select x).Distinct().ToList();
|
||||
return q.OrderByDescending(x => x.ProjectCode).ToList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (userId == BLL.Const.GlyId) //管理员
|
||||
{
|
||||
var q = (from x in Funs.DB.Base_Project
|
||||
where x.IsClosed == false && x.ProjectArea == projectArea
|
||||
orderby x.ProjectCode descending
|
||||
select x).ToList();
|
||||
return q;
|
||||
}
|
||||
else
|
||||
{
|
||||
var q = (from x in Funs.DB.Base_Project
|
||||
join y in Funs.DB.Project_User
|
||||
on x.ProjectId equals y.ProjectId
|
||||
where y.UserId == userId && x.IsClosed == false && x.ProjectArea == projectArea
|
||||
select x).Distinct().ToList();
|
||||
return q.OrderByDescending(x => x.ProjectCode).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void InitProjectDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease, string userId, string state, string projectArea, string itemText)
|
||||
{
|
||||
dropName.DataValueField = "ProjectId";
|
||||
dropName.DataTextField = "ProjectCode";
|
||||
dropName.DataSource = GetProjectListByUserIdAndState(userId, state, projectArea);
|
||||
dropName.DataBind();
|
||||
if (isShowPlease)
|
||||
{
|
||||
Funs.FineUIPleaseSelect(dropName, itemText);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 项目信息下拉项
|
||||
/// <summary>
|
||||
/// 项目信息下拉项
|
||||
/// </summary>
|
||||
/// <param name="dropName">下拉框名称</param>
|
||||
/// <param name="isShowPlease">是否显示请选择</param>
|
||||
/// <param name="userId">用户ID</param>
|
||||
/// <param name="state">状态</param>
|
||||
public static void InitProjectDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease, string userId, string state,string itemText)
|
||||
{
|
||||
dropName.DataValueField = "ProjectId";
|
||||
dropName.DataTextField = "ProjectCode";
|
||||
dropName.DataSource = GetProjectListByUserIdAndState(userId, state);
|
||||
dropName.DataBind();
|
||||
if (isShowPlease)
|
||||
{
|
||||
Funs.FineUIPleaseSelect(dropName,itemText);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户所有在建项目字符串
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="projectSoft"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetStrProjectIds(string userId, string state)
|
||||
{
|
||||
List<Model.Base_Project> projects = BLL.Base_ProjectService.GetProjectListByUserIdAndState(userId, state);
|
||||
string projectIds = string.Empty;
|
||||
foreach (var project in projects)
|
||||
{
|
||||
projectIds += project.ProjectId + ",";
|
||||
}
|
||||
return projectIds;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user