123 lines
4.6 KiB
C#
123 lines
4.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace BLL
|
|
{
|
|
public class Base_OrganizationService
|
|
{
|
|
public static Model.SGGLDB db = Funs.DB;
|
|
|
|
/// <summary>
|
|
///获取机构管理信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static Model.Base_Organization GetOrganizationByOrganizationId(string organizationId)
|
|
{
|
|
return Funs.DB.Base_Organization.FirstOrDefault(e => e.OrganizationId == organizationId);
|
|
}
|
|
|
|
/// <summary>
|
|
///获取机构管理信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static List<Model.Base_Organization> GetOrganizationsByUnitId(string projectId, string unitId)
|
|
{
|
|
return (from x in Funs.DB.Base_Organization where x.UnitId == unitId && x.ProjectId == projectId select x).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 增加机构管理信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static void AddOrganization(Model.Base_Organization organization)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
string newKeyID = SQLHelper.GetNewID(typeof(Model.Base_Organization));
|
|
Model.Base_Organization newOrganization = new Model.Base_Organization();
|
|
newOrganization.OrganizationId = newKeyID;
|
|
newOrganization.ProjectId = organization.ProjectId;
|
|
newOrganization.UnitId = organization.UnitId;
|
|
newOrganization.Post = organization.Post;
|
|
newOrganization.CardNo = organization.CardNo;
|
|
newOrganization.PersonName = organization.PersonName;
|
|
newOrganization.CellPhone = organization.CellPhone;
|
|
newOrganization.Telephone = organization.Telephone;
|
|
newOrganization.Email = organization.Email;
|
|
|
|
db.Base_Organization.InsertOnSubmit(newOrganization);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
///修改机构管理信息
|
|
/// </summary>
|
|
/// <param name="organization"></param>
|
|
public static void UpdateOrganization(Model.Base_Organization organization)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.Base_Organization newOrganization = db.Base_Organization.First(e => e.OrganizationId == organization.OrganizationId);
|
|
newOrganization.ProjectId = organization.ProjectId;
|
|
newOrganization.UnitId = organization.UnitId;
|
|
newOrganization.Post = organization.Post;
|
|
newOrganization.CardNo = organization.CardNo;
|
|
newOrganization.PersonName = organization.PersonName;
|
|
newOrganization.CellPhone = organization.CellPhone;
|
|
newOrganization.Telephone = organization.Telephone;
|
|
newOrganization.Email = organization.Email;
|
|
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除所有机构管理信息
|
|
/// </summary>
|
|
public static void DeleteOrganizationByUnitId(string unitId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
var q = (from x in db.Base_Organization where x.UnitId == unitId select x).ToList();
|
|
|
|
db.Base_Organization.DeleteAllOnSubmit(q);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除组织机构
|
|
/// </summary>
|
|
/// <param name="organizationId"></param>
|
|
public static void DeleteOrganization(string organizationId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
var q = Funs.DB.Base_Organization.FirstOrDefault(e => e.OrganizationId == organizationId);
|
|
if (q != null)
|
|
{
|
|
db.Base_Organization.DeleteOnSubmit(q);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据单位主键获得机构管理的数量
|
|
/// </summary>
|
|
/// <param name="unitId">单位主键</param>
|
|
/// <returns></returns>
|
|
public static int GetOrganizationCountByUnitId(string unitId)
|
|
{
|
|
var q = (from x in Funs.DB.Base_Organization where x.UnitId == unitId select x).ToList();
|
|
return q.Count();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据项目主键获得机构管理的数量
|
|
/// </summary>
|
|
/// <param name="projectId">项目主键</param>
|
|
/// <returns></returns>
|
|
public static int GetOrganizationCountByProjectId(string projectId)
|
|
{
|
|
var q = (from x in Funs.DB.Base_Organization where x.ProjectId == projectId select x).ToList();
|
|
return q.Count();
|
|
}
|
|
}
|
|
}
|