using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BLL { /// /// 规格 /// public static class SpecificationsService { /// /// 根据主键获取规格 /// /// /// public static Model.Weld_Specifications GetSpecificationsById(string specificationsId) { return Funs.DB.Weld_Specifications.FirstOrDefault(e => e.SpecificationsId == specificationsId); } /// /// 添加规格设置 /// /// 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(); } /// /// 修改规格设置 /// /// 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(); } } /// /// 根据主键删除规格设置 /// /// 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(); } } /// /// 根据焊材类型获取相关规格 /// /// /// public static List GetSpecificationsByWeldTypeId(string weldTypeId) { return (from x in Funs.DB.Weld_Specifications where x.WeldTypeId == weldTypeId orderby x.Specifications select x).ToList(); } /// /// 验证规格是否存在 /// /// /// /// 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; } } /// /// 根据焊材类型、规格获取规格设置信息 /// /// /// /// public static Model.Weld_Specifications GetSpecificationsByWeldTypeIdSpec(string weldTypeId, string spec) { return Funs.DB.Weld_Specifications.FirstOrDefault(e => e.WeldTypeId == weldTypeId && e.Specifications == spec); } } }