205 lines
7.1 KiB
C#
205 lines
7.1 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using Model;
|
||
using BLL;
|
||
using System.Collections;
|
||
using System.Web.UI.WebControls;
|
||
|
||
namespace BLL
|
||
{
|
||
public class Base_TeamGroupService
|
||
{
|
||
public static Model.SGGLDB db = Funs.DB;
|
||
|
||
/// <summary>
|
||
/// 记录数
|
||
/// </summary>
|
||
public static int count
|
||
{
|
||
get;
|
||
set;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 定义变量
|
||
/// </summary>
|
||
public static IQueryable<Model.Base_TeamGroup> qq = from x in db.Base_TeamGroup orderby x.TeamGroupCode select x;
|
||
|
||
/// <summary>
|
||
/// 获取分页列表
|
||
/// </summary>
|
||
/// <param name="searchItem"></param>
|
||
/// <param name="searchValue"></param>
|
||
/// <param name="startRowIndex"></param>
|
||
/// <param name="maximumRows"></param>
|
||
/// <returns></returns>
|
||
public static IEnumerable getListData(string projectId, string teamGroupCode, string teamGroupName, string unitId, int startRowIndex, int maximumRows)
|
||
{
|
||
IQueryable<Model.Base_TeamGroup> q = qq;
|
||
if (!string.IsNullOrEmpty(teamGroupCode))
|
||
{
|
||
q = q.Where(e => e.TeamGroupCode.Contains(teamGroupCode));
|
||
}
|
||
if (!string.IsNullOrEmpty(teamGroupName))
|
||
{
|
||
q = q.Where(e => e.TeamGroupName.Contains(teamGroupName));
|
||
}
|
||
if (unitId != "0")
|
||
{
|
||
q = q.Where(e => e.UnitId == unitId);
|
||
}
|
||
|
||
if (projectId != "0")
|
||
{
|
||
q = q.Where(e => e.ProjectId == projectId);
|
||
}
|
||
|
||
count = q.Count();
|
||
if (count == 0)
|
||
{
|
||
return new object[] { "" };
|
||
}
|
||
return from x in q.Skip(startRowIndex).Take(maximumRows)
|
||
select new
|
||
{
|
||
x.TeamGroupId,
|
||
x.TeamGroupCode,
|
||
x.TeamGroupName,
|
||
UnitName = (from y in db.Base_Unit where y.UnitId == x.UnitId select y.UnitName).First(),
|
||
ProjectName = (from y in db.Base_Project where y.ProjectId == x.ProjectId select y.ProjectName).First(),
|
||
Area = (from y in db.Project_WorkArea where y.WorkAreaId == x.Area select y.WorkAreaCode).First(),
|
||
x.Remark
|
||
};
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取列表数
|
||
/// </summary>
|
||
/// <param name="teamGroupCode"></param>
|
||
/// <param name="teamGroupName"></param>
|
||
/// <param name="unitId"></param>
|
||
/// <returns></returns>
|
||
public static int GetListCount(string projectId, string teamGroupCode, string teamGroupName, string unitId)
|
||
{
|
||
return count;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据
|
||
/// </summary>
|
||
/// <param name="groupId"></param>
|
||
/// <returns></returns>
|
||
public static Model.Base_TeamGroup GetTeamGroupByTeamGroupId(string teamGroupId)
|
||
{
|
||
return Funs.DB.Base_TeamGroup.FirstOrDefault(e => e.TeamGroupId == teamGroupId);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据班组名称获取班组信息
|
||
/// </summary>
|
||
/// <param name="teamGroupName"></param>
|
||
/// <returns></returns>
|
||
public static Model.Base_TeamGroup GetTeamGroupByTeamGroupName(string projectId, string teamGroupName)
|
||
{
|
||
return Funs.DB.Base_TeamGroup.FirstOrDefault(e =>e.ProjectId==projectId && e.TeamGroupName == teamGroupName);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加班组信息
|
||
/// </summary>
|
||
/// <param name="?"></param>
|
||
public static void AddTeamGroup(Model.Base_TeamGroup teamGroup)
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
string newKeyID = SQLHelper.GetNewID(typeof(Model.Base_TeamGroup));
|
||
Model.Base_TeamGroup newTeamGroup = new Model.Base_TeamGroup();
|
||
newTeamGroup.TeamGroupId = newKeyID;
|
||
newTeamGroup.TeamGroupCode = teamGroup.TeamGroupCode;
|
||
newTeamGroup.TeamGroupName = teamGroup.TeamGroupName;
|
||
newTeamGroup.UnitId = teamGroup.UnitId;
|
||
newTeamGroup.ProjectId = teamGroup.ProjectId;
|
||
newTeamGroup.Remark = teamGroup.Remark;
|
||
newTeamGroup.Area = teamGroup.Area;
|
||
|
||
db.Base_TeamGroup.InsertOnSubmit(newTeamGroup);
|
||
db.SubmitChanges();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 修改班组信息
|
||
/// </summary>
|
||
/// <param name="teamGroup"></param>
|
||
public static void UpdateTeamGroup(Model.Base_TeamGroup teamGroup)
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
Model.Base_TeamGroup newTeamGroup = db.Base_TeamGroup.First(e => e.TeamGroupId == teamGroup.TeamGroupId);
|
||
newTeamGroup.TeamGroupCode = teamGroup.TeamGroupCode;
|
||
newTeamGroup.TeamGroupName = teamGroup.TeamGroupName;
|
||
newTeamGroup.UnitId = teamGroup.UnitId;
|
||
newTeamGroup.ProjectId = teamGroup.ProjectId;
|
||
newTeamGroup.Remark = teamGroup.Remark;
|
||
newTeamGroup.Area = teamGroup.Area;
|
||
|
||
db.SubmitChanges();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是否存在班组编号
|
||
/// </summary>
|
||
/// <param name="teamGroupCode"></param>
|
||
/// <returns>true-存在,false-不存在</returns>
|
||
public static bool IsExistTeamGroupCode(string projectId, string teamGroupCode)
|
||
{
|
||
var q = from x in Funs.DB.Base_TeamGroup where x.ProjectId == projectId && x.TeamGroupCode == teamGroupCode select x;
|
||
if (q.Count() > 0)
|
||
{
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 删除班组信息
|
||
/// </summary>
|
||
/// <param name="teamGroupId"></param>
|
||
public static void DeleteTeamGroup(string teamGroupId)
|
||
{
|
||
Model.SGGLDB db = Funs.DB;
|
||
Model.Base_TeamGroup teamGroup = db.Base_TeamGroup.First(e => e.TeamGroupId == teamGroupId);
|
||
db.Base_TeamGroup.DeleteOnSubmit(teamGroup);
|
||
db.SubmitChanges();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据单位Id和项目ID查询班组信息
|
||
/// </summary>
|
||
/// <param name="projectId">项目Id</param>
|
||
/// <param name="unitId">单位Id</param>
|
||
/// <returns>班组信息</returns>
|
||
public static List<Model.Base_TeamGroup> GetTeamGroupByUnit(string projectId, string unitId)
|
||
{
|
||
return (from x in Funs.DB.Base_TeamGroup
|
||
where x.ProjectId==projectId && x.UnitId==unitId
|
||
orderby x.TeamGroupCode
|
||
select x).ToList();
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 根据区域获取班组数
|
||
/// </summary>
|
||
/// <param name="workAreaId"></param>
|
||
/// <returns></returns>
|
||
public static int GetTeamGroupCountByworkAreaId(string workAreaId)
|
||
{
|
||
var q = (from x in Funs.DB.Base_TeamGroup where x.Area == workAreaId select x).ToList();
|
||
return q.Count();
|
||
}
|
||
}
|
||
}
|