ZHJA_HJGL/HJGL_ZH/BLL/HJGLServer/BaseInfo/HJGL_ComponentsService.cs

114 lines
3.6 KiB
C#
Raw Normal View History

2024-05-08 17:17:11 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Web.UI.WebControls;
namespace BLL
{
/// <summary>
/// 安装组件
/// </summary>
public static class HJGL_ComponentsService
{
/// <summary>
/// 根据安装组件ID获取安装组件信息
/// </summary>
/// <param name="com_id"></param>
/// <returns></returns>
public static Model.HJGL_BS_Component GetComponentByComID(string com_id)
{
return Funs.DB.HJGL_BS_Component.FirstOrDefault(e => e.COM_ID == com_id);
}
/// <summary>
/// 添加安装组件
/// </summary>
/// <param name="component"></param>
public static void AddComponent(Model.HJGL_BS_Component component)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_BS_Component newComponent = new Model.HJGL_BS_Component();
string newKeyID = SQLHelper.GetNewID(typeof(Model.HJGL_BS_Component));
newComponent.COM_ID = newKeyID;
newComponent.COM_Code = component.COM_Code;
newComponent.COM_Name = component.COM_Name;
newComponent.COM_Remark = component.COM_Remark;
db.HJGL_BS_Component.InsertOnSubmit(newComponent);
db.SubmitChanges();
}
/// <summary>
/// 修改安装组件
/// </summary>
/// <param name="component"></param>
public static void UpdateComponent(Model.HJGL_BS_Component component)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_BS_Component newComponent = db.HJGL_BS_Component.FirstOrDefault(e => e.COM_ID == component.COM_ID);
if (newComponent != null)
{
newComponent.COM_Code = component.COM_Code;
newComponent.COM_Name = component.COM_Name;
newComponent.COM_Remark = component.COM_Remark;
db.SubmitChanges();
}
}
/// <summary>
/// 删除安装组件
/// </summary>
/// <param name="com_id"></param>
public static void DeleteComponent(string com_id)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_BS_Component component = db.HJGL_BS_Component.FirstOrDefault(e => e.COM_ID == com_id);
if (component != null)
{
db.HJGL_BS_Component.DeleteOnSubmit(component);
db.SubmitChanges();
}
}
/// <summary>
/// 判断是否存在相同的组件代号
/// </summary>
/// <param name="com_code"></param>
/// <returns></returns>
public static bool IsExitComCode(string com_code, string id)
{
var q = Funs.DB.HJGL_BS_Component.FirstOrDefault(x => x.COM_Code == com_code && x.COM_ID != id);
if (q != null)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 获取焊缝类型名称
/// </summary>
/// <returns></returns>
public static List<Model.HJGL_BS_Component> GetComponentNameList()
{
var q = (from x in Funs.DB.HJGL_BS_Component orderby x.COM_Code select x).ToList();
return q;
}
/// <summary>
/// 组件代码获取组件代号信息
/// </summary>
/// <param name="unitCode"></param>
/// <returns></returns>
public static Model.HJGL_BS_Component GetComponentByComponentCode(string componentCode)
{
return Funs.DB.HJGL_BS_Component.FirstOrDefault(x => x.COM_Code == componentCode);
}
}
}