using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
namespace BLL.CQMS.Comprehensive
{
    public class ContactListService
    {
        /// 
        /// 根据方案审查Id删除一个方案审查信息
        /// 
        /// 方案审查Id
        public static void DeletetContactList(string ContactListId)
        {
            Model.SGGLDB db = Funs.DB;
            Model.Comprehensive_ContactList visaApplication_Final = db.Comprehensive_ContactList.First(e => e.ContactListId == ContactListId);
            db.Comprehensive_ContactList.DeleteOnSubmit(visaApplication_Final);
            db.SubmitChanges();
        }
        /// 
        /// 增加方案审查信息
        /// 
        /// 方案审查实体
        public static void AddtContactList(Model.Comprehensive_ContactList contactList)
        {
            Model.SGGLDB db = Funs.DB;
            Model.Comprehensive_ContactList newContactList = new Model.Comprehensive_ContactList();
            newContactList.ContactListId = contactList.ContactListId;
            newContactList.ProjectId = contactList.ProjectId;
            newContactList.UnitId = contactList.UnitId;
            newContactList.CreateMan = contactList.CreateMan;
            newContactList.Remark = contactList.Remark;
            newContactList.CreateDate = contactList.CreateDate;
            newContactList.CNProfessionalId = contactList.CNProfessionalId;
            newContactList.ContactListCode = contactList.ContactListCode;
            db.Comprehensive_ContactList.InsertOnSubmit(newContactList);
            db.SubmitChanges();
        }
        /// 
        /// 修改方案审查信息
        /// 
        /// 方案审查实体
        public static void UpdatetContactList(Model.Comprehensive_ContactList contactList)
        {
            Model.SGGLDB db = Funs.DB;
            Model.Comprehensive_ContactList newContactList = db.Comprehensive_ContactList.FirstOrDefault(e => e.ContactListId == contactList.ContactListId);
            if (newContactList == null)
            {
                AddtContactList(contactList);
            }
            else
            {   newContactList.ProjectId = contactList.ProjectId;
                newContactList.UnitId = contactList.UnitId;
                newContactList.CreateMan = contactList.CreateMan;
                newContactList.Remark = contactList.Remark;
                newContactList.CreateDate = contactList.CreateDate;
                newContactList.CNProfessionalId = contactList.CNProfessionalId;
                newContactList.ContactListCode = contactList.ContactListCode;
                db.SubmitChanges();
            }
        }
        /// 
        /// 把状态转换代号为文字形式
        /// 
        /// 
        /// 
        /// 
        public static string ConvertState(object state)
        {
            if (state != null)
            {
                if (state.ToString() == BLL.Const.CQMSConstructSolution_ReCompile)
                {
                    return "重报";
                }
                else if (state.ToString() == BLL.Const.CQMSConstructSolution_Compile)
                {
                    return "编制";
                }
                else if (state.ToString() == BLL.Const.CQMSConstructSolution_Audit)
                {
                    return "会签";
                }
                else if (state.ToString() == BLL.Const.CQMSConstructSolution_Complete)
                {
                    return "审批完成";
                }
            }
            return "";
        }
        /// 
        /// 根据方案审查Id获取一个方案审查信息
        /// 
        /// 方案审查Id
        /// 一个方案审查实体
        public static Model.Comprehensive_ContactList GetContactListById(string ContactListId)
        {
            return Funs.DB.Comprehensive_ContactList.FirstOrDefault(x => x.ContactListId == ContactListId);
        }
    }   
      
}