173 lines
		
	
	
		
			7.4 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			173 lines
		
	
	
		
			7.4 KiB
		
	
	
	
		
			C#
		
	
	
	
| using FineUIPro;
 | |
| using System;
 | |
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| 
 | |
| 
 | |
| namespace BLL
 | |
| {
 | |
| 
 | |
|     public static class DriversubcontractorsService
 | |
|     {
 | |
| 
 | |
| 
 | |
| 
 | |
|         #region 获取列表
 | |
|         /// <summary>
 | |
|         /// 记录数
 | |
|         /// </summary>
 | |
|         public static int Count
 | |
|         {
 | |
|             get;
 | |
|             set;
 | |
|         }
 | |
|         public static IQueryable<Model.DriverSub_DriverSubContractors> GetDriverSub_DriverSubContractorsByModle(Model.DriverSub_DriverSubContractors table)
 | |
|         {
 | |
|             var q = from x in Funs.DB.DriverSub_DriverSubContractors
 | |
|                     where
 | |
|                               (string.IsNullOrEmpty(table.DriverSubContractorsId) || x.DriverSubContractorsId.Contains(table.DriverSubContractorsId)) &&
 | |
|                               (string.IsNullOrEmpty(table.SubUnitName) || x.SubUnitName.Contains(table.SubUnitName)) &&
 | |
|                               (string.IsNullOrEmpty(table.EnterpriseNature) || x.EnterpriseNature.Contains(table.EnterpriseNature)) &&
 | |
|                               (string.IsNullOrEmpty(table.SubcontractingType) || x.SubcontractingType.Contains(table.SubcontractingType)) &&
 | |
|                               (string.IsNullOrEmpty(table.CollCropCode) || x.CollCropCode.Contains(table.CollCropCode)) &&
 | |
|                               (string.IsNullOrEmpty(table.SafetyProductionLicense) || x.SafetyProductionLicense.Contains(table.SafetyProductionLicense)) &&
 | |
|                               (string.IsNullOrEmpty(table.QualificationCertificateNumber) || x.QualificationCertificateNumber.Contains(table.QualificationCertificateNumber)) &&
 | |
|                               (string.IsNullOrEmpty(table.QualificationType) || x.QualificationType.Contains(table.QualificationType)) &&
 | |
|                               (string.IsNullOrEmpty(table.QualificationLevel) || x.QualificationLevel.Contains(table.QualificationLevel)) &&
 | |
|                               (string.IsNullOrEmpty(table.Province) || x.Province.Contains(table.Province)) &&
 | |
|                               (string.IsNullOrEmpty(table.City) || x.City.Contains(table.City)) 
 | |
|                     select x
 | |
|                   ;
 | |
| 
 | |
|             return q;
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 获取分页列表
 | |
|         /// </summary>
 | |
|         /// <param name="table"></param>
 | |
|         /// <param name="grid1"></param>
 | |
|         /// <returns></returns>
 | |
|         public static IEnumerable GetListData(Model.DriverSub_DriverSubContractors table, Grid grid1)
 | |
|         {
 | |
|             var q = GetDriverSub_DriverSubContractorsByModle(table);
 | |
|             Count = q.Count();
 | |
|             if (Count == 0)
 | |
|             {
 | |
|                 return null;
 | |
|             }
 | |
|             q = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize) ;
 | |
|             // q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
 | |
|             return from x in q
 | |
|                    select new
 | |
|                    {
 | |
|                        x.DriverSubContractorsId,
 | |
|                        x.SubUnitName,
 | |
|                        x.EnterpriseNature,
 | |
|                        x.SubcontractingType,
 | |
|                        x.CollCropCode,
 | |
|                        x.SafetyProductionLicense,
 | |
|                        x.QualificationCertificateNumber,
 | |
|                        x.QualificationType,
 | |
|                        x.QualificationLevel,
 | |
|                        x.Province,
 | |
|                        x.City,
 | |
|                        x.IsUse
 | |
| 
 | |
|                    };
 | |
|         }
 | |
|         #endregion
 | |
|  
 | |
| 
 | |
|         public static Model.DriverSub_DriverSubContractors GetDriverSub_DriverSubContractorsById(string DriverSubContractorsId)
 | |
|         {
 | |
|             return Funs.DB.DriverSub_DriverSubContractors.FirstOrDefault(x => x.DriverSubContractorsId == DriverSubContractorsId);
 | |
|         }
 | |
| 
 | |
|         public static Model.DriverSub_DriverSubContractors GetDriverSubContractorsByCollCropCode(
 | |
|             string CollCropCode)
 | |
|         {
 | |
|             return Funs.DB.DriverSub_DriverSubContractors.FirstOrDefault(e => e.CollCropCode == CollCropCode);
 | |
|         }
 | |
|         public static void AddDriverSub_DriverSubContractors(Model.DriverSub_DriverSubContractors newtable)
 | |
|         {
 | |
| 
 | |
|             Model.DriverSub_DriverSubContractors table = new Model.DriverSub_DriverSubContractors
 | |
|             {
 | |
|                 DriverSubContractorsId = newtable.DriverSubContractorsId,
 | |
|                 SubUnitName = newtable.SubUnitName,
 | |
|                 EnterpriseNature = newtable.EnterpriseNature,
 | |
|                 SubcontractingType = newtable.SubcontractingType,
 | |
|                 CollCropCode = newtable.CollCropCode,
 | |
|                 SafetyProductionLicense = newtable.SafetyProductionLicense,
 | |
|                 QualificationCertificateNumber = newtable.QualificationCertificateNumber,
 | |
|                 QualificationType = newtable.QualificationType,
 | |
|                 QualificationLevel = newtable.QualificationLevel,
 | |
|                 Province = newtable.Province,
 | |
|                 City = newtable.City,
 | |
|                 IsUse = newtable.IsUse
 | |
|             };
 | |
|             Funs.DB.DriverSub_DriverSubContractors.InsertOnSubmit(table);
 | |
|             Funs.DB.SubmitChanges();
 | |
|         }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 
 | |
|         /// </summary>
 | |
|         /// <param name="newtable"></param>
 | |
|         public static void UpdateDriverSub_DriverSubContractors(Model.DriverSub_DriverSubContractors newtable)
 | |
|         {
 | |
| 
 | |
|             Model.DriverSub_DriverSubContractors table = Funs.DB.DriverSub_DriverSubContractors.FirstOrDefault(x => x.DriverSubContractorsId == newtable.DriverSubContractorsId);
 | |
|             if (table != null)
 | |
|             {
 | |
|                 table.DriverSubContractorsId = newtable.DriverSubContractorsId;
 | |
|                 table.SubUnitName = newtable.SubUnitName;
 | |
|                 table.EnterpriseNature = newtable.EnterpriseNature;
 | |
|                 table.SubcontractingType = newtable.SubcontractingType;
 | |
|                 table.CollCropCode = newtable.CollCropCode;
 | |
|                 table.SafetyProductionLicense = newtable.SafetyProductionLicense;
 | |
|                 table.QualificationCertificateNumber = newtable.QualificationCertificateNumber;
 | |
|                 table.QualificationType = newtable.QualificationType;
 | |
|                 table.QualificationLevel = newtable.QualificationLevel;
 | |
|                 table.Province = newtable.Province;
 | |
|                 table.City = newtable.City;
 | |
|                 table.IsUse = newtable.IsUse;
 | |
|                 Funs.DB.SubmitChanges();
 | |
|             }
 | |
| 
 | |
|         }
 | |
|           /// <summary>
 | |
|           /// 将所有的IsUse设置为false
 | |
|           /// </summary>
 | |
|         public static void UpdateDriverSub_DriverSubContractorsIsUse()
 | |
|         {
 | |
|             var list = Funs.DB.DriverSub_DriverSubContractors.ToList();
 | |
|             foreach (var item in list)
 | |
|             {
 | |
|                 item.IsUse = false;
 | |
|             }
 | |
|             Funs.DB.SubmitChanges();
 | |
|         }
 | |
|          
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 删除
 | |
|         /// </summary>
 | |
|         /// <param name="DriverSubContractorsId"></param>
 | |
|         public static void DeleteDriverSub_DriverSubContractorsById(string DriverSubContractorsId)
 | |
|         {
 | |
| 
 | |
|             Model.DriverSub_DriverSubContractors table = Funs.DB.DriverSub_DriverSubContractors.FirstOrDefault(x => x.DriverSubContractorsId == DriverSubContractorsId);
 | |
|             if (table != null)
 | |
|             {
 | |
|                 Funs.DB.DriverSub_DriverSubContractors.DeleteOnSubmit(table);
 | |
|                 Funs.DB.SubmitChanges();
 | |
|             }
 | |
| 
 | |
|         }
 | |
| 
 | |
|     }
 | |
| } |