Exemple #1
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="personName">用户名</param>
        /// <param name="oldPassword">旧密码</param>
        /// <param name="newPassword">新密码</param>
        /// <returns>修改密码是否成功</returns>
        public bool ChangePassword(string personName, string oldPassword, string newPassword)
        {
            if (!string.IsNullOrWhiteSpace(personName) && !string.IsNullOrWhiteSpace(oldPassword) && !string.IsNullOrWhiteSpace(newPassword))
            {
                try
                {
                 string   oldPasswordEncryptString = EncryptAndDecrypte.EncryptString(oldPassword);
                string    newPasswordEncryptString = EncryptAndDecrypte.EncryptString(newPassword);

                    using (SysEntities db = new SysEntities())
                    {
                        var person = db.SysPerson.FirstOrDefault(p => (p.Name == personName) && (p.Password == oldPasswordEncryptString));
                        person.Password = newPasswordEncryptString;
                        person.SurePassword = newPasswordEncryptString;
                        if (!string.IsNullOrWhiteSpace(person.EmailAddress))
                        {
                            NetSendMail.MailSendChangePassword(db, person.EmailAddress, personName, newPassword);
                            //发送通知的邮件

                        }

                        db.SaveChanges();
                        return true;
                    }
                }
                catch (Exception ex)
                {
                    ExceptionsHander.WriteExceptions(ex);
                }

            }
            return false;
        }
Exemple #2
0
        /// <summary>
        /// 验证用户名和密码是否正确
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="password">密码</param>
        /// <returns>登录成功后的用户信息</returns>
        public SysPerson ValidateUser(string userName, string password)
        {
            if (String.IsNullOrWhiteSpace(userName) || String.IsNullOrWhiteSpace(password))
                return null;

            //获取用户信息,请确定web.config中的连接字符串正确
            using (SysEntities db = new SysEntities())
            {
                var person = (from p in db.SysPerson
                              where p.Name == userName
                              && p.Password == password
                              && p.State == "开启"
                              select p).FirstOrDefault();
                if (person != null)
                {//登录成功
                    person.LastLogonTime = person.LogonTime;
                    person.LastLogonIP = person.LogonIP;
                    person.LogonNum++;
                    person.LogonTime = DateTime.Now;
                    person.LogonIP = Common.IP.GetIP();
                    db.SaveChanges();
                    return person;
                }

            } return null;
        }
Exemple #3
0
        /// <summary>
        /// 创建一个菜单
        /// </summary>
        /// <param name="validationErrors">返回的错误信息</param>
        /// <param name="db">数据库上下文</param>
        /// <param name="entity">一个菜单</param>
        /// <returns></returns>
        public bool Create(ref ValidationErrors validationErrors, SysEntities db, SysMenu entity)
        {
            int count = 1;

            foreach (string item in entity.SysOperationId.GetIdSort())
            {
                SysOperation sys = new SysOperation { Id = item };
                db.SysOperation.Attach(sys);
                entity.SysOperation.Add(sys);
                count++;
            }

            repository.Create(db, entity);
            if (count == repository.Save(db))
            {
                //创建后重置菜单编码
                List<int> flags = new List<int>();//层级
                GetMenus2(null, flags);
                db.SaveChanges();
                return true;
            }
            else
            {
                validationErrors.Add("创建出错了");
            }
            return false;
        }
Exemple #4
0
        /// <summary>
        /// 添加员工
        /// </summary>
        /// <param name="baseModel"></param>
        /// <param name="contactModel"></param>
        /// <param name="bankModel"></param>
        /// <returns></returns>
        public int EmployeeAdd(Employee baseModel, EmployeeContact contactModel, EmployeeBank bankModel, CompanyEmployeeRelation relationModel)
        {
            using (SysEntities db = new SysEntities())
            {
                using (var tran = db.Database.BeginTransaction())
                {
                    try
                    {
                        //创建公司
                        db.Employee.Add(baseModel);
                        db.SaveChanges();

                        //添加联系方式
                        contactModel.EmployeeId = baseModel.Id;
                        db.EmployeeContact.Add(contactModel);

                        //添加银行信息
                        if (bankModel != null)
                        {
                            bankModel.EmployeeId = baseModel.Id;
                            db.EmployeeBank.Add(bankModel);
                        }

                        //企业员工关系
                        relationModel.EmployeeId = baseModel.Id;
                        db.CompanyEmployeeRelation.Add(relationModel);

                        db.SaveChanges();
                        tran.Commit();
                        return(1);
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        return(0);
                    }
                }
            }
        }
        /// <summary>
        /// 退回企业合同信息修改审核
        /// </summary>
        /// <param name="ID">审核表ID</param>
        /// <param name="mainTableID">原表ID</param>
        /// <returns></returns>
        public int ReturnEdit(int ID, int mainTableID)
        {
            using (SysEntities db = new SysEntities())
            {
                CRM_CompanyContract comModel = db.CRM_CompanyContract.Where(e => e.ID == mainTableID).FirstOrDefault();
                comModel.Status = 1;//启用

                CRM_CompanyContract_Audit comAudit = db.CRM_CompanyContract_Audit.Where(c => c.ID == ID).FirstOrDefault();
                comAudit.OperateStatus = 0;//未通过

                return(db.SaveChanges());
            }
        }
Exemple #6
0
        /// <summary>
        /// 提交企业银行信息修改审核
        /// </summary>
        /// <param name="ID">审核表ID</param>
        /// <param name="mainTableID">原表ID</param>
        /// <returns></returns>
        public int PassEdit(int ID, int mainTableID)
        {
            using (SysEntities db = new SysEntities())
            {
                CRM_CompanyBankAccount_Audit comAudit = db.CRM_CompanyBankAccount_Audit.Where(c => c.ID == ID).FirstOrDefault();
                comAudit.OperateStatus = 2;//成功

                CRM_CompanyBankAccount comModel = db.CRM_CompanyBankAccount.Where(e => e.ID == mainTableID).FirstOrDefault();
                comModel.Account = comAudit.Account;
                comModel.Bank    = comAudit.Bank;
                comModel.Status  = 1;//启用
                return(db.SaveChanges());
            }
        }
Exemple #7
0
        /// <summary>
        /// 提交企业财务信息(开票)修改审核
        /// </summary>
        /// <param name="ID">审核表ID</param>
        /// <param name="mainTableID">原表ID</param>
        /// <returns></returns>
        public int PassEdit(int ID, int mainTableID)
        {
            using (SysEntities db = new SysEntities())
            {
                CRM_CompanyFinance_Bill_Audit comAudit = db.CRM_CompanyFinance_Bill_Audit.Where(c => c.ID == ID).FirstOrDefault();
                comAudit.OperateStatus = 2;//成功

                CRM_CompanyFinance_Bill comModel = db.CRM_CompanyFinance_Bill.Where(e => e.ID == mainTableID).FirstOrDefault();
                comModel.BillName          = comAudit.BillName;
                comModel.TaxRegistryNumber = comAudit.TaxRegistryNumber;
                comModel.Status            = 1;//启用
                return(db.SaveChanges());
            }
        }
        /// <summary>
        /// 提交企业报价信息修改审核
        /// </summary>
        /// <param name="ID">审核表ID</param>
        /// <param name="mainTableID">原表ID</param>
        /// <returns></returns>
        public int PassEdit(int ID, int mainTableID)
        {
            using (SysEntities db = new SysEntities())
            {
                CRM_CompanyPrice_Audit comAudit = db.CRM_CompanyPrice_Audit.Where(c => c.ID == ID).FirstOrDefault();
                comAudit.OperateStatus = 2;//成功

                CRM_CompanyPrice comModel = db.CRM_CompanyPrice.Where(e => e.ID == mainTableID).FirstOrDefault();
                comModel.AddPrice       = comAudit.AddPrice;
                comModel.LowestPrice    = comAudit.LowestPrice;
                comModel.PRD_Product_ID = comAudit.PRD_Product_ID;
                comModel.Status         = 1;//启用
                return(db.SaveChanges());
            }
        }
 /// <summary>
 /// 修改默认联系人
 /// </summary>
 /// <param name="id">联系人表id</param>
 /// <returns></returns>
 public int SetDefault(int id, int companyID)
 {
     using (SysEntities db = new SysEntities())
     {
         var data = db.CRM_CompanyLinkMan.Where(e => (e.CRM_Company_ID == companyID && e.IsDefault == "Y"));
         if (data.Count() > 0)
         {
             foreach (var item in data)
             {
                 item.IsDefault = "N";
             }
         }
         db.CRM_CompanyLinkMan.Where(e => e.ID == id).FirstOrDefault().IsDefault = "Y";
         return(db.SaveChanges());
     }
 }
Exemple #10
0
 /// <summary>
 /// 修改默认联系人
 /// </summary>
 /// <param name="id">联系人表id</param>
 /// <returns></returns>
 public int SetDefault(string id, int supplierID)
 {
     using (SysEntities db = new SysEntities())
     {
         var data = db.SupplierLinkMan.Where(e => (e.SupplierId == supplierID && e.IsDefault == "Y"));
         if (data.Count() > 0)
         {
             foreach (var item in data)
             {
                 item.IsDefault = "N";
             }
         }
         db.SupplierLinkMan.Where(e => e.Id == id).FirstOrDefault().IsDefault = "Y";
         return(db.SaveChanges());
     }
 }
 /// <summary>
 /// 提交企业阶梯报价信息修改审核
 /// </summary>
 /// <param name="entity">修改信息</param>
 /// <returns></returns>
 public int ModifyLadderPrice(CRM_CompanyLadderPrice_Audit entity)
 {
     if (entity != null)
     {
         using (SysEntities db = new SysEntities())
         {
             CRM_CompanyLadderPrice linkModel = db.CRM_CompanyLadderPrice.Where(e => e.ID == entity.CRM_CompanyLadderPrice_ID).FirstOrDefault();
             linkModel.Status = 2;//修改中
             db.CRM_CompanyLadderPrice_Audit.Add(entity);
             return(db.SaveChanges());
         }
     }
     else
     {
         return(0);
     }
 }
Exemple #12
0
        /// <summary>
        /// 停用企业报价信息
        /// </summary>
        /// <param name="entity">修改信息</param>
        /// <returns></returns>
        public int StopPrice(int ID)
        {
            using (SysEntities db = new SysEntities())
            {
                CRM_CompanyPrice model = db.CRM_CompanyPrice.Where(c => c.ID == ID).FirstOrDefault();
                model.Status = 0;//停用

                List <CRM_CompanyLadderPrice> list = new List <CRM_CompanyLadderPrice>();
                list = db.CRM_CompanyLadderPrice.Where(c => c.CRM_Company_ID == model.CRM_Company_ID && c.PRD_Product_ID == model.PRD_Product_ID).ToList();

                foreach (CRM_CompanyLadderPrice l in list)
                {
                    l.Status = 0;//停用
                }
                return(db.SaveChanges());
            }
        }
Exemple #13
0
 /// <summary>
 /// 提交企业银行信息修改审核
 /// </summary>
 /// <param name="entity">修改信息</param>
 /// <returns></returns>
 public int ModifyBank(CRM_CompanyBankAccount_Audit entity)
 {
     if (entity != null)
     {
         using (SysEntities db = new SysEntities())
         {
             CRM_CompanyBankAccount bankModel = db.CRM_CompanyBankAccount.Where(e => e.ID == entity.CRM_CompanyBankAccount_ID).FirstOrDefault();
             bankModel.Status = 2;//修改中
             db.CRM_CompanyBankAccount_Audit.Add(entity);
             return(db.SaveChanges());
         }
     }
     else
     {
         return(0);
     }
 }
Exemple #14
0
        /// <summary>
        /// 停用企业报价信息
        /// </summary>
        /// <param name="entity">修改信息</param>
        /// <returns></returns>
        public bool StopPrice(SysEntities db, string ID)
        {
            using (db)
            {
                LadderLowestPrice model = db.LadderLowestPrice.Where(c => c.Id == ID).FirstOrDefault();
                model.Status = Common.Status.停用.ToString();//停用

                List <LadderPrice> list = new List <LadderPrice>();
                list = db.LadderPrice.Where(c => c.LadderLowestPriceId == model.Id).ToList();

                foreach (LadderPrice l in list)
                {
                    l.Status = Common.Status.停用.ToString();//停用
                }
                return(db.SaveChanges().GetBool());
            }
        }
Exemple #15
0
        /// <summary>
        /// 审核退回修改信息
        /// </summary>
        /// <param name="companyID">企业ID</param>
        /// <param name="cityID">缴纳地ID</param>
        /// <returns></returns>
        public bool ReturnEdit(SysEntities db, int companyID, string cityID)
        {
            try
            {
                int    operateType  = (int)Common.OperateType.修改;
                int    operateState = (int)Common.AuditStatus.待处理;
                string state        = Common.Status.修改中.ToString();
                //DateTime dtnow = DateTime.Now;
                var AuditI  = 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 AuditPI = db.CRM_Company_PoliceInsurance_Audit.Where(c => c.CRM_Company_ID == companyID && c.City == cityID && c.OperateType == operateType && c.OperateStatus == operateState && c.OperateNode == 2);

                var updI  = db.CRM_Company_Insurance.Where(c => c.CRM_Company_ID == companyID && c.City == cityID && c.State == state);
                var updPI = db.CRM_Company_PoliceInsurance.Where(c => c.CRM_Company_ID == companyID && c.City == cityID && c.State == state);

                foreach (var modelI in AuditI)
                {
                    //设置失败
                    modelI.OperateStatus = (int)Common.AuditStatus.失败;
                }
                foreach (var modelPI in AuditPI)
                {
                    //设置失败
                    modelPI.OperateStatus = (int)Common.AuditStatus.失败;
                }
                foreach (var modelI in updI)
                {
                    //设置启用
                    modelI.State = Common.Status.启用.ToString();
                }
                foreach (var modelPI in updPI)
                {
                    //设置启用
                    modelPI.State = Common.Status.启用.ToString();
                }

                db.SaveChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        /// <summary>
        /// 提交企业联系人信息修改审核
        /// </summary>
        /// <param name="ID">审核表ID</param>
        /// <param name="mainTableID">原表ID</param>
        /// <returns></returns>
        public int PassEdit(int ID, int mainTableID)
        {
            using (SysEntities db = new SysEntities())
            {
                CRM_CompanyLinkMan_Audit comAudit = db.CRM_CompanyLinkMan_Audit.Where(c => c.ID == ID).FirstOrDefault();
                comAudit.OperateStatus = 2;//成功

                CRM_CompanyLinkMan comModel = db.CRM_CompanyLinkMan.Where(e => e.ID == mainTableID).FirstOrDefault();
                comModel.LinkManName = comAudit.LinkManName;
                comModel.Mobile      = comAudit.Mobile;
                comModel.Position    = comAudit.Position;
                comModel.Remark      = comAudit.Remark;
                comModel.Telephone   = comAudit.Telephone;
                comModel.Email       = comAudit.Email;
                comModel.Address     = comAudit.Address;
                comModel.Status      = 1;//启用
                return(db.SaveChanges());
            }
        }
        /// <summary>
        /// 修改供应商基本信息
        /// </summary>
        /// <param name="viewModel">供应商</param>
        /// <returns></returns>
        public int EditSupplier(SupplierView viewModel)
        {
            using (SysEntities db = new SysEntities())
            {
                using (var tran = db.Database.BeginTransaction())
                {
                    try
                    {
                        //基本信息
                        var entity = db.Supplier.Where(e => e.Id == viewModel.Id).FirstOrDefault();
                        entity.Code             = viewModel.Code;
                        entity.Name             = viewModel.Name;
                        entity.OfficeAddress    = viewModel.OfficeAddress;
                        entity.OrganizationCode = viewModel.OrganizationCode;
                        entity.RegisterAddress  = viewModel.RegisterAddress;

                        //社保缴纳地
                        var      oldCityList = db.SupplierNatureCity.Where(e => e.SupplierId == viewModel.Id).ToList();
                        string[] arrOldCity  = new string[oldCityList.Count()];//旧城市ID数组
                        for (int i = 0; i < oldCityList.Count(); i++)
                        {
                            arrOldCity[i] = oldCityList[i].NatureCityId;
                        }

                        List <SupplierNatureCity> newCityList = GetCityList(viewModel.Id, viewModel.NatureCityId, arrOldCity);
                        if (newCityList.Count > 0)
                        {
                            db.SupplierNatureCity.RemoveRange(oldCityList);
                            db.SupplierNatureCity.AddRange(newCityList);
                        }

                        db.SaveChanges();
                        tran.Commit();
                        return(1);
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        return(0);
                    }
                }
            }
        }
        /// <summary>
        /// 提交企业合同信息修改审核
        /// </summary>
        /// <param name="ID">审核表ID</param>
        /// <param name="mainTableID">原表ID</param>
        /// <returns></returns>
        public int PassEdit(int ID, int mainTableID)
        {
            using (SysEntities db = new SysEntities())
            {
                CRM_CompanyContract_Audit comAudit = db.CRM_CompanyContract_Audit.Where(c => c.ID == ID).FirstOrDefault();
                comAudit.OperateStatus = 2;//成功

                CRM_CompanyContract comModel = db.CRM_CompanyContract.Where(e => e.ID == mainTableID).FirstOrDefault();
                comModel.BillDay         = comAudit.BillDay;
                comModel.ChangeDay       = comAudit.ChangeDay;
                comModel.DatumDay        = comAudit.DatumDay;
                comModel.FeesCycle       = comAudit.FeesCycle;
                comModel.ReceivedDay     = comAudit.ReceivedDay;
                comModel.SendBillDay     = comAudit.SendBillDay;
                comModel.ServceEndDay    = comAudit.ServceEndDay;
                comModel.ServiceBeginDay = comAudit.ServceEndDay;
                comModel.Status          = 1;//启用
                return(db.SaveChanges());
            }
        }
        /// <summary>
        /// 提交企业财务信息(付款)添加审核
        /// </summary>
        /// <param name="ID">审核表ID</param>
        /// <returns></returns>
        public int PassAdd(int ID)
        {
            using (SysEntities db = new SysEntities())
            {
                CRM_CompanyFinance_Payment_Audit comAudit = db.CRM_CompanyFinance_Payment_Audit.Where(c => c.ID == ID).FirstOrDefault();
                comAudit.OperateStatus = 2;//成功

                CRM_CompanyFinance_Payment comModel = new CRM_CompanyFinance_Payment();
                comModel.PaymentName = comAudit.PaymentName;
                comModel.Status      = 1;//启用

                comModel.CRM_Company_ID = Convert.ToInt32(comAudit.CRM_Company_ID);
                comModel.CreateTime     = comAudit.CreateTime;
                comModel.CreateUserID   = comAudit.CreateUserID;
                comModel.CreateUserName = comAudit.CreateUserName;
                comModel.BranchID       = comAudit.BranchID;
                db.CRM_CompanyFinance_Payment.Add(comModel);

                return(db.SaveChanges());
            }
        }
 /// <summary>
 /// 批量更新供应商客服
 /// </summary>
 /// <param name="id">供应商编号</param>
 /// <param name="customerServiceId">供应商客服ID</param>
 /// <returns></returns>
 public bool UpdateCustomerService(int?[] ids, int customerServiceId)
 {
     using (SysEntities db = new SysEntities())
     {
         try
         {
             var query = from supplier in db.Supplier
                         where ids.Contains(supplier.Id)
                         select supplier;
             var f = query.ToList();
             foreach (var item in f)
             {
                 item.CustomerServiceId = customerServiceId;
             }
             db.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
 /// <summary>
 /// 批量删除角色(将标志位置为‘N’)
 /// </summary>
 /// <param name="db">数据访问的上下文</param>
 /// <param name="id">菜单功能编号</param>
 /// <returns></returns>
 public bool DeleteRoleOp(int[] ids)
 {
     using (SysEntities db = new SysEntities())
     {
         try
         {
             var query = from menuop in db.ORG_Role
                         where ids.Contains(menuop.ID)
                         select menuop;
             var f = query.ToList();
             foreach (var item in f)
             {
                 item.XYBZ = "N";
             }
             db.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
 /// <summary>
 /// 批量删除供应商(将状态设置为‘停用’)
 /// </summary>
 /// <param name="id">供应商编号</param>
 /// <returns></returns>
 public bool DeleteSupplier(int?[] ids)
 {
     using (SysEntities db = new SysEntities())
     {
         try
         {
             var query = from supplier in db.Supplier
                         where ids.Contains(supplier.Id)
                         select supplier;
             var f = query.ToList();
             foreach (var item in f)
             {
                 item.Status = "停用";
             }
             db.SaveChanges();
             return(true);
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
        /// <summary>
        /// 提交企业阶梯报价信息添加审核
        /// </summary>
        /// <param name="ID">审核表ID</param>
        /// <returns></returns>
        public int PassAdd(int ID)
        {
            using (SysEntities db = new SysEntities())
            {
                CRM_CompanyLadderPrice_Audit comAudit = db.CRM_CompanyLadderPrice_Audit.Where(c => c.ID == ID).FirstOrDefault();
                comAudit.OperateStatus = 2;//成功

                CRM_CompanyLadderPrice comModel = new CRM_CompanyLadderPrice();
                comModel.BeginLadder    = comAudit.BeginLadder;
                comModel.EndLadder      = comAudit.EndLadder;
                comModel.PRD_Product_ID = comAudit.PRD_Product_ID;
                comModel.SinglePrice    = comAudit.SinglePrice;
                comModel.Status         = 1;//启用

                comModel.CRM_Company_ID = Convert.ToInt32(comAudit.CRM_Company_ID);
                comModel.CreateTime     = comAudit.CreateTime;
                comModel.CreateUserID   = comAudit.CreateUserID;
                comModel.CreateUserName = comAudit.CreateUserName;
                comModel.BranchID       = comAudit.BranchID;
                db.CRM_CompanyLadderPrice.Add(comModel);

                return(db.SaveChanges());
            }
        }
 // 创建新公司
 //public int CreateNewCompany(CRM_Company baseModel, CRM_CompanyContract contractModel, CRM_CompanyToBranch branchModel, List<CRM_CompanyLinkMan> listLink, List<CRM_CompanyBankAccount> listBank, List<CRM_CompanyFinance_Bill> listBill, List<CRM_CompanyFinance_Payment> listPay, List<CRM_CompanyPrice> listPrice, List<CRM_CompanyLadderPrice> listLadderPrice)
 public int CreateNewCompany(CRM_Company baseModel, CRM_CompanyContract contractModel, CRM_CompanyToBranch branchModel, List <CRM_CompanyLinkMan> listLink, List <CRM_CompanyBankAccount> listBank, List <CRM_CompanyFinance_Bill> listBill, List <CRM_CompanyFinance_Payment> listPay, List <CRM_CompanyPrice> listPrice, List <CRM_CompanyLadderPrice> listLadderPrice, List <CRM_Company_PoliceInsurance> CompanyPoliceInsurance, List <CRM_Company_Insurance> CompanyInsurance)
 {
     using (SysEntities db = new SysEntities())
     {
         using (var tran = db.Database.BeginTransaction())
         {
             try
             {
                 //创建公司
                 db.CRM_Company.Add(baseModel);
                 db.SaveChanges();
                 baseModel.CompanyCode = baseModel.ID.ToString();//编号等于ID
                 //添加公司分支机构
                 branchModel.CRM_Company_ID = baseModel.ID;
                 db.CRM_CompanyToBranch.Add(branchModel);
                 //添加合同信息
                 contractModel.CRM_Company_ID = baseModel.ID;
                 db.CRM_CompanyContract.Add(contractModel);
                 //联系人
                 if (listLink != null && listLink.Count > 0)
                 {
                     listLink = GetLinkList(listLink, baseModel.ID);
                     db.CRM_CompanyLinkMan.AddRange(listLink);
                 }
                 //银行
                 if (listBank != null && listBank.Count > 0)
                 {
                     listBank = GetBankList(listBank, baseModel.ID);
                     db.CRM_CompanyBankAccount.AddRange(listBank);
                 }
                 //开票
                 if (listBill != null && listBill.Count > 0)
                 {
                     listBill = GetBillList(listBill, baseModel.ID);
                     db.CRM_CompanyFinance_Bill.AddRange(listBill);
                 }
                 //回款
                 if (listPay != null && listPay.Count > 0)
                 {
                     listPay = GetPayList(listPay, baseModel.ID);
                     db.CRM_CompanyFinance_Payment.AddRange(listPay);
                 }
                 //报价
                 if (listPrice != null && listPrice.Count > 0)
                 {
                     listPrice = GetPriceList(listPrice, baseModel.ID);
                     db.CRM_CompanyPrice.AddRange(listPrice);
                 }
                 //阶梯报价
                 if (listLadderPrice != null && listLadderPrice.Count > 0)
                 {
                     listLadderPrice = GetLadderList(listLadderPrice, baseModel.ID);
                     db.CRM_CompanyLadderPrice.AddRange(listLadderPrice);
                 }
                 //企业社保政策
                 if (CompanyPoliceInsurance != null && CompanyPoliceInsurance.Count > 0)
                 {
                     CompanyPoliceInsurance = GetPoliceInsuranceList(CompanyPoliceInsurance, baseModel.ID);
                     db.CRM_Company_PoliceInsurance.AddRange(CompanyPoliceInsurance);
                 }
                 //企业社保信息
                 if (CompanyInsurance != null && CompanyInsurance.Count > 0)
                 {
                     CompanyInsurance = GetInsuranceList(CompanyInsurance, baseModel.ID);
                     db.CRM_Company_Insurance.AddRange(CompanyInsurance);
                 }
                 db.SaveChanges();
                 tran.Commit();
                 return(1);
             }
             catch (Exception ex)
             {
                 tran.Rollback();
                 return(0);
             }
         }
     }
 }
Exemple #25
0
        /// <summary>
        /// 编辑一个菜单
        /// </summary>
        /// <param name="validationErrors">返回的错误信息</param>
        /// <param name="db">数据上下文</param>
        /// <param name="entity">一个菜单</param>
        /// <returns>是否编辑成功</returns>
        public bool Edit(ref ValidationErrors validationErrors, SysEntities db, SysMenu entity)
        {
            /*
                           * 不操作 原有 现有
                           * 增加   原没 现有
                           * 删除   原有 现没
                           */
            if (entity == null)
            {
                return false;
            }
            int count = 1;

            List<string> addSysOperationId = new List<string>();
            List<string> deleteSysOperationId = new List<string>();
            DataOfDiffrent.GetDiffrent(entity.SysOperationId.GetIdSort(), entity.SysOperationIdOld.GetIdSort(), ref addSysOperationId, ref deleteSysOperationId);
            List<SysOperation> listEntitySysOperation = new List<SysOperation>();
            if (deleteSysOperationId != null && deleteSysOperationId.Count() > 0)
            {
                foreach (var item in deleteSysOperationId)
                {
                    SysOperation sys = new SysOperation { Id = item };
                    listEntitySysOperation.Add(sys);
                    entity.SysOperation.Add(sys);
                }
            }

            SysMenu editEntity = repository.Edit(db, entity);

            if (addSysOperationId != null && addSysOperationId.Count() > 0)
            {
                foreach (var item in addSysOperationId)
                {
                    SysOperation sys = new SysOperation { Id = item };
                    db.SysOperation.Attach(sys);
                    editEntity.SysOperation.Add(sys);
                    count++;
                }
            }
            if (deleteSysOperationId != null && deleteSysOperationId.Count() > 0)
            {
                foreach (SysOperation item in listEntitySysOperation)
                {
                    editEntity.SysOperation.Remove(item);
                    count++;
                }
            }

            if (count == repository.Save(db))
            {
                //修改后重置菜单编码
                List<int> flags = new List<int>();//层级
                GetMenus2(null, flags);
                db.SaveChanges();
                return true;
            }
            else
            {
                validationErrors.Add("编辑菜单出错了");
            }
            return false;
        }
        /// <summary>
        /// 配置角色权限
        /// </summary>
        /// <param name="id"></param>
        /// <param name="isEditOpt"></param>
        /// <param name="isEditDpt"></param>
        /// <param name="isEditData"></param>
        /// <param name="selectedMenuOpt"></param>
        /// <param name="selectedMenuDpt"></param>
        /// <param name="selectedMenuScope"></param>
        /// <returns></returns>
        private bool ConfigRloe(int id, bool isEditOpt, bool isEditDpt, bool isEditData, string selectedMenuOpt, string selectedMenuDpt, string selectedMenuScope)
        {
            try
            {
                using (SysEntities db = new SysEntities())
                {
                    if (isEditOpt)
                    {
                        #region 配置操作权限
                        //删除操作权限
                        //dal.Delete<ORG_RoleMenuOpAuthority>(string.Format(" ORG_Role_ID = {0}", id));
                        //db.Database.ExecuteSqlCommand("delete from ORG_RoleMenuOpAuthority where ORG_Role_ID = " + id, null);
                        IEnumerable <ORG_RoleMenuOpAuthority> MenuOps_Old = db.ORG_RoleMenuOpAuthority.Where(c => c.ORG_Role_ID == id);
                        db.ORG_RoleMenuOpAuthority.RemoveRange(MenuOps_Old);

                        //重新添加操作权限
                        if (!string.IsNullOrEmpty(selectedMenuOpt))
                        {
                            //拆解成(菜单:操作1,操作2)类型的集合
                            string[] tmpMenusOpts = selectedMenuOpt.Split(';');

                            ORG_RoleMenuOpAuthority MenuOp = new ORG_RoleMenuOpAuthority();
                            foreach (string tmpMenuOpts in tmpMenusOpts)
                            {
                                if (!string.IsNullOrEmpty(tmpMenuOpts))
                                {
                                    //拆解菜单和菜单操作
                                    string[] strMenuOpts = tmpMenuOpts.Split(':');

                                    MenuOp             = new ORG_RoleMenuOpAuthority();
                                    MenuOp.ORG_Role_ID = id;

                                    MenuOp.ORG_Menu_ID = strMenuOpts[0];//菜单ID
                                    //若有操作,则存入菜单操作ID集合
                                    if (strMenuOpts.Length > 1)
                                    {
                                        MenuOp.ORG_MenuOp_ID_List = strMenuOpts[1];
                                    }
                                    //dal.Add<ORG_RoleMenuOpAuthority>(MenuOp);
                                    db.ORG_RoleMenuOpAuthority.Add(MenuOp);
                                }
                            }
                        }
                        #endregion
                    }

                    if (isEditDpt)
                    {
                        #region 配置部门业务权限
                        //拆解成(菜单:部门1,部门2)类型的集合
                        string[] tmpMenuDpt = selectedMenuDpt.Split(';');
                        foreach (string md in tmpMenuDpt)
                        {
                            string[] menu_dpt = md.Split(':');
                            if (menu_dpt.Length > 0)
                            {
                                //删除部门的菜单部门权限
                                //dal.Delete<ORG_RoleDepartmentAuthority>(string.Format(" ORG_Role_ID = {0} and ORG_Menu_ID = '{1}'", id, menu_dpt[0]));
                                string menuId = menu_dpt[0];
                                IEnumerable <ORG_RoleDepartmentAuthority> RoleDeparts_Old = db.ORG_RoleDepartmentAuthority.Where(c => c.ORG_Role_ID == id && c.ORG_Menu_ID == menuId);
                                db.ORG_RoleDepartmentAuthority.RemoveRange(RoleDeparts_Old);
                            }

                            if (menu_dpt.Length == 2 && menu_dpt[1] != "")
                            {
                                //添加部门权限
                                ORG_RoleDepartmentAuthority DptAuthority = new ORG_RoleDepartmentAuthority();
                                DptAuthority                        = new ORG_RoleDepartmentAuthority();
                                DptAuthority.ORG_Role_ID            = id;
                                DptAuthority.ORG_Menu_ID            = menu_dpt[0];
                                DptAuthority.ORG_Department_ID_List = menu_dpt[1];

                                //dal.Add<ORG_RoleDepartmentAuthority>(DptAuthority);
                                db.ORG_RoleDepartmentAuthority.Add(DptAuthority);
                            }
                        }
                        #endregion
                    }

                    if (isEditData)
                    {
                        #region 配置部门范围权限
                        //分解成(菜单:范围)类型的集合
                        string[] tmpMenuScope = selectedMenuScope.Split(';');

                        foreach (string strMenuScope in tmpMenuScope)
                        {
                            string[] menuScope = strMenuScope.Split(':');

                            //删除原有权限
                            //dal.Delete<ORG_RoleDepartmenScopetAuthority>(string.Format("ORG_Role_ID = {0} and ORG_Menu_ID = '{1}'", id, menuScope[0]));
                            string menuId = menuScope[0];
                            IEnumerable <ORG_RoleDepartmenScopetAuthority> Scopes_Olds = db.ORG_RoleDepartmenScopetAuthority.Where(c => c.ORG_Role_ID == id && c.ORG_Menu_ID == menuId);
                            db.ORG_RoleDepartmenScopetAuthority.RemoveRange(Scopes_Olds);

                            //添加部门范围权限
                            ORG_RoleDepartmenScopetAuthority Scopet = new ORG_RoleDepartmenScopetAuthority();
                            Scopet.ORG_Role_ID     = id;
                            Scopet.ORG_Menu_ID     = menuScope[0];
                            Scopet.DepartmentScope = Convert.ToInt32(menuScope[1]);
                            //dal.Add<ORG_RoleDepartmenScopetAuthority>(Scopet);
                            db.ORG_RoleDepartmenScopetAuthority.Add(Scopet);

                            //菜单范围权限不为0(无限制)时,删除部门业务权限
                            if (menuScope[1] != "0")
                            {
                                //删除部门的菜单部门权限
                                //dal.Delete<ORG_RoleDepartmentAuthority>(string.Format("ORG_Role_ID = {0} and ORG_Menu_ID = '{1}'", id, menuScope[0]));
                                IEnumerable <ORG_RoleDepartmentAuthority> RoleDeparts_Err = db.ORG_RoleDepartmentAuthority.Where(c => c.ORG_Role_ID == id && c.ORG_Menu_ID == menuId);
                                db.ORG_RoleDepartmentAuthority.RemoveRange(RoleDeparts_Err);
                            }
                        }
                        #endregion
                    }

                    db.SaveChanges();
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemple #27
0
 /// <summary>
 /// 提交保存,持久化到数据库
 /// </summary>
 /// <param name="db">实体数据</param>
 /// <returns>受影响行数</returns>
 public int Save(SysEntities db)
 {
     return(db.SaveChanges());
 }
Exemple #28
0
        /// <summary>
        /// 审核通过修改信息
        /// </summary>
        /// <param name="companyID">企业ID</param>
        /// <param name="cityID">缴纳地ID</param>
        /// <returns></returns>
        public bool PassEdit(SysEntities db, int companyID, string cityID)
        {
            try
            {
                int    operateType  = (int)Common.OperateType.修改;
                int    operateState = (int)Common.AuditStatus.待处理;
                string state        = Common.Status.修改中.ToString();
                //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);

                var delI  = db.CRM_Company_Insurance.Where(c => c.CRM_Company_ID == companyID && c.City == cityID && c.State == state);
                var delPI = db.CRM_Company_PoliceInsurance.Where(c => c.CRM_Company_ID == companyID && c.City == cityID && c.State == state);

                //删除正式表元数据
                db.CRM_Company_Insurance.RemoveRange(delI);
                db.CRM_Company_PoliceInsurance.RemoveRange(delPI);

                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);
            }
        }
Exemple #29
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);
            }
        }
Exemple #30
0
        public bool EmployeeListAdd(List <EmployeeAddExcle> empList, string createPerson)
        {
            using (SysEntities db = new SysEntities())
            {
                using (var tran = db.Database.BeginTransaction())
                {
                    try
                    {
                        if (empList != null)
                        {
                            foreach (EmployeeAddExcle employ in empList)
                            {
                                Employee                employee                = new Employee();                //员工表
                                EmployeeContact         employeeContact         = new EmployeeContact();         //联系人表
                                CompanyEmployeeRelation companyEmployeeRelation = new CompanyEmployeeRelation(); //员工企业关系表
                                EmployeeBank            employeebank            = new EmployeeBank();            //员工银行


                                //员工基本
                                employee.Name              = employ.Empname;
                                employee.CertificateType   = employ.CertificateType;
                                employee.CertificateNumber = employ.CertificateNumber;
                                employee.AccountType       = employ.AccountType;
                                employee.Sex          = Common.CardCommon.Getsex(employ.CertificateNumber) == 1 ? "男" : "女";
                                employee.Birthday     = Common.CardCommon.GetShengRi(employ.CertificateNumber);
                                employee.CreateTime   = DateTime.Now;
                                employee.CreatePerson = createPerson;
                                db.Employee.Add(employee);


                                //联系人
                                employeeContact.Telephone    = employ.Telephone;
                                employeeContact.MobilePhone  = employ.MobilePhone;
                                employeeContact.Address      = employ.Address;
                                employeeContact.Email        = employ.Email;
                                employeeContact.EmployeeId   = employee.Id;
                                employeeContact.State        = "启用";
                                employeeContact.CreateTime   = DateTime.Now;
                                employeeContact.CreatePerson = createPerson;
                                db.EmployeeContact.Add(employeeContact);
                                db.SaveChanges();

                                // 银行信息
                                //if (!string.IsNullOrWhiteSpace(employeebank.AccountName))
                                {
                                    employeebank.EmployeeId   = employee.Id;
                                    employeebank.AccountName  = employ.AccountName;
                                    employeebank.Bank         = employ.Bank;
                                    employeebank.BranchBank   = employ.BranchBank;
                                    employeebank.Account      = employ.Account;
                                    employeebank.IsDefault    = employ.Account;
                                    employeebank.State        = "启用";
                                    employeebank.CreateTime   = DateTime.Now;
                                    employeebank.CreatePerson = createPerson;
                                    db.EmployeeBank.Add(employeebank);
                                    db.SaveChanges();
                                }


                                //员工关系表
                                companyEmployeeRelation.CityId                = employ.City;
                                companyEmployeeRelation.CompanyId             = employ.CompanyId;
                                companyEmployeeRelation.EmployeeId            = employee.Id;
                                companyEmployeeRelation.State                 = "在职";
                                companyEmployeeRelation.Station               = employ.Station;
                                companyEmployeeRelation.PoliceAccountNatureId = employ.PoliceAccountNature;
                                companyEmployeeRelation.CreateTime            = DateTime.Now;
                                companyEmployeeRelation.CreatePerson          = createPerson;
                                db.CompanyEmployeeRelation.Add(companyEmployeeRelation);
                                db.SaveChanges();
                            }
                        }


                        tran.Commit();
                        return(true);
                    }
                    //catch
                    //{
                    //    tran.Rollback();

                    //    return false;
                    //}

                    catch (System.Data.Entity.Validation.DbEntityValidationException ex)
                    {
                        tran.Rollback();
                        foreach (var errors in ex.EntityValidationErrors)
                        {
                            foreach (var item in errors.ValidationErrors)
                            {
                                Console.WriteLine(item.ErrorMessage + item.PropertyName);
                            }
                        }
                        return(false);
                    }
                }
            }
        }