Exemplo n.º 1
0
        //Model转换
        public CRM_Company_Audit GetModel(CRM_Company item)
        {
            CRM_Company_Audit model = new CRM_Company_Audit();
            object            value;

            if (item != null)
            {
                string[]       arrField   = new string[] { "CompanyCode", "CompanyName", "Dict_HY_Code", "OrganizationCode", "RegisterAddress", "OfficeAddress" };
                Type           t1         = typeof(CRM_Company);
                PropertyInfo[] propertys1 = t1.GetProperties();
                Type           t2         = typeof(CRM_Company_Audit);
                PropertyInfo[] propertys2 = t2.GetProperties();

                foreach (PropertyInfo pi in propertys2)
                {
                    string name = pi.Name;
                    if (arrField.Contains(name))
                    {
                        value = t1.GetProperty(name).GetValue(item, null);
                        t2.GetProperty(name).SetValue(model, value, null);
                    }
                }
                model.CRM_Company_ID = item.ID;
                model.CreateTime     = DateTime.Now;
                model.CreateUserID   = LoginInfo.UserID;
                model.CreateUserName = LoginInfo.RealName;
                model.BranchID       = LoginInfo.BranchID;
                model.Source         = 2;
                model.OperateStatus  = 1;
                model.OperateNode    = 2;//质控
            }
            return(model);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 创建一个客户_企业信息
 /// </summary>
 /// <param name="validationErrors">返回的错误信息</param>
 /// <param name="db">数据库上下文</param>
 /// <param name="entity">一个客户_企业信息</param>
 /// <returns></returns>
 public bool Create(ref ValidationErrors validationErrors, CRM_Company entity)
 {
     try
     {
         repository.Create(entity);
         return(true);
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
     }
     return(false);
 }
Exemplo n.º 3
0
 /// <summary>
 ///  创建新公司
 /// </summary>
 /// <param name="validationErrors"></param>
 /// <param name="baseModel">基本信息表</param>
 /// <param name="contractModel">合同信息表</param>
 /// <param name="branchModel">公司分支关系</param>
 /// <param name="listLink">联系人信息</param>
 /// <param name="listBank">银行信息</param>
 /// <param name="listBill">开票信息</param>
 /// <param name="listPay">回款信息</param>
 /// <param name="listPrice">报价</param>
 /// <param name="listLadderPrice">阶梯报价</param>
 /// <returns></returns>
 public bool CreateNewCompany(ref ValidationErrors validationErrors, 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)
 {
     try
     {
         int result = repository.CreateNewCompany(baseModel, contractModel, branchModel, listLink, listBank, listBill, listPay, listPrice, listLadderPrice, CompanyPoliceInsurance, CompanyInsurance);
         if (result == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         validationErrors.Add(ex.Message);
         ExceptionsHander.WriteExceptions(ex);
         return(false);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="entity">实体对象</param>
        /// <returns></returns>
        public Common.ClientResult.Result Post([FromBody] CRM_Company entity)
        {
            Common.ClientResult.Result result = new Common.ClientResult.Result();
            if (entity != null && ModelState.IsValid)
            {
                CRM_Company_Audit model = GetModel(entity);

                string returnValue = string.Empty;
                if (m_BLL.ModifyBaseInfo(ref validationErrors, model))
                {
                    LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",客户_企业信息_待审核的信息的Id为" + entity.ID, "客户_企业信息_待审核"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Succeed;
                    result.Message = Suggestion.InsertSucceed;
                    return(result); //提示创建成功
                }
                else
                {
                    if (validationErrors != null && validationErrors.Count > 0)
                    {
                        validationErrors.All(a =>
                        {
                            returnValue += a.ErrorMessage;
                            return(true);
                        });
                    }
                    LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",客户_企业信息_待审核的信息," + returnValue, "客户_企业信息_待审核"
                                                   );//写入日志
                    result.Code    = Common.ClientCode.Fail;
                    result.Message = Suggestion.InsertFail + returnValue;
                    return(result); //提示插入失败
                }
            }

            result.Code    = Common.ClientCode.FindNull;
            result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对
            return(result);
        }
Exemplo n.º 5
0
 //创建新公司
 public Common.ClientResult.Result PostNewCompany([FromBody] CRM_CompanyInfo entity)
 {
     Common.ClientResult.Result result = new Common.ClientResult.Result();
     if (entity != null && ModelState.IsValid)
     {
         CRM_Company baseModel = entity.BasicInfo;//基本信息
         baseModel.CreateTime     = DateTime.Now;
         baseModel.CreateUserID   = LoginInfo.UserID;
         baseModel.CreateUserName = LoginInfo.RealName;
         baseModel.OperateStatus  = (int)Common.Status.启用;
         CRM_CompanyContract contractModel = entity.Contract; // 合同信息
         contractModel.CreateTime     = DateTime.Now;
         contractModel.CreateUserID   = LoginInfo.UserID;
         contractModel.CreateUserName = LoginInfo.RealName;
         contractModel.Status         = (int)Common.Status.启用;
         contractModel.BranchID       = LoginInfo.BranchID;
         //公司分支机构
         CRM_CompanyToBranch branchModel = new CRM_CompanyToBranch();
         branchModel.BranchID  = LoginInfo.BranchID;
         branchModel.UserID_XS = LoginInfo.UserID;
         branchModel.Status    = (int)Common.Status.启用;
         //联系人信息
         List <CRM_CompanyLinkMan> listLink = new List <CRM_CompanyLinkMan>();
         string linkMan = entity.LinkMan;
         if (!string.IsNullOrEmpty(linkMan))
         {
             listLink = GetLinkList(linkMan);
         }
         //银行信息
         List <CRM_CompanyBankAccount> listBank = new List <CRM_CompanyBankAccount>();
         string bank = entity.Bank;
         if (!string.IsNullOrEmpty(bank))
         {
             listBank = GetBankList(bank);
         }
         //财务信息开票
         List <CRM_CompanyFinance_Bill> listBill  = new List <CRM_CompanyFinance_Bill>();
         CRM_CompanyFinance_Bill        billModel = entity.Bill;
         billModel.CreateTime     = DateTime.Now;
         billModel.CreateUserID   = LoginInfo.UserID;
         billModel.CreateUserName = LoginInfo.RealName;
         billModel.Status         = (int)Common.Status.启用;
         billModel.BranchID       = LoginInfo.BranchID;
         listBill.Add(billModel);
         //财务信息收款
         List <CRM_CompanyFinance_Payment> listPay = new List <CRM_CompanyFinance_Payment>();
         string payment = entity.Payment;
         if (!string.IsNullOrEmpty(payment))
         {
             listPay = GetPayList(payment);
         }
         //企业报价
         List <CRM_CompanyPrice> listPrice = new List <CRM_CompanyPrice>();
         string price = entity.Price;
         if (!string.IsNullOrEmpty(price))
         {
             listPrice = GetPriceList(price);
         }
         //企业阶梯报价
         List <CRM_CompanyLadderPrice> listLadderPrice = new List <CRM_CompanyLadderPrice>();
         string ladderPrice = entity.LadderPrice;
         if (!string.IsNullOrEmpty(ladderPrice))
         {
             listLadderPrice = GetLadderPriceList(ladderPrice);
         }
         //企业社保政策和社保信息
         SheBao shebao = Newtonsoft.Json.JsonConvert.DeserializeObject <SheBao>(entity.SheBaoInfo);
         List <CRM_Company_PoliceInsurance> CompanyPoliceInsurance = GetPoliceInsuance(shebao);
         List <CRM_Company_Insurance>       CompanyInsurance       = GetInsurance(shebao);
         string returnValue = string.Empty;
         if (m_BLL.CreateNewCompany(ref validationErrors, baseModel, contractModel, branchModel, listLink, listBank, listBill, listPay, listPrice, listLadderPrice, CompanyPoliceInsurance, CompanyInsurance))
         //if (m_BLL.CreateNewCompany(ref validationErrors, baseModel, contractModel, branchModel, listLink, listBank, listBill, listPay, listPrice, listLadderPrice))
         {
             //LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",客户_企业信息_待审核的信息的Id为" + entity.ID, "客户_企业信息_待审核"
             //);//写入日志
             result.Code    = Common.ClientCode.Succeed;
             result.Message = Suggestion.InsertSucceed;
             return(result); //提示创建成功
         }
         else
         {
             if (validationErrors != null && validationErrors.Count > 0)
             {
                 validationErrors.All(a =>
                 {
                     returnValue += a.ErrorMessage;
                     return(true);
                 });
             }
             //LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",客户_企业信息_待审核的信息," + returnValue, "客户_企业信息_待审核"
             //    );//写入日志
             result.Code    = Common.ClientCode.Fail;
             result.Message = Suggestion.InsertFail + returnValue;
             return(result); //提示插入失败
         }
     }
     result.Code    = Common.ClientCode.FindNull;
     result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对
     return(result);
 }
Exemplo n.º 6
0
        public IHttpActionResult AddCompany(CompanyInfo companyinfo)
        {
            if (!IsValidation())
            {
                return(Json(new { code = -1, message = "验证未通过" }));
            }
            try
            {
                using (SysEntities db = new SysEntities())
                {
                    CRM_Company company = new CRM_Company();

                    company.CompanyCode      = "0001测试";
                    company.CompanyName      = companyinfo.Name;
                    company.OrganizationCode = companyinfo.OrganizationCode;
                    //company.TaxRegistryNumber = companyinfo.TaxNumber;
                    //company.InvoiceCompanyName = companyinfo.InvoiceName;
                    //company.PayCompanyName =   companyinfo.PaymentName;
                    company.CreateTime     = DateTime.Now;
                    company.CreateUserID   = 1;
                    company.CreateUserName = "******";
                    company.OperateStatus  = 1;//启用


                    //注意   是否需要转换
                    company.Dict_HY_Code = companyinfo.Industry;
                    company.Source       = 1;//平台推送。


                    db.CRM_Company.Add(company);
                    db.SaveChanges();
                    //#region 开票回款

                    //CRM_CompanyFinance companyfinance = new CRM_CompanyFinance();
                    //companyfinance.CRM_Company_ID = company.ID;
                    //companyfinance.FinanceName = companyinfo.InvoiceName;
                    //companyfinance.FinanceType = 1;//开票
                    //companyfinance.Status = 1;//启用
                    //companyfinance.BranchID = 1;
                    //companyfinance.CreateTime = DateTime.Now;
                    //companyfinance.CreateUserID = 1;
                    //companyfinance.CreateUserName = "******";

                    //db.CRM_CompanyFinance.Add(companyfinance);
                    //db.SaveChanges();

                    //companyfinance = new CRM_CompanyFinance();
                    //companyfinance.CRM_Company_ID = company.ID;
                    //companyfinance.FinanceName = companyinfo.PaymentName;
                    //companyfinance.FinanceType = 2;//回款
                    //companyfinance.Status = 1;//启用
                    //companyfinance.BranchID = 1;
                    //companyfinance.CreateTime = DateTime.Now;
                    //companyfinance.CreateUserID = 1;
                    //companyfinance.CreateUserName = "******";

                    //db.CRM_CompanyFinance.Add(companyfinance);
                    //db.SaveChanges();
                    //#endregion

                    #region 联系人
                    CRM_CompanyLinkMan companylinkman = new CRM_CompanyLinkMan();
                    companylinkman.CRM_Company_ID = company.ID;
                    companylinkman.LinkManName    = companyinfo.ContactPerson;
                    companylinkman.Telephone      = companyinfo.ContactPhone;
                    companylinkman.Address        = companyinfo.ContactAddress;

                    companylinkman.CreateTime     = DateTime.Now;
                    companylinkman.BranchID       = 1;//暂时写1
                    companylinkman.CreateUserID   = 1;
                    companylinkman.CreateUserName = "******";
                    companylinkman.Status         = 1;

                    db.CRM_CompanyLinkMan.Add(companylinkman);
                    db.SaveChanges();

                    #endregion


                    return(Json(new { code = 0, message = "成功", id = company.ID }));
                };
            }
            catch (Exception ee)
            {
                return(Json(new { code = -1, message = ee.ToString() }));
            }
        }