namespace BLL { using Model; using System.Collections.Generic; using System.Linq; using System.Web.UI.WebControls; public static class Base_DetectionRateService { /// ///获取探伤比例信息 /// /// public static Model.Base_DetectionRate GetDetectionRateByDetectionRateId(string detectionRateId) { return Funs.DB.Base_DetectionRate.FirstOrDefault(e => e.DetectionRateId == detectionRateId); } /// /// 增加探伤比例信息 /// /// public static void AddDetectionRate(Model.Base_DetectionRate detectionRate) { Model.SGGLDB db = Funs.DB; Model.Base_DetectionRate newDetectionRate = new Base_DetectionRate { DetectionRateId = detectionRate.DetectionRateId, DetectionRateCode = detectionRate.DetectionRateCode, DetectionRateValue = detectionRate.DetectionRateValue, Remark = detectionRate.Remark, DetectionRate = detectionRate.DetectionRate }; db.Base_DetectionRate.InsertOnSubmit(newDetectionRate); db.SubmitChanges(); } /// /// 修改探伤比例信息 /// /// public static void UpdateDetectionRate(Model.Base_DetectionRate detectionRate) { Model.SGGLDB db = Funs.DB; Model.Base_DetectionRate newDetectionRate = db.Base_DetectionRate.FirstOrDefault(e => e.DetectionRateId == detectionRate.DetectionRateId); if (newDetectionRate != null) { newDetectionRate.DetectionRateCode = detectionRate.DetectionRateCode; newDetectionRate.DetectionRateValue = detectionRate.DetectionRateValue; newDetectionRate.Remark = detectionRate.Remark; newDetectionRate.DetectionRate = detectionRate.DetectionRate; db.SubmitChanges(); } } /// /// 根据探伤比例Id删除一个探伤比例信息 /// /// public static void DeleteDetectionRateByDetectionRateId(string detectionRateId) { Model.SGGLDB db = Funs.DB; Model.Base_DetectionRate delDetectionRate = db.Base_DetectionRate.FirstOrDefault(e => e.DetectionRateId == detectionRateId); if (delDetectionRate != null) { db.Base_DetectionRate.DeleteOnSubmit(delDetectionRate); db.SubmitChanges(); } } /// /// 按类型获取探伤比例项 /// /// /// public static List GetDetectionRateList() { var list = (from x in Funs.DB.Base_DetectionRate orderby x.DetectionRateCode select x).ToList(); return list; } /// /// 获取探伤比例下拉框 /// /// public static ListItem[] GetNDTRateNameList() { var q = (from x in Funs.DB.Base_DetectionRate orderby x.DetectionRateCode select x).ToList(); ListItem[] list = new ListItem[q.Count()]; for (int i = 0; i < q.Count(); i++) { list[i] = new ListItem( q[i].DetectionRate.ToString() + "", q[i].DetectionRateId.ToString()); } return list; } #region 探伤比例下拉项 /// /// 探伤比例下拉项 /// /// 下拉框名称 /// 是否显示请选择 /// 耗材类型 public static void InitDetectionRateDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease) { dropName.DataValueField = "Value"; dropName.DataTextField = "Text"; dropName.DataSource = GetNDTRateNameList(); dropName.DataBind(); if (isShowPlease) { Funs.FineUIPleaseSelect(dropName); } } #endregion } }