using System; using System.Collections.Generic; using System.Linq; namespace BLL { /// /// 项目策划 /// public static class ProjectPlanService { /// /// 根据主键获取项目策划 /// /// /// public static Model.ActionPlan_ProjectPlan GetProjectPlanById(string ProjectPlanId) { return Funs.DB.ActionPlan_ProjectPlan.FirstOrDefault(e => e.ProjectPlanId == ProjectPlanId); } /// /// 根据日期获取项目策划集合 /// /// 开始时间 /// 结束时间 /// 项目号 /// 项目策划集合 public static List GetProjectPlansByDate(DateTime startTime, DateTime endTime, string projectId) { return (from x in Funs.DB.ActionPlan_ProjectPlan where x.CompileDate >= startTime && x.CompileDate <= endTime && x.ProjectId == projectId orderby x.CompileDate select x).ToList(); } /// /// 添加项目策划 /// /// public static void AddProjectPlan(Model.ActionPlan_ProjectPlan ProjectPlan) { Model.ActionPlan_ProjectPlan newProjectPlan = new Model.ActionPlan_ProjectPlan { ProjectPlanId = ProjectPlan.ProjectPlanId, ProjectId = ProjectPlan.ProjectId, ProjectPlanCode = ProjectPlan.ProjectPlanCode, ProjectPlanName = ProjectPlan.ProjectPlanName, VersionNo = ProjectPlan.VersionNo, ProjectType = ProjectPlan.ProjectType, Edition = ProjectPlan.Edition, IsReview = ProjectPlan.IsReview, ReviewMan = ProjectPlan.ReviewMan, IsCompanyReview = ProjectPlan.IsCompanyReview, ProjectPlanContents = ProjectPlan.ProjectPlanContents, CompileMan = ProjectPlan.CompileMan, CompileDate = ProjectPlan.CompileDate, States = ProjectPlan.States }; Funs.DB.ActionPlan_ProjectPlan.InsertOnSubmit(newProjectPlan); Funs.DB.SubmitChanges(); } /// /// 修改项目策划 /// /// public static void UpdateProjectPlan(Model.ActionPlan_ProjectPlan ProjectPlan) { Model.ActionPlan_ProjectPlan newProjectPlan = Funs.DB.ActionPlan_ProjectPlan.FirstOrDefault(e => e.ProjectPlanId == ProjectPlan.ProjectPlanId); if (newProjectPlan != null) { //newProjectPlan.ProjectId = ProjectPlan.ProjectId; newProjectPlan.ProjectPlanCode = ProjectPlan.ProjectPlanCode; newProjectPlan.ProjectPlanName = ProjectPlan.ProjectPlanName; newProjectPlan.VersionNo = ProjectPlan.VersionNo; newProjectPlan.ProjectType = ProjectPlan.ProjectType; newProjectPlan.Edition = ProjectPlan.Edition; newProjectPlan.IsReview = ProjectPlan.IsReview; newProjectPlan.ReviewMan = ProjectPlan.ReviewMan; newProjectPlan.IsCompanyReview = ProjectPlan.IsCompanyReview; newProjectPlan.ProjectPlanContents = ProjectPlan.ProjectPlanContents; newProjectPlan.CompileMan = ProjectPlan.CompileMan; newProjectPlan.CompileDate = ProjectPlan.CompileDate; newProjectPlan.States = ProjectPlan.States; Funs.DB.SubmitChanges(); } } /// /// 根据主键删除项目策划 /// /// public static void DeleteProjectPlanById(string ProjectPlanId) { Model.ActionPlan_ProjectPlan ProjectPlan = Funs.DB.ActionPlan_ProjectPlan.FirstOrDefault(e => e.ProjectPlanId == ProjectPlanId); if (ProjectPlan != null) { BLL.ProjectPlanOpinionService.DeleteProjectPlanOpinionsByProjectPlanId(ProjectPlanId); BLL.ProjectPlanApproveService.DeleteProjectPlanApprovesByProjectPlanId(ProjectPlanId); ///删除附件 BLL.CommonService.DeleteAttachFileById(ProjectPlanId); Funs.DB.ActionPlan_ProjectPlan.DeleteOnSubmit(ProjectPlan); Funs.DB.SubmitChanges(); } } /// /// 把状态转换代号为文字形式 /// /// /// /// public static string ConvertState(object state) { if (state != null) { if (state.ToString() == BLL.Const.ProjectPlan_ReCompile) { return "重报"; } else if (state.ToString() == BLL.Const.ProjectPlan_Compile) { return "编制"; } else if (state.ToString() == BLL.Const.ProjectPlan_Reviewing) { return "施工管理部评审"; } else if (state.ToString() == BLL.Const.ProjectPlan_Complete) { return "审批完成"; } } return ""; } public static string IsAgree(Object type, Object res) { string result = string.Empty; if (type.ToString().Equals(Const.ProjectPlan_ReCompile) || type.ToString().Equals(Const.ProjectPlan_Compile)) { res = null; } if (res != null) { if (Convert.ToBoolean(res)) { result = "是"; } else { result = "否"; } } return result; } } }