| 
									
										
										
										
											2022-12-26 14:34:56 +08:00
										 |  |  |  | using FineUIPro; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace BLL | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     public static class HJGLData_DefectService | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         public static Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 获取列表 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 记录数 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public static int count | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get; | 
					
						
							|  |  |  |  |             set; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public static List<Model.HJGLData_Defect> GetHJGLData_DefectByModle(Model.HJGLData_Defect table) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var q = from x in db.HJGLData_Defect | 
					
						
							|  |  |  |  |                     where | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.UnitId) || x.UnitId.Contains(table.UnitId)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.CollCropCode) || x.CollCropCode.Contains(table.CollCropCode)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.UnitName) || x.UnitName.Contains(table.UnitName)) && | 
					
						
							|  |  |  |  |                               (string.IsNullOrEmpty(table.DefectName) || x.DefectName.Contains(table.DefectName))  | 
					
						
							|  |  |  |  |                     select x | 
					
						
							|  |  |  |  |                   ; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return q.ToList(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// 获取分页列表 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="PageIndex">页码</param> | 
					
						
							|  |  |  |  |         /// <param name="PageSize">每页数量</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static IEnumerable getListData(Model.HJGLData_Defect table, Grid Grid1) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var q = GetHJGLData_DefectByModle(table); | 
					
						
							|  |  |  |  |             count = q.Count(); | 
					
						
							|  |  |  |  |             if (count == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return null; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |            // q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize); | 
					
						
							|  |  |  |  |             return from x in q | 
					
						
							|  |  |  |  |                    select new | 
					
						
							|  |  |  |  |                    { | 
					
						
							|  |  |  |  |                        x.Id, | 
					
						
							|  |  |  |  |                        x.UnitId, | 
					
						
							|  |  |  |  |                        x.CollCropCode, | 
					
						
							|  |  |  |  |                        x.UnitName, | 
					
						
							|  |  |  |  |                        x.ReportDate, | 
					
						
							|  |  |  |  |                        x.DefectName, | 
					
						
							|  |  |  |  |                        x.DefectNum, | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                    }; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public static Model.HJGLData_Defect GetHJGLData_DefectById(string Id) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return db.HJGLData_Defect.FirstOrDefault(x => x.Id == Id); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public static List<Model.HJGLData_Defect> GetHJGLData_DefectByDate(DateTime? reportDate) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             var q = from x in db.HJGLData_Defect | 
					
						
							|  |  |  |  |                     where x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0 | 
					
						
							|  |  |  |  |                     select x;  | 
					
						
							|  |  |  |  |             return q.ToList(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public static void AddHJGLData_Defect(Model.HJGLData_Defect newtable) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |             using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) | 
					
						
							| 
									
										
										
										
											2022-12-26 14:34:56 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |                 Model.HJGLData_Defect table = new Model.HJGLData_Defect | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     Id = newtable.Id, | 
					
						
							|  |  |  |  |                     UnitId = newtable.UnitId, | 
					
						
							|  |  |  |  |                     CollCropCode = newtable.CollCropCode, | 
					
						
							|  |  |  |  |                     UnitName = newtable.UnitName, | 
					
						
							|  |  |  |  |                     ReportDate = newtable.ReportDate, | 
					
						
							|  |  |  |  |                     DefectName = newtable.DefectName, | 
					
						
							|  |  |  |  |                     DefectNum = newtable.DefectNum, | 
					
						
							|  |  |  |  |                 }; | 
					
						
							|  |  |  |  |                 db.HJGLData_Defect.InsertOnSubmit(table); | 
					
						
							|  |  |  |  |                 db.SubmitChanges(); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2022-12-26 14:34:56 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public static void UpdateHJGLData_Defect(Model.HJGLData_Defect newtable) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |             using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) | 
					
						
							| 
									
										
										
										
											2022-12-26 14:34:56 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |                 Model.HJGLData_Defect table = db.HJGLData_Defect.FirstOrDefault(x => x.Id == newtable.Id); | 
					
						
							|  |  |  |  |                 if (table != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     table.Id = newtable.Id; | 
					
						
							|  |  |  |  |                     table.UnitId = newtable.UnitId; | 
					
						
							|  |  |  |  |                     table.CollCropCode = newtable.CollCropCode; | 
					
						
							|  |  |  |  |                     table.UnitName = newtable.UnitName; | 
					
						
							|  |  |  |  |                     table.ReportDate = newtable.ReportDate; | 
					
						
							|  |  |  |  |                     table.DefectName = newtable.DefectName; | 
					
						
							|  |  |  |  |                     table.DefectNum = newtable.DefectNum; | 
					
						
							|  |  |  |  |                     db.SubmitChanges(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2022-12-26 14:34:56 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public static void DeleteHJGLData_DefectById(string Id) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |             using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) | 
					
						
							| 
									
										
										
										
											2022-12-26 14:34:56 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |                 Model.HJGLData_Defect table = db.HJGLData_Defect.FirstOrDefault(x => x.Id == Id); | 
					
						
							|  |  |  |  |                 if (table != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     db.HJGLData_Defect.DeleteOnSubmit(table); | 
					
						
							|  |  |  |  |                     db.SubmitChanges(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2022-12-26 14:34:56 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public static void DeleteHJGLData_DefectByDate(DateTime? reportDate) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |             using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) | 
					
						
							| 
									
										
										
										
											2022-12-26 14:34:56 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-12-24 19:04:32 +08:00
										 |  |  |  |                 var table = db.HJGLData_Defect.Where(x => x.ReportDate.Value.Date.CompareTo(reportDate.Value.Date) == 0); | 
					
						
							|  |  |  |  |                 if (table != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     db.HJGLData_Defect.DeleteAllOnSubmit(table); | 
					
						
							|  |  |  |  |                     db.SubmitChanges(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             }  | 
					
						
							| 
									
										
										
										
											2022-12-26 14:34:56 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |