using System.Collections.Generic; using System.Linq; using System.Web.UI.WebControls; namespace BLL { public class CQMS_InspectionService { /// /// 获取报验信息 /// /// /// public static Model.Material_Inspection GetInspectionByInspectionId(string InspectionId) { return Funs.DB.Material_Inspection.FirstOrDefault(e => e.InspectionId == InspectionId); } /// /// 添加报验信息 /// /// public static void AddInspection(Model.Material_Inspection Inspection) { Model.SGGLDB db = Funs.DB; Model.Material_Inspection newInspection = new Model.Material_Inspection(); newInspection.InspectionId = Inspection.InspectionId; newInspection.ProjectId = Inspection.ProjectId; newInspection.InspectionType = Inspection.InspectionType; newInspection.InspectionCode = Inspection.InspectionCode; newInspection.UnitId = Inspection.UnitId; newInspection.IsSpotCheck = Inspection.IsSpotCheck; newInspection.IsNoticeAndSupervision = Inspection.IsNoticeAndSupervision; newInspection.State = Inspection.State; newInspection.CompileMan = Inspection.CompileMan; newInspection.CompileDate = Inspection.CompileDate; db.Material_Inspection.InsertOnSubmit(newInspection); db.SubmitChanges(); } /// /// 修改报验信息 /// /// public static void UpdateInspection(Model.Material_Inspection Inspection) { Model.SGGLDB db = Funs.DB; Model.Material_Inspection newInspection = db.Material_Inspection.FirstOrDefault(e => e.InspectionId == Inspection.InspectionId); if (newInspection != null) { newInspection.InspectionCode = Inspection.InspectionCode; newInspection.UnitId = Inspection.UnitId; newInspection.IsSpotCheck = Inspection.IsSpotCheck; newInspection.IsNoticeAndSupervision = Inspection.IsNoticeAndSupervision; newInspection.State = Inspection.State; db.SubmitChanges(); } } /// /// 根据主键删除报验信息 /// /// public static void DeleteInspectionById(string InspectionId) { Model.SGGLDB db = Funs.DB; Model.Material_Inspection Inspection = db.Material_Inspection.FirstOrDefault(e => e.InspectionId == InspectionId); if (Inspection != null) { db.Material_Inspection.DeleteOnSubmit(Inspection); db.SubmitChanges(); } if (Inspection.InspectionType == "M") { var ms = from x in db.Material_Material where x.InspectionId == InspectionId select x; foreach (var item in ms) { item.InspectionId = null; db.SubmitChanges(); } } else { var es = from x in db.Material_Equipment where x.InspectionId == InspectionId select x; foreach (var item in es) { item.InspectionId = null; db.SubmitChanges(); } } } /// /// 根据状态选择下一步办理类型 /// /// /// public static ListItem[] GetDHandleTypeByState(string state) { if (state == Const.Inspection_Compile || state == Const.Inspection_ReCompile) { ListItem[] lis = new ListItem[1]; lis[0] = new ListItem("总包专业工程师审核", Const.Inspection_Audit1); return lis; } else if (state == Const.Inspection_Audit1) { ListItem[] lis = new ListItem[2]; lis[0] = new ListItem("监理工程师审批", Const.Inspection_Audit2); lis[1] = new ListItem("重新编制", Const.Inspection_ReCompile); return lis; } else if (state == Const.Inspection_Audit2) { ListItem[] lis = new ListItem[2]; lis[0] = new ListItem("审批完成", Const.Inspection_Complete); lis[1] = new ListItem("重新编制", Const.Inspection_ReCompile); return lis; } else return null; } } }