//Model转换 public CRM_CompanyFinance_Bill_Audit GetModel(CRM_CompanyFinance_Bill item) { CRM_CompanyFinance_Bill_Audit model = new CRM_CompanyFinance_Bill_Audit(); object value; if (item != null) { string[] arrField = new string[] { "CRM_Company_ID", "BillName", "TaxRegistryNumber" }; Type t1 = typeof(CRM_CompanyFinance_Bill); PropertyInfo[] propertys1 = t1.GetProperties(); Type t2 = typeof(CRM_CompanyFinance_Bill_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_CompanyFinance_Bill_ID = item.ID; model.CreateTime = DateTime.Now; model.CreateUserID = LoginInfo.UserID; model.CreateUserName = LoginInfo.RealName; model.BranchID = LoginInfo.BranchID; model.OperateStatus = 1; //待处理 model.OperateNode = 2; //质控 } return(model); }
/// <summary> /// 创建一个客户_企业财务信息_开票 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据库上下文</param> /// <param name="entity">一个客户_企业财务信息_开票</param> /// <returns></returns> public bool Create(ref ValidationErrors validationErrors, CRM_CompanyFinance_Bill entity) { try { repository.Create(entity); return(true); } catch (Exception ex) { validationErrors.Add(ex.Message); ExceptionsHander.WriteExceptions(ex); } return(false); }
// PUT api/<controller>/5 /// <summary> /// 编辑 /// </summary> /// <param name="entity"></param> /// <returns></returns> public Common.ClientResult.Result Put([FromBody] CRM_CompanyFinance_Bill entity) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (entity != null && ModelState.IsValid) { //数据校验 //string currentPerson = GetCurrentPerson(); //entity.UpdateTime = DateTime.Now; //entity.UpdatePerson = currentPerson; CRM_CompanyFinance_Bill_Audit model = GetModel(entity); string returnValue = string.Empty; if (m_BLL.ModifyFinance_Bill(ref validationErrors, model)) { LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",客户_企业财务信息_待审核信息的Id为" + entity.ID, "客户_企业财务信息_待审核" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.UpdateSucceed; return(result); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",客户_企业财务信息_待审核信息的Id为" + entity.ID + "," + returnValue, "客户_企业财务信息_待审核" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示更新失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式"; return(result); //提示输入的数据的格式不对 }
/// <summary> /// 停用 /// </summary> /// <param name="id"></param> /// <returns></returns> public Common.ClientResult.Result Stop(int id) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (ModelState.IsValid) { //数据校验 CRM_CompanyFinance_Bill item = m_BLL.GetById(id); item.Status = 0;//停用 string returnValue = string.Empty; if (m_BLL.Edit(ref validationErrors, item)) { LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",客户_企业财务信息的Id为" + id, "客户_企业财务信息_停用" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.UpdateSucceed; return(result); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",客户_企业财务信息的Id为" + id + "," + returnValue, "客户_企业财务信息_停用" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示更新失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式"; return(result); //提示输入的数据的格式不对 }
//创建新公司 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); }
/// <summary> /// 根据ID获取数据模型 /// </summary> /// <param name="id">编号</param> /// <returns></returns> public CRM_CompanyFinance_Bill Get(int id) { CRM_CompanyFinance_Bill item = m_BLL.GetById(id); return(item); }