using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using System.Web.UI.WebControls; namespace BLL { /// /// 探伤部位 /// public static class InspectionAreaService { public static Model.SGGLDB db = Funs.DB; /// /// 记录数 /// public static int count { get; set; } /// /// 定义变量 /// public static IQueryable qq = from x in db.Base_InspectionArea orderby x.InspectionAreaCode select x; /// /// 获取分页列表 /// /// /// /// /// public static IEnumerable GetListData(string inspectionAreaName, int startRowIndex, int maximumRows) { IQueryable q = qq; if (!string.IsNullOrEmpty(inspectionAreaName)) { q = q.Where(e => e.InspectionAreaName.Contains(inspectionAreaName)); } count = q.Count(); if (count == 0) { return new object[] { "" }; } return from x in q.Skip(startRowIndex).Take(maximumRows) select new { x.InspectionAreaId, x.InspectionAreaCode, x.InspectionAreaName, x.Remark }; } /// /// 获取分页列表数 /// /// /// public static int GetListCount(string inspectionAreaName) { return count; } /// /// 根据主键获取探伤部位 /// /// /// public static Model.Base_InspectionArea GetInspectionAreaById(string inspectionAreaId) { return Funs.DB.Base_InspectionArea.FirstOrDefault(e => e.InspectionAreaId == inspectionAreaId); } /// /// 添加探伤部位 /// /// public static void AddInspectionArea(Model.Base_InspectionArea inspectionArea) { Model.SGGLDB db = Funs.DB; Model.Base_InspectionArea newInspectionArea = new Model.Base_InspectionArea(); newInspectionArea.InspectionAreaId = inspectionArea.InspectionAreaId; newInspectionArea.InspectionAreaCode = inspectionArea.InspectionAreaCode; newInspectionArea.InspectionAreaName = inspectionArea.InspectionAreaName; newInspectionArea.Remark = inspectionArea.Remark; db.Base_InspectionArea.InsertOnSubmit(newInspectionArea); db.SubmitChanges(); } /// /// 修改探伤部位 /// /// public static void UpdateInspectionArea(Model.Base_InspectionArea inspectionArea) { Model.SGGLDB db = Funs.DB; Model.Base_InspectionArea newInspectionArea = db.Base_InspectionArea.FirstOrDefault(e => e.InspectionAreaId == inspectionArea.InspectionAreaId); if (newInspectionArea != null) { newInspectionArea.InspectionAreaCode = inspectionArea.InspectionAreaCode; newInspectionArea.InspectionAreaName = inspectionArea.InspectionAreaName; newInspectionArea.Remark = inspectionArea.Remark; db.SubmitChanges(); } } /// /// 根据主键删除探伤部位 /// /// public static void DeleteInspectionAreaById(string inspectionAreaId) { Model.SGGLDB db = Funs.DB; Model.Base_InspectionArea newInspectionArea = db.Base_InspectionArea.FirstOrDefault(e => e.InspectionAreaId == inspectionAreaId); if (newInspectionArea != null) { db.Base_InspectionArea.DeleteOnSubmit(newInspectionArea); db.SubmitChanges(); } } /// /// 获取探伤部位名称项 /// /// /// public static ListItem[] drpInspectionAreaList() { var q = (from x in Funs.DB.Base_InspectionArea orderby x.InspectionAreaCode select x).ToList(); ListItem[] list = new ListItem[q.Count()]; for (int i = 0; i < list.Count(); i++) { list[i] = new ListItem(q[i].InspectionAreaName ?? "", q[i].InspectionAreaId); } return list; } public static void InitInspectionAreaDownList(FineUIPro.DropDownList dropName, bool isShowPlease) { dropName.DataValueField = "Value"; dropName.DataTextField = "Text"; dropName.DataSource = drpInspectionAreaList(); dropName.DataBind(); if (isShowPlease) { Funs.FineUIPleaseSelect(dropName); } } /// /// 判断是否存在相同的探伤部位名称 /// /// /// /// public static bool IsExitInspectionAreaName(string inspectionAreaName, string inspectionAreaId) { Model.SGGLDB db = Funs.DB; var q = from x in db.Base_InspectionArea where x.InspectionAreaName == inspectionAreaName && x.InspectionAreaId != inspectionAreaId select x; if (q.Count() > 0) { return true; } else { return false; } } } }