147 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			147 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | using FineUIPro; | |||
|  | using System; | |||
|  | using System.Collections; | |||
|  | using System.Collections.Generic; | |||
|  | using System.Linq; | |||
|  | using System.Text; | |||
|  | 
 | |||
|  | 
 | |||
|  | namespace BLL | |||
|  | { | |||
|  | 
 | |||
|  |     public static class SyhsedataRiskcontrolService | |||
|  |     { | |||
|  |         public static Model.SGGLDB db = Funs.DB; | |||
|  | 
 | |||
|  | 
 | |||
|  |         #region 获取列表 | |||
|  |         /// <summary> | |||
|  |         /// 记录数 | |||
|  |         /// </summary> | |||
|  |         public static int count | |||
|  |         { | |||
|  |             get; | |||
|  |             set; | |||
|  |         } | |||
|  |         public static List<Model.SYHSEData_RiskControl> GetSYHSEData_RiskControlByModle(Model.SYHSEData_RiskControl table) | |||
|  |         { | |||
|  |             var q = from x in db.SYHSEData_RiskControl | |||
|  |                     where | |||
|  |                               (string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) && | |||
|  |                               (string.IsNullOrEmpty(table.FactoryId) || x.FactoryId.Contains(table.FactoryId)) && | |||
|  |                               (string.IsNullOrEmpty(table.RiskControlName) || x.RiskControlName.Contains(table.RiskControlName))  | |||
|  |                     select x | |||
|  |                   ; | |||
|  | 
 | |||
|  |             return q.ToList(); | |||
|  |         } | |||
|  | 
 | |||
|  |         /// 获取分页列表 | |||
|  |         /// </summary> | |||
|  |         /// <param name="PageIndex">页码</param> | |||
|  |         /// <param name="PageSize">每页数量</param> | |||
|  |         /// <returns></returns> | |||
|  |         public static IEnumerable getListData(Model.SYHSEData_RiskControl table, Grid Grid1) | |||
|  |         { | |||
|  |             var q = GetSYHSEData_RiskControlByModle(table); | |||
|  |             count = q.Count(); | |||
|  |             if (count == 0) | |||
|  |             { | |||
|  |                 return null; | |||
|  |             } | |||
|  |             //  q=  q.Take(Grid1.PageSize * Grid1.PageIndex).Skip(Grid1.PageSize * (Grid1.PageIndex)).ToList(); | |||
|  |             // q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize); | |||
|  |             return from x in q | |||
|  |                    select new | |||
|  |                    { | |||
|  |                        x.Id, | |||
|  |                        x.FactoryId, | |||
|  |                        x.RiskControlName, | |||
|  |                        x.ReportDate, | |||
|  | 
 | |||
|  |                    }; | |||
|  |         } | |||
|  |         #endregion | |||
|  | 
 | |||
|  |         public static Model.SYHSEData_RiskControl GetSYHSEData_RiskControlById(string Id) | |||
|  |         { | |||
|  |             return db.SYHSEData_RiskControl.FirstOrDefault(x => x.Id == Id); | |||
|  |         } | |||
|  | 
 | |||
|  | 
 | |||
|  |         public static void AddSYHSEData_RiskControl(Model.SYHSEData_RiskControl newtable) | |||
|  |         { | |||
|  | 
 | |||
|  |             Model.SYHSEData_RiskControl table = new Model.SYHSEData_RiskControl | |||
|  |             { | |||
|  |                 Id = newtable.Id, | |||
|  |                 FactoryId = newtable.FactoryId, | |||
|  |                 RiskControlName = newtable.RiskControlName, | |||
|  |                 ReportDate = newtable.ReportDate, | |||
|  |             }; | |||
|  |             db.SYHSEData_RiskControl.InsertOnSubmit(table); | |||
|  |             db.SubmitChanges(); | |||
|  |         } | |||
|  | 
 | |||
|  |         public static void AddBulkSYHSEData_RiskControl(List<Model.SYHSEData_RiskControl> newtables) | |||
|  |         { | |||
|  | 
 | |||
|  |             db.SYHSEData_RiskControl.InsertAllOnSubmit(newtables); | |||
|  |             db.SubmitChanges(); | |||
|  |         } | |||
|  | 
 | |||
|  | 
 | |||
|  |         public static void UpdateSYHSEData_RiskControl(Model.SYHSEData_RiskControl newtable) | |||
|  |         { | |||
|  | 
 | |||
|  |             Model.SYHSEData_RiskControl table = db.SYHSEData_RiskControl.FirstOrDefault(x => x.Id == newtable.Id); | |||
|  |             if (table != null) | |||
|  |             { | |||
|  |                 table.Id = newtable.Id; | |||
|  |                 table.FactoryId = newtable.FactoryId; | |||
|  |                 table.RiskControlName = newtable.RiskControlName; | |||
|  |                 table.ReportDate = newtable.ReportDate; | |||
|  |                 db.SubmitChanges(); | |||
|  |             } | |||
|  | 
 | |||
|  |         } | |||
|  |         public static void DeleteSYHSEData_RiskControlById(string Id) | |||
|  |         { | |||
|  | 
 | |||
|  |             Model.SYHSEData_RiskControl table = db.SYHSEData_RiskControl.FirstOrDefault(x => x.Id == Id); | |||
|  |             if (table != null) | |||
|  |             { | |||
|  |                 db.SYHSEData_RiskControl.DeleteOnSubmit(table); | |||
|  |                 db.SubmitChanges(); | |||
|  |             } | |||
|  | 
 | |||
|  |         } | |||
|  | 
 | |||
|  |         public static void DeleteALLSYHSEData_RiskControl() | |||
|  |         { | |||
|  |             if (db.SYHSEData_RiskControl != null) | |||
|  |             { | |||
|  |                 db.SYHSEData_RiskControl.DeleteAllOnSubmit(db.SYHSEData_RiskControl); | |||
|  |                 db.SubmitChanges(); | |||
|  |             } | |||
|  |         } | |||
|  |         public static List<Model.SYHSEData_RiskControl> GetSYHSEData_RiskControlByDate(DateTime? reportDate) | |||
|  |         { | |||
|  |             var q = from x in db.SYHSEData_RiskControl | |||
|  |                     where x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0 | |||
|  |                     select x; | |||
|  |             return q.ToList(); | |||
|  |         } | |||
|  |         public static void DeleteSYHSEData_RiskControlByDate(DateTime? reportDate) | |||
|  |         { | |||
|  | 
 | |||
|  |             var table = db.SYHSEData_RiskControl.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0); | |||
|  |             if (table != null) | |||
|  |             { | |||
|  |                 db.SYHSEData_RiskControl.DeleteAllOnSubmit(table); | |||
|  |                 db.SubmitChanges(); | |||
|  |             } | |||
|  | 
 | |||
|  |         } | |||
|  |     } | |||
|  | } |