159 lines
5.4 KiB
C#
159 lines
5.4 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace BLL
|
|
{
|
|
/// <summary>
|
|
/// 承包商
|
|
/// </summary>
|
|
public class ContractorService
|
|
{
|
|
/// <summary>
|
|
/// 根据主键获取承包商
|
|
/// </summary>
|
|
/// <param name="contractorId"></param>
|
|
/// <returns></returns>
|
|
public static Model.Base_Contractor GetContractorById(string contractorId)
|
|
{
|
|
return Funs.DB.Base_Contractor.FirstOrDefault(e => e.ContractorId == contractorId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取承包商列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static List<Model.View_Contractor_DropDownValue> GetContractorList()
|
|
{
|
|
return (from x in Funs.DB.View_Contractor_DropDownValue orderby x.Contractor 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.VendorNumber = contractor.VendorNumber;
|
|
newContractor.Contractor = contractor.Contractor;
|
|
newContractor.ContractorCN = contractor.ContractorCN;
|
|
newContractor.ContractorShortName = contractor.ContractorShortName;
|
|
Funs.DB.Base_Contractor.InsertOnSubmit(newContractor);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改承包商
|
|
/// </summary>
|
|
/// <param name="contractor"></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.VendorNumber = contractor.VendorNumber;
|
|
newContractor.Contractor = contractor.Contractor;
|
|
newContractor.ContractorCN = contractor.ContractorCN;
|
|
newContractor.ContractorShortName = contractor.ContractorShortName;
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键删除承包商
|
|
/// </summary>
|
|
/// <param name="contractorId"></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="contractor"></param>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public static bool IsExitContractor(string contractor, string id)
|
|
{
|
|
var q = Funs.DB.Base_Contractor.FirstOrDefault(x => x.Contractor == contractor && x.ContractorId != id);
|
|
if (q != null)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 验证是否存在相同的vendor号
|
|
/// </summary>
|
|
/// <param name="contractor"></param>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public static bool IsExitVendor(string vendor, string id)
|
|
{
|
|
var q = Funs.DB.Base_Contractor.FirstOrDefault(x => x.VendorNumber == vendor && x.ContractorId != id);
|
|
if (q != null)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 常量表下拉框
|
|
/// </summary>
|
|
/// <param name="dropName">下拉框名字</param>
|
|
/// <param name="isShowPlease">是否显示请选择</param>
|
|
public static void InitDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease)
|
|
{
|
|
dropName.DataValueField = "ContractorId";
|
|
dropName.DataTextField = "Contractor";
|
|
dropName.DataSource = GetContractorList();
|
|
dropName.DataBind();
|
|
if (isShowPlease)
|
|
{
|
|
Funs.FineUIPleaseSelect(dropName);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取中文承包商列表下拉项
|
|
/// </summary>
|
|
/// <param name="dropName"></param>
|
|
/// <param name="isShowPlease"></param>
|
|
public static void InitCNDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease)
|
|
{
|
|
dropName.DataValueField = "ContractorId";
|
|
dropName.DataTextField = "ContractorCN";
|
|
dropName.DataSource = GetContractorCNList();
|
|
dropName.DataBind();
|
|
if (isShowPlease)
|
|
{
|
|
Funs.FineUIPleaseSelect(dropName);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取承包商列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static List<Model.Base_Contractor> GetContractorCNList()
|
|
{
|
|
return (from x in Funs.DB.Base_Contractor orderby x.ContractorCN select x).ToList();
|
|
}
|
|
|
|
}
|
|
} |