namespace BLL { using Model; using System.Collections.Generic; using System.Linq; public static class Project_InstallationService { /// ///获取项目装置信息 /// /// public static Model.Project_Installation GetProject_InstallationByInstallationId(string strInstallationId) { return Funs.DB.Project_Installation.FirstOrDefault(e => e.InstallationId == strInstallationId); } /// ///获取项目装置信息 /// /// public static string GetProject_InstallationNameByInstallationId(string strInstallationId) { string name = string.Empty; var q = Funs.DB.Project_Installation.FirstOrDefault(e => e.InstallationId == strInstallationId); if (q != null) { name = q.InstallationName; } return name; } /// /// 增加项目装置信息 /// /// public static void AddProject_Installation(Model.Project_Installation setInstallation) { Model.HJGLDB db = Funs.DB; Model.Project_Installation newInstallation = new Project_Installation { InstallationId = setInstallation.InstallationId, ProjectId = setInstallation.ProjectId, InstallationCode = setInstallation.InstallationCode, InstallationName = setInstallation.InstallationName, SupervisorUnitId = setInstallation.SupervisorUnitId, Remark = setInstallation.Remark, }; db.Project_Installation.InsertOnSubmit(newInstallation); db.SubmitChanges(); } /// /// 修改项目装置信息 /// /// public static void UpdateProject_Installation(Model.Project_Installation updateInstallation) { Model.HJGLDB db = Funs.DB; Model.Project_Installation newInstallation = db.Project_Installation.FirstOrDefault(e => e.InstallationId == updateInstallation.InstallationId); if (newInstallation != null) { newInstallation.InstallationCode = updateInstallation.InstallationCode; newInstallation.InstallationName = updateInstallation.InstallationName; newInstallation.SupervisorUnitId = updateInstallation.SupervisorUnitId; newInstallation.Remark = updateInstallation.Remark; db.SubmitChanges(); } } /// /// 根据装置Id删除一个项目装置信息 /// /// 装置ID public static void DeleteProject_InstallationByInstallationId(string strInstallationId) { Model.HJGLDB db = Funs.DB; Model.Project_Installation delInstallation = db.Project_Installation.FirstOrDefault(e => e.InstallationId == strInstallationId); if (delInstallation != null) { db.Project_Installation.DeleteOnSubmit(delInstallation); db.SubmitChanges(); } } /// /// 根据项目Id删除一个项目装置信息 /// /// 项目ID public static void DeleteProject_InstallationByProjectId(string strProjectId) { Model.HJGLDB db = Funs.DB; var delInstallations = from x in db.Project_Installation where x.ProjectId == strProjectId select x; if (delInstallations.Count() > 0) { db.Project_Installation.DeleteAllOnSubmit(delInstallations); db.SubmitChanges(); } } /// /// 按类型获取项目装置项 /// /// /// public static List GetProject_InstallationListByProjectId(string strProjectId) { var list = (from x in Funs.DB.Project_Installation where x.ProjectId == strProjectId orderby x.InstallationCode select x).ToList(); return list; } /// /// 按类型获取项目装置项 /// /// /// /// public static List GetInstallationList(string projectId, string unitId) { var q = (from x in BLL.Funs.DB.Project_Installation join y in BLL.Funs.DB.Project_WorkArea on x.InstallationId equals y.InstallationId where x.ProjectId == projectId && y.UnitId == unitId orderby x.InstallationCode select x).Distinct().ToList(); return q; } public static void InitInstallationDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease, string projectId, string unitId, string itemText) { dropName.DataValueField = "InstallationId"; dropName.DataTextField = "InstallationName"; dropName.DataSource = GetInstallationList(projectId, unitId); dropName.DataBind(); if (isShowPlease) { Funs.FineUIPleaseSelect(dropName, itemText); } else { dropName.SelectedIndex = 0; } } #region 项目装置下拉项 /// /// /// /// /// /// /// public static void InitInstallationDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease, string strProjectId, string itemText) { dropName.DataValueField = "InstallationId"; dropName.DataTextField = "InstallationName"; dropName.DataSource = GetProject_InstallationListByProjectId(strProjectId); dropName.DataBind(); if (isShowPlease) { Funs.FineUIPleaseSelect(dropName, itemText); } else { dropName.SelectedIndex = 0; } } #endregion } }