140 lines
4.7 KiB
C#
140 lines
4.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace BLL
|
|
{
|
|
/// <summary>
|
|
/// 部门
|
|
/// </summary>
|
|
public static class ContractorService
|
|
{
|
|
/// <summary>
|
|
/// 根据主键获取承包商信息
|
|
/// </summary>
|
|
/// <param name="departId"></param>
|
|
/// <returns></returns>
|
|
public static Model.Base_Contractor GetContractorById(string contractorId)
|
|
{
|
|
return Funs.DB.Base_Contractor.FirstOrDefault(e => e.ContractorId == contractorId);
|
|
}
|
|
|
|
// 根据简称获取承包商信息
|
|
public static Model.Base_Contractor GetContractorByShortName(string contractorShortName)
|
|
{
|
|
return Funs.DB.Base_Contractor.FirstOrDefault(e => e.ContractorShortName == contractorShortName);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取承包商列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static List<Model.Base_Contractor> GetContractorList()
|
|
{
|
|
return (from x in Funs.DB.Base_Contractor orderby x.ContractorName select x).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加承包商
|
|
/// </summary>
|
|
/// <param name="contractor"></param>
|
|
public static void AddContractor(Model.Base_Contractor contractor)
|
|
{
|
|
Model.Base_Contractor newContractor = new Model.Base_Contractor();
|
|
newContractor.ContractorId = contractor.ContractorId;
|
|
newContractor.ContractorName = contractor.ContractorName;
|
|
newContractor.ContractorShortName = contractor.ContractorShortName;
|
|
newContractor.Remark = contractor.Remark;
|
|
Funs.DB.Base_Contractor.InsertOnSubmit(newContractor);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改承包商
|
|
/// </summary>
|
|
/// <param name="depart"></param>
|
|
public static void UpdateContractor(Model.Base_Contractor contractor)
|
|
{
|
|
Model.Base_Contractor newContractor = Funs.DB.Base_Contractor.FirstOrDefault(e => e.ContractorId == contractor.ContractorId);
|
|
if (newContractor != null)
|
|
{
|
|
newContractor.ContractorName = contractor.ContractorName;
|
|
newContractor.ContractorShortName = contractor.ContractorShortName;
|
|
newContractor.Remark = contractor.Remark;
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键删除承包商信息
|
|
/// </summary>
|
|
/// <param name="departId"></param>
|
|
public static void DeleteContractorById(string contractorId)
|
|
{
|
|
Model.Base_Contractor contractor = Funs.DB.Base_Contractor.FirstOrDefault(e => e.ContractorId == contractorId);
|
|
if (contractor != null)
|
|
{
|
|
Funs.DB.Base_Contractor.DeleteOnSubmit(contractor);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 验证是否存在相同的承包商名称
|
|
/// </summary>
|
|
/// <param name="departCode"></param>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public static bool IsExitContractorName(string contractorName, string id)
|
|
{
|
|
var q = Funs.DB.Base_Contractor.FirstOrDefault(x => x.ContractorName == contractorName && x.ContractorId != id);
|
|
if (q != null)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 验证是否存在简写相同的承包商
|
|
/// </summary>
|
|
/// <param name="departCode"></param>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public static bool IsExitContractorShortName(string contractorShortName, string id)
|
|
{
|
|
var q = Funs.DB.Base_Contractor.FirstOrDefault(x => x.ContractorShortName == contractorShortName && x.ContractorId != id);
|
|
if (q != null)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取承包商下拉框
|
|
/// </summary>
|
|
/// <param name="dropName"></param>
|
|
/// <param name="isShowPlease"></param>
|
|
public static void InitContractorDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease)
|
|
{
|
|
dropName.DataValueField = "ContractorShortName";
|
|
dropName.DataTextField = "ContractorShortName";
|
|
dropName.DataSource = GetContractorList();
|
|
dropName.DataBind();
|
|
if (isShowPlease)
|
|
{
|
|
Funs.FineUIPleaseSelect(dropName);
|
|
}
|
|
}
|
|
}
|
|
}
|