Пример #1
0
        /// <summary>
        /// 审核通过新建数据
        /// </summary>
        /// <param name="companyID">企业ID</param>
        /// <param name="cityID">缴纳地ID</param>
        /// <returns></returns>
        public bool PassAdd(SysEntities db, int companyID, string cityID)
        {
            try
            {
                int operateType  = (int)Common.OperateType.添加;
                int operateState = (int)Common.AuditStatus.待处理;
                //DateTime dtnow = DateTime.Now;
                var updI  = db.CRM_Company_Insurance_Audit.Where(c => c.CRM_Company_ID == companyID && c.City == cityID && c.OperateType == operateType && c.OperateStatus == operateState && c.OperateNode == 2);
                var updPI = db.CRM_Company_PoliceInsurance_Audit.Where(c => c.CRM_Company_ID == companyID && c.City == cityID && c.OperateType == operateType && c.OperateStatus == operateState && c.OperateNode == 2);
                List <CRM_Company_Insurance>       ListI  = new List <CRM_Company_Insurance>();
                List <CRM_Company_PoliceInsurance> ListPI = new List <CRM_Company_PoliceInsurance>();
                foreach (var modelI in updI)
                {
                    //设置成功
                    modelI.OperateStatus = (int)Common.AuditStatus.成功;
                    //数据复制到正式表
                    CRM_Company_Insurance entityI = new CRM_Company_Insurance();
                    entityI.Account        = modelI.Account;
                    entityI.City           = modelI.City;
                    entityI.CreatePerson   = modelI.CreatePerson;
                    entityI.CreateTime     = modelI.CreateTime;
                    entityI.CRM_Company_ID = companyID;
                    entityI.InsuranceKind  = modelI.InsuranceKind;
                    entityI.State          = modelI.State;
                    ListI.Add(entityI);
                }
                foreach (var modelPI in updPI)
                {
                    //设置成功
                    modelPI.OperateStatus = (int)Common.AuditStatus.成功;
                    //数据复制到正式表
                    CRM_Company_PoliceInsurance entityPI = new CRM_Company_PoliceInsurance();
                    entityPI.City            = modelPI.City;
                    entityPI.CreatePerson    = modelPI.CreatePerson;
                    entityPI.CreateTime      = modelPI.CreateTime;
                    entityPI.CRM_Company_ID  = companyID;
                    entityPI.InsuranceKind   = modelPI.InsuranceKind;
                    entityPI.PoliceInsurance = modelPI.PoliceInsurance;
                    entityPI.State           = modelPI.State;
                    ListPI.Add(entityPI);
                }
                db.CRM_Company_Insurance.AddRange(ListI);
                db.CRM_Company_PoliceInsurance.AddRange(ListPI);
                db.SaveChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 修改企业社保信息
        /// </summary>
        /// <param name="db"></param>
        /// <param name="model">社保信息实体</param>
        /// <param name="userID">操作人ID</param>
        /// <param name="userName">操作人姓名</param>
        /// <param name="branchID">所属分支机构</param>
        /// <returns></returns>
        public bool UpdateCRM_Company_Insurance(SysEntities db, CompanyInsurance model, int userID, string userName, int branchID)
        {
            try
            {
                DateTime dtnow = DateTime.Now;
                List <CRM_Company_Insurance_Audit> ListI  = new List <CRM_Company_Insurance_Audit>();
                CRM_Company_Insurance_Audit        ModelI = new CRM_Company_Insurance_Audit();

                List <CRM_Company_PoliceInsurance_Audit> ListPI  = new List <CRM_Company_PoliceInsurance_Audit>();
                CRM_Company_PoliceInsurance_Audit        ModelPI = new CRM_Company_PoliceInsurance_Audit();

                string[] Accounts = model.Account1 == null ? null : model.Account1.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                string[] Polices1 = model.PoliceID1 == null ? null : model.PoliceID1.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                string[] Polices2 = model.PoliceID2 == null ? null : model.PoliceID2.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);


                List <CRM_Company_Insurance>       ListI_Old  = db.CRM_Company_Insurance.Where(c => c.City == model.CityId && c.CRM_Company_ID == model.CRM_Company_ID).OrderBy(c => c.InsuranceKind).ToList();
                List <CRM_Company_PoliceInsurance> ListPI_Old = db.CRM_Company_PoliceInsurance.Where(c => c.City == model.CityId && c.CRM_Company_ID == model.CRM_Company_ID).OrderBy(c => c.InsuranceKind).ToList();


                //公积金账户
                if (!string.IsNullOrEmpty(model.Account2))
                {
                    ModelI                = new CRM_Company_Insurance_Audit();
                    ModelI.Account        = model.Account2;
                    ModelI.InsuranceKind  = (int)Common.EmployeeAdd_InsuranceKindId.公积金;
                    ModelI.CRM_Company_ID = model.CRM_Company_ID;
                    ModelI.City           = model.CityId;

                    CRM_Company_Insurance oldGGJ = ListI_Old.Where(c => c.InsuranceKind == ModelI.InsuranceKind).ToList().FirstOrDefault();
                    if (oldGGJ != null)
                    {
                        ModelI.CRM_Company_Insurance_ID = oldGGJ.ID;
                    }

                    ModelI.State         = Common.Status.启用.ToString();
                    ModelI.CreateTime    = dtnow;
                    ModelI.CreateUserID  = userID;
                    ModelI.CreatePerson  = userName;
                    ModelI.OperateStatus = (int)Common.AuditStatus.待处理; //待处理
                    ModelI.OperateNode   = 2;                           //质控
                    ModelI.BranchID      = branchID;
                    ModelI.OperateType   = (int)Common.OperateType.修改;

                    ListI.Add(ModelI);
                }

                //社保账户
                if (!string.IsNullOrEmpty(model.Account1))
                {
                    foreach (string acc in Accounts)
                    {
                        string[] account = acc.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

                        if (account.Length == 2 && !string.IsNullOrEmpty(account[1]))
                        {
                            Common.EmployeeAdd_InsuranceKindId getType = (Common.EmployeeAdd_InsuranceKindId)Enum.Parse(typeof(Common.EmployeeAdd_InsuranceKindId), account[0]);

                            ModelI               = new CRM_Company_Insurance_Audit();
                            ModelI.Account       = account[1];
                            ModelI.InsuranceKind = (int)getType;

                            ModelI.CRM_Company_ID = model.CRM_Company_ID;
                            ModelI.City           = model.CityId;

                            CRM_Company_Insurance oldInsurance = ListI_Old.Where(c => c.InsuranceKind == ModelI.InsuranceKind).ToList().FirstOrDefault();
                            if (oldInsurance != null)
                            {
                                ModelI.CRM_Company_Insurance_ID = oldInsurance.ID;
                            }
                            //ModelI.CRM_Company_Insurance_ID = ListI_Old.Where(c => c.InsuranceKind == ModelI.InsuranceKind).ToList().FirstOrDefault().ID;

                            ModelI.State         = Common.Status.启用.ToString();
                            ModelI.CreateTime    = dtnow;
                            ModelI.CreateUserID  = userID;
                            ModelI.CreatePerson  = userName;
                            ModelI.OperateStatus = (int)Common.AuditStatus.待处理; //待处理
                            ModelI.OperateNode   = 2;                           //质控
                            ModelI.BranchID      = branchID;
                            ModelI.OperateType   = (int)Common.OperateType.修改;

                            ListI.Add(ModelI);
                        }
                    }
                }
                //公积金政策
                if (!string.IsNullOrEmpty(model.PoliceID2))
                {
                    foreach (string po in Polices2)
                    {
                        ModelPI = new CRM_Company_PoliceInsurance_Audit();


                        ModelPI.PoliceInsurance = Convert.ToInt32(po);
                        ModelPI.InsuranceKind   = (int)Common.EmployeeAdd_InsuranceKindId.公积金;

                        ModelPI.CRM_Company_ID = model.CRM_Company_ID;
                        ModelPI.City           = model.CityId;

                        CRM_Company_PoliceInsurance oldPiGGJ = ListPI_Old.Where(c => c.InsuranceKind == ModelPI.InsuranceKind).ToList().FirstOrDefault();
                        if (oldPiGGJ != null)
                        {
                            ModelPI.CRM_Company_PoliceInsurance_ID = oldPiGGJ.ID;
                        }
                        //ModelPI.CRM_Company_PoliceInsurance_ID = ListPI_Old.Where(c => c.InsuranceKind == ModelPI.InsuranceKind).ToList().FirstOrDefault().ID;

                        ModelPI.State         = Common.Status.启用.ToString();
                        ModelPI.CreateTime    = dtnow;
                        ModelPI.CreateUserID  = userID;
                        ModelPI.CreatePerson  = userName;
                        ModelPI.OperateStatus = (int)Common.AuditStatus.待处理; //待处理
                        ModelPI.OperateNode   = 2;                           //质控
                        ModelPI.BranchID      = branchID;
                        ModelPI.OperateType   = (int)Common.OperateType.修改;

                        ListPI.Add(ModelPI);
                    }
                }


                //工伤政策
                if (!string.IsNullOrEmpty(model.PoliceID1))
                {
                    foreach (string po in Polices1)
                    {
                        ModelPI = new CRM_Company_PoliceInsurance_Audit();

                        ModelPI.PoliceInsurance = Convert.ToInt32(po);
                        ModelPI.InsuranceKind   = (int)Common.EmployeeAdd_InsuranceKindId.工伤;

                        ModelPI.CRM_Company_ID = model.CRM_Company_ID;
                        ModelPI.City           = model.CityId;

                        CRM_Company_PoliceInsurance oldPiGS = ListPI_Old.Where(c => c.InsuranceKind == ModelPI.InsuranceKind).ToList().FirstOrDefault();
                        if (oldPiGS != null)
                        {
                            ModelPI.CRM_Company_PoliceInsurance_ID = oldPiGS.ID;
                        }

                        ModelPI.State         = Common.Status.启用.ToString();
                        ModelPI.CreateTime    = dtnow;
                        ModelPI.CreateUserID  = userID;
                        ModelPI.CreatePerson  = userName;
                        ModelPI.OperateStatus = (int)Common.AuditStatus.待处理; //待处理
                        ModelPI.OperateNode   = 2;                           //质控
                        ModelPI.BranchID      = branchID;
                        ModelPI.OperateType   = (int)Common.OperateType.修改;

                        ListPI.Add(ModelPI);
                    }
                }

                db.CRM_Company_Insurance_Audit.AddRange(ListI);
                db.CRM_Company_PoliceInsurance_Audit.AddRange(ListPI);

                foreach (var Iold in ListI_Old)
                {
                    Iold.State = Common.Status.修改中.ToString();
                }

                foreach (var PIold in ListPI_Old)
                {
                    PIold.State = Common.Status.修改中.ToString();
                }

                db.SaveChanges();
                return(true);
            }
            catch
            {
                return(false);
            }
        }