//Model转换 public CRM_CompanyLinkMan_Audit GetModel(CRM_CompanyLinkMan item) { CRM_CompanyLinkMan_Audit model = new CRM_CompanyLinkMan_Audit(); object value; if (item != null) { string[] arrField = new string[] { "CRM_Company_ID", "LinkManName", "Position", "Address", "Mobile", "Telephone", "Email", "Remark" }; Type t1 = typeof(CRM_CompanyLinkMan); PropertyInfo[] propertys1 = t1.GetProperties(); Type t2 = typeof(CRM_CompanyLinkMan_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_CompanyLinkMan_ID = item.ID; model.CreateTime = DateTime.Now; model.CreateUserID = LoginInfo.UserID; model.CreateUserName = LoginInfo.RealName; model.BranchID = 1; model.OperateStatus = 1; model.OperateNode = 2;//质控 } return(model); }
//获得联系人信息 public List <CRM_CompanyLinkMan> GetLinkList(string linkMan) { List <CRM_CompanyLinkMan> list = new List <CRM_CompanyLinkMan>(); if (!string.IsNullOrEmpty(linkMan)) { string[] arrGroup = linkMan.Split('^'); string[] arrItem; for (int i = 0; i < arrGroup.Length; i++) { CRM_CompanyLinkMan model = new CRM_CompanyLinkMan(); arrItem = arrGroup[i].Split('&'); model.LinkManName = arrItem[0]; model.Position = arrItem[1]; model.Address = arrItem[2]; model.Mobile = arrItem[3]; model.Telephone = arrItem[4]; model.Email = arrItem[5]; model.IsDefault = arrItem[6]; model.CreateTime = DateTime.Now; model.CreateUserID = LoginInfo.UserID; model.CreateUserName = LoginInfo.RealName; model.BranchID = LoginInfo.BranchID; model.Status = (int)Common.Status.启用; list.Add(model); } } return(list); }
/// <summary> /// 创建一个客户_企业联系人信息 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据库上下文</param> /// <param name="entity">一个客户_企业联系人信息</param> /// <returns></returns> public bool Create(ref ValidationErrors validationErrors, CRM_CompanyLinkMan entity) { try { repository.Create(entity); return(true); } catch (Exception ex) { validationErrors.Add(ex.Message); ExceptionsHander.WriteExceptions(ex); } return(false); }
/// <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_CompanyLinkMan 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); //提示输入的数据的格式不对 }
/// <summary> /// 修改联系人信息 /// </summary> /// <param name="entity"></param> /// <returns></returns> public Common.ClientResult.Result Put([FromBody] CRM_CompanyLinkMan entity) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (entity != null && ModelState.IsValid) { CRM_CompanyLinkMan_Audit model = GetModel(entity); string returnValue = string.Empty; if (m_BLL.ModifyContact(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); }
/// <summary> /// 根据ID获取数据模型 /// </summary> /// <param name="id">编号</param> /// <returns></returns> public CRM_CompanyLinkMan Get(int id) { CRM_CompanyLinkMan item = m_BLL.GetById(id); return(item); }
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() })); } }