42 lines
1.5 KiB
C#
42 lines
1.5 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using Model;
|
||
using BLL;
|
||
|
||
namespace BLL
|
||
{
|
||
public static class APIUnitInfoService
|
||
{
|
||
/// <summary>
|
||
/// 根据项目和单位类型获取分包单位
|
||
/// </summary>
|
||
/// <param name="projectCode">施工号</param>
|
||
/// <param name="unitType">单位类型(1-业主,2-监理,3-总包,4-施工,5-质检,6-理化,7-热处理,8-检测)</param>
|
||
/// <returns></returns>
|
||
public static List<Model.UnitInfoItem> getUnitByProjectIdUnitType(string projectCode, string unitType)
|
||
{
|
||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||
{
|
||
var p = db.Base_Project.FirstOrDefault(z => z.ProjectCode == projectCode);
|
||
if (p != null)
|
||
{
|
||
var getData = from x in Funs.DB.Base_Unit
|
||
join y in Funs.DB.Project_Unit on x.UnitId equals y.UnitId
|
||
where y.ProjectId == p.ProjectId && y.UnitType.Contains(unitType)
|
||
orderby x.UnitCode
|
||
select new Model.UnitInfoItem
|
||
{ UnitId = x.UnitId, UnitCode = x.UnitCode, UnitName = x.UnitName };
|
||
|
||
return getData.ToList();
|
||
}
|
||
else
|
||
{
|
||
return null;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|