using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
    public static class GJSXProcessService
    {
        public static Model.SGGLDB db = Funs.DB;
        /// 
        /// 添加
        /// 
        /// 
        public static void AddProcess(Model.GJSX_Process process)
        {
            Model.SGGLDB db = Funs.DB;
            Model.GJSX_Process newProcess = new Model.GJSX_Process();
            string newKeyID = SQLHelper.GetNewID(typeof(Model.GJSX_Process));
            newProcess.ProcessID = newKeyID;
            newProcess.UserId = process.UserId;
            newProcess.GJSXID = process.GJSXID;
            db.GJSX_Process.InsertOnSubmit(newProcess);
            db.SubmitChanges();
        }
        /// 
        /// 删除
        /// 
        /// 
        public static void DeleteProcess(string GJSXID)
        {
            Model.SGGLDB db = Funs.DB;
            var q = (from x in db.GJSX_Process where x.GJSXID == GJSXID select x).ToList();
            if (q != null)
            {
                db.GJSX_Process.DeleteAllOnSubmit(q);
                db.SubmitChanges();
            }
        }
        /// 
        /// 根据事项进展操作人获取事项进展信息
        /// 
        /// 
        /// 
        public static int GetGJSXProcessByUserId(string userId)
        {
            return (from x in Funs.DB.GJSX_Process where x.UserId == userId select x).Count();
        }
        /// 
        /// 根据事项进展操作人获取事项进展信息
        /// 
        /// 
        /// 
        public static int GetGJSXProcessByGJSXIDAndUserId(string GJSXID, string userId)
        {
            return (from x in Funs.DB.GJSX_Process where x.GJSXID == GJSXID && x.UserId == userId select x).Count();
        }
        /// 
        /// 根据编号获取下一接收人信息
        /// 
        /// 
        /// 
        public static List GetProcessListByGJSXID(string GJSXID)
        {
            return (from x in Funs.DB.GJSX_Process where x.GJSXID == GJSXID select x.UserId).Distinct().ToList();
        }
    }
}