using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
    /// 
    /// 资料收发文登记记录
    /// 
    public class DataReceivingDocService
    {
        /// 
        /// 根据主键获取资料收发文登记记录
        /// 
        /// 
        /// 
        public static Model.Comprehensive_DataReceivingDoc GetDataReceivingDocById(string dataReceivingDocId)
        {
            return Funs.DB.Comprehensive_DataReceivingDoc.FirstOrDefault(e => e.DataReceivingDocId == dataReceivingDocId);
        }           
        /// 
        /// 添加资料收发文登记记录
        /// 
        /// 
        public static void AddDataReceivingDoc(Model.Comprehensive_DataReceivingDoc doc)
        {
            Model.Comprehensive_DataReceivingDoc newDoc = new Model.Comprehensive_DataReceivingDoc
            {
                DataReceivingDocId = doc.DataReceivingDocId,
                ProjectId = doc.ProjectId,
                FileCode = doc.FileCode,
                FileName = doc.FileName,
                ReceiveDate = doc.ReceiveDate,
                FileType = doc.FileType,
                CNProfessionalId = doc.CNProfessionalId,
                SendUnit = doc.SendUnit,
                SendMan = doc.SendMan,
                Copies = doc.Copies,
                DocumentHandler = doc.DocumentHandler,
                SendDate = doc.SendDate,
                ReceiveUnit = doc.ReceiveUnit,
                ReceiveMan = doc.ReceiveMan,
                IsReply = doc.IsReply,
                ReturnWuhuangDate = doc.ReturnWuhuangDate,
                RetrunWuhuangCopies = doc.RetrunWuhuangCopies,
                IssueToUnit = doc.IssueToUnit,
                IssueCopies = doc.IssueCopies,
                IssueUnitReceiver = doc.IssueUnitReceiver,
                IsOnFile = doc.IsOnFile,
                CompileMan = doc.CompileMan,
                CompileDate = doc.CompileDate,
                Status = doc.Status,
                AuditMan = doc.AuditMan,
                RemarkCode = doc.RemarkCode
            };
            Funs.DB.Comprehensive_DataReceivingDoc.InsertOnSubmit(newDoc);
            Funs.DB.SubmitChanges();
        }
        /// 
        /// 修改资料收发文登记记录
        /// 
        /// 
        public static void UpdateDataReceivingDoc(Model.Comprehensive_DataReceivingDoc doc)
        {
            Model.Comprehensive_DataReceivingDoc newDoc = Funs.DB.Comprehensive_DataReceivingDoc.FirstOrDefault(e => e.DataReceivingDocId == doc.DataReceivingDocId);
            if (newDoc != null)
            {
                newDoc.FileCode = doc.FileCode;
                newDoc.FileName = doc.FileName;
                newDoc.ReceiveDate = doc.ReceiveDate;
                newDoc.FileType = doc.FileType;
                newDoc.CNProfessionalId = doc.CNProfessionalId;
                newDoc.SendUnit = doc.SendUnit;
                newDoc.SendMan = doc.SendMan;
                newDoc.Copies = doc.Copies;
                newDoc.DocumentHandler = doc.DocumentHandler;
                newDoc.SendDate = doc.SendDate;
                newDoc.ReceiveUnit = doc.ReceiveUnit;
                newDoc.ReceiveMan = doc.ReceiveMan;
                newDoc.IsReply = doc.IsReply;
                newDoc.ReturnWuhuangDate = doc.ReturnWuhuangDate;
                newDoc.RetrunWuhuangCopies = doc.RetrunWuhuangCopies;
                newDoc.IssueToUnit = doc.IssueToUnit;
                newDoc.IssueCopies = doc.IssueCopies;
                newDoc.IssueUnitReceiver = doc.IssueUnitReceiver;
                newDoc.IsOnFile = doc.IsOnFile;
                newDoc.CompileMan = doc.CompileMan;
                newDoc.CompileDate = doc.CompileDate;
                newDoc.Status = doc.Status;
                newDoc.AuditMan = doc.AuditMan;
                newDoc.RemarkCode = doc.RemarkCode;
                Funs.DB.SubmitChanges();
            }
        }
        /// 
        /// 根据主键删除资料收发文登记记录
        /// 
        /// 
        public static void DeleteDataReceivingDocById(string docId)
        {
            Model.Comprehensive_DataReceivingDoc newDoc = Funs.DB.Comprehensive_DataReceivingDoc.FirstOrDefault(e => e.DataReceivingDocId == docId);
            if (newDoc != null)
            {
                Funs.DB.Comprehensive_DataReceivingDoc.DeleteOnSubmit(newDoc);
                Funs.DB.SubmitChanges();
            }
        }
    }
}