using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
namespace BLL
{
    /// 
    /// 施工标准规范
    /// 
    public static class ConstructionStandardListService
    { 
        /// 
      /// 根据标准规范清单Id获取一个标准规范清单信息
      /// 
      /// 标准规范清单Id
      /// 一个标准规范清单实体
        public static Model.CQMS_Law_ConstructionStandardList GetConstructionStandardListByStandardCode(int standardCode)
        {
            return Funs.DB.CQMS_Law_ConstructionStandardList.FirstOrDefault(x => x.StandardCode == standardCode);
        }
        /// 
        /// 查询的标准规范信息的数量
        /// 
        /// 标准规范信息的数量
        public static int GetCountConstructionStandardList()
        {
            return (from x in Funs.DB.CQMS_Law_ConstructionStandardList select x).Count();
        }
        /// 
        /// 查询最大的标准规范序号
        /// 
        /// 最大的标准规范序号
        public static int GetMaxStandardCode()
        {
            return (from x in Funs.DB.CQMS_Law_ConstructionStandardList select x.StandardCode).Max();
        }
        /// 
        /// 增加标准规范清单信息
        /// 
        /// 标准规范清单实体
        public static void AddConstructionStandardList(Model.CQMS_Law_ConstructionStandardList ConstructionStandardList)
        {
            Model.CQMS_Law_ConstructionStandardList newConstructionStandardList = new Model.CQMS_Law_ConstructionStandardList();
            newConstructionStandardList.StandardCode = ConstructionStandardList.StandardCode;
            newConstructionStandardList.StandardGrade = ConstructionStandardList.StandardGrade;
            newConstructionStandardList.StandardNo = ConstructionStandardList.StandardNo;
            newConstructionStandardList.StandardName = ConstructionStandardList.StandardName;
            newConstructionStandardList.AttachUrl = ConstructionStandardList.AttachUrl;
            newConstructionStandardList.Memo = ConstructionStandardList.Memo;
            newConstructionStandardList.Status = ConstructionStandardList.Status;
            newConstructionStandardList.ImpDate = ConstructionStandardList.ImpDate;
            newConstructionStandardList.PubDate = ConstructionStandardList.PubDate;
            newConstructionStandardList.UseLevel = ConstructionStandardList.UseLevel;
            newConstructionStandardList.StandardType = ConstructionStandardList.StandardType;
            newConstructionStandardList.ReplaceStandard = ConstructionStandardList.ReplaceStandard;
            newConstructionStandardList.IsSelected1 = ConstructionStandardList.IsSelected1;
            newConstructionStandardList.IsSelected2 = ConstructionStandardList.IsSelected2;
            newConstructionStandardList.IsSelected3 = ConstructionStandardList.IsSelected3;
            newConstructionStandardList.IsSelected4 = ConstructionStandardList.IsSelected4;
            newConstructionStandardList.IsSelected5 = ConstructionStandardList.IsSelected5;
            newConstructionStandardList.IsSelected6 = ConstructionStandardList.IsSelected6;
            newConstructionStandardList.IsSelected7 = ConstructionStandardList.IsSelected7;
            newConstructionStandardList.IsSelected8 = ConstructionStandardList.IsSelected8;
            newConstructionStandardList.IsSelected9 = ConstructionStandardList.IsSelected9;
            newConstructionStandardList.IsSelected10 = ConstructionStandardList.IsSelected10;
            Funs.DB.CQMS_Law_ConstructionStandardList.InsertOnSubmit(newConstructionStandardList);
            Funs.DB.SubmitChanges();
        }
        /// 
        /// 修改标准规范清单信息
        /// 
        /// 标准规范清单实体
        public static void UpdateConstructionStandardList(Model.CQMS_Law_ConstructionStandardList ConstructionStandardList)
        {
            Model.CQMS_Law_ConstructionStandardList newConstructionStandardList = Funs.DB.CQMS_Law_ConstructionStandardList.FirstOrDefault(e => e.StandardCode == ConstructionStandardList.StandardCode);
            if (newConstructionStandardList != null)
            {
                newConstructionStandardList.StandardGrade = ConstructionStandardList.StandardGrade;
                newConstructionStandardList.StandardNo = ConstructionStandardList.StandardNo;
                newConstructionStandardList.StandardName = ConstructionStandardList.StandardName;
                newConstructionStandardList.AttachUrl = ConstructionStandardList.AttachUrl;
                newConstructionStandardList.Memo = ConstructionStandardList.Memo;
                newConstructionStandardList.Status = ConstructionStandardList.Status;
                newConstructionStandardList.ImpDate = ConstructionStandardList.ImpDate;
                newConstructionStandardList.PubDate = ConstructionStandardList.PubDate;
                newConstructionStandardList.UseLevel = ConstructionStandardList.UseLevel;
                newConstructionStandardList.StandardType = ConstructionStandardList.StandardType;
                newConstructionStandardList.ReplaceStandard = ConstructionStandardList.ReplaceStandard;
                newConstructionStandardList.IsSelected1 = ConstructionStandardList.IsSelected1;
                newConstructionStandardList.IsSelected2 = ConstructionStandardList.IsSelected2;
                newConstructionStandardList.IsSelected3 = ConstructionStandardList.IsSelected3;
                newConstructionStandardList.IsSelected4 = ConstructionStandardList.IsSelected4;
                newConstructionStandardList.IsSelected5 = ConstructionStandardList.IsSelected5;
                newConstructionStandardList.IsSelected6 = ConstructionStandardList.IsSelected6;
                Funs.DB.SubmitChanges();
            }
        }
        /// 
        /// 根据标准规范清单Id删除一个标准规范清单信息
        /// 
        /// 标准规范清单Id
        public static void DeleteConstructionStandardList(int standardCode)
        {
            Model.CQMS_Law_ConstructionStandardList ConstructionStandardList = Funs.DB.CQMS_Law_ConstructionStandardList.FirstOrDefault(e => e.StandardCode == standardCode);
            if (ConstructionStandardList != null)
            {
                Funs.DB.CQMS_Law_ConstructionStandardList.DeleteOnSubmit(ConstructionStandardList);
                Funs.DB.SubmitChanges();
            }
        }        
    }
}