116 lines
4.5 KiB
C#
116 lines
4.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace BLL
|
|
{
|
|
/// <summary>
|
|
/// 规格
|
|
/// </summary>
|
|
public static class SpecificationsService
|
|
{
|
|
/// <summary>
|
|
/// 根据主键获取规格
|
|
/// </summary>
|
|
/// <param name="specificationsId"></param>
|
|
/// <returns></returns>
|
|
public static Model.Weld_Specifications GetSpecificationsById(string specificationsId)
|
|
{
|
|
return Funs.DB.Weld_Specifications.FirstOrDefault(e => e.SpecificationsId == specificationsId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加规格设置
|
|
/// </summary>
|
|
/// <param name="specifications"></param>
|
|
public static void AddSpecifications(Model.Weld_Specifications specifications)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.Weld_Specifications newSpecifications = new Model.Weld_Specifications();
|
|
newSpecifications.SpecificationsId = specifications.SpecificationsId;
|
|
newSpecifications.Specifications = specifications.Specifications;
|
|
newSpecifications.MaxUsingNum = specifications.MaxUsingNum;
|
|
newSpecifications.WeldTypeId = specifications.WeldTypeId;
|
|
newSpecifications.CreateMan = specifications.CreateMan;
|
|
newSpecifications.Remark = specifications.Remark;
|
|
db.Weld_Specifications.InsertOnSubmit(newSpecifications);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改规格设置
|
|
/// </summary>
|
|
/// <param name="specifications"></param>
|
|
public static void UpdateSpecifications(Model.Weld_Specifications specifications)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.Weld_Specifications newSpecifications = db.Weld_Specifications.FirstOrDefault(e => e.SpecificationsId == specifications.SpecificationsId);
|
|
if (newSpecifications != null)
|
|
{
|
|
newSpecifications.Specifications = specifications.Specifications;
|
|
newSpecifications.WeldTypeId = specifications.WeldTypeId;
|
|
newSpecifications.MaxUsingNum = specifications.MaxUsingNum;
|
|
newSpecifications.ModifyMan = specifications.ModifyMan;
|
|
newSpecifications.Remark = specifications.Remark;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键删除规格设置
|
|
/// </summary>
|
|
/// <param name="specificationsId"></param>
|
|
public static void DeleteSpecificationsById(string specificationsId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.Weld_Specifications specifications = db.Weld_Specifications.FirstOrDefault(e => e.SpecificationsId == specificationsId);
|
|
if (specifications != null)
|
|
{
|
|
db.Weld_Specifications.DeleteOnSubmit(specifications);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据焊材类型获取相关规格
|
|
/// </summary>
|
|
/// <param name="weldTypeId"></param>
|
|
/// <returns></returns>
|
|
public static List<Model.Weld_Specifications> GetSpecificationsByWeldTypeId(string weldTypeId)
|
|
{
|
|
return (from x in Funs.DB.Weld_Specifications where x.WeldTypeId == weldTypeId orderby x.Specifications select x).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 验证规格是否存在
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public static bool IsExitSpecifications(string weldTypeId, string specifications, string id)
|
|
{
|
|
var q = Funs.DB.Weld_Specifications.FirstOrDefault(x => x.WeldTypeId == weldTypeId && x.Specifications == specifications && x.SpecificationsId != id);
|
|
if (q != null)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据焊材类型、规格获取规格设置信息
|
|
/// </summary>
|
|
/// <param name="weldTypeId"></param>
|
|
/// <param name="spec"></param>
|
|
/// <returns></returns>
|
|
public static Model.Weld_Specifications GetSpecificationsByWeldTypeIdSpec(string weldTypeId, string spec)
|
|
{
|
|
return Funs.DB.Weld_Specifications.FirstOrDefault(e => e.WeldTypeId == weldTypeId && e.Specifications == spec);
|
|
}
|
|
}
|
|
}
|