/// <summary> /// 获取指定记录 /// <param name="id">Id值</param> /// </summary> public CustomerEnt Get(int CustomerEntId) { CustomerEnt returnValue = null; MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdGetCustomerEnt = cmdGetCustomerEnt.Clone() as MySqlCommand; _cmdGetCustomerEnt.Connection = oc; try { _cmdGetCustomerEnt.Parameters["@CustomerEntId"].Value = CustomerEntId; if (oc.State == ConnectionState.Closed) { oc.Open(); } MySqlDataReader reader = _cmdGetCustomerEnt.ExecuteReader(); if (reader.HasRows) { reader.Read(); returnValue = new CustomerEnt().BuildSampleEntity(reader); } } finally { oc.Close(); oc.Dispose(); oc = null; _cmdGetCustomerEnt.Dispose(); _cmdGetCustomerEnt = null; GC.Collect(); } return(returnValue); }
/// <summary> /// 修改指定的数据 /// <param name="e">修改后的数据实体对象</param> /// <para>数据对应的主键必须在实例中设置</para> /// </summary> public void Update(CustomerEnt e) { MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdUpdateCustomerEnt = cmdUpdateCustomerEnt.Clone() as MySqlCommand; _cmdUpdateCustomerEnt.Connection = oc; try { if (oc.State == ConnectionState.Closed) { oc.Open(); } _cmdUpdateCustomerEnt.Parameters["@CustomerEntId"].Value = e.CustomerEntId; _cmdUpdateCustomerEnt.Parameters["@EntName"].Value = e.EntName; _cmdUpdateCustomerEnt.Parameters["@Industy"].Value = e.Industy; _cmdUpdateCustomerEnt.Parameters["@ContactUsername"].Value = e.ContactUsername; _cmdUpdateCustomerEnt.Parameters["@ContactMobile"].Value = e.ContactMobile; _cmdUpdateCustomerEnt.Parameters["@ContactPhone"].Value = e.ContactPhone; _cmdUpdateCustomerEnt.Parameters["@ContactEmail"].Value = e.ContactEmail; _cmdUpdateCustomerEnt.Parameters["@ContactQq"].Value = e.ContactQq; _cmdUpdateCustomerEnt.Parameters["@Address"].Value = e.Address; _cmdUpdateCustomerEnt.Parameters["@Detail"].Value = e.Detail; _cmdUpdateCustomerEnt.Parameters["@EntId"].Value = e.EntId; _cmdUpdateCustomerEnt.Parameters["@OwnerId"].Value = e.OwnerId; _cmdUpdateCustomerEnt.ExecuteNonQuery(); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdUpdateCustomerEnt.Dispose(); _cmdUpdateCustomerEnt = null; GC.Collect(); } }
/// <summary> /// 添加数据 /// <param name="es">数据实体对象数组</param> /// <returns></returns> /// </summary> public int Insert(CustomerEnt e) { MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdInsertCustomerEnt = cmdInsertCustomerEnt.Clone() as MySqlCommand; int returnValue = 0; _cmdInsertCustomerEnt.Connection = oc; try { if (oc.State == ConnectionState.Closed) { oc.Open(); } _cmdInsertCustomerEnt.Parameters["@EntName"].Value = e.EntName; _cmdInsertCustomerEnt.Parameters["@Industy"].Value = e.Industy; _cmdInsertCustomerEnt.Parameters["@ContactUsername"].Value = e.ContactUsername; _cmdInsertCustomerEnt.Parameters["@ContactMobile"].Value = e.ContactMobile; _cmdInsertCustomerEnt.Parameters["@ContactPhone"].Value = e.ContactPhone; _cmdInsertCustomerEnt.Parameters["@ContactEmail"].Value = e.ContactEmail; _cmdInsertCustomerEnt.Parameters["@ContactQq"].Value = e.ContactQq; _cmdInsertCustomerEnt.Parameters["@Address"].Value = e.Address; _cmdInsertCustomerEnt.Parameters["@Detail"].Value = e.Detail; _cmdInsertCustomerEnt.Parameters["@EntId"].Value = e.EntId; _cmdInsertCustomerEnt.Parameters["@OwnerId"].Value = e.OwnerId; _cmdInsertCustomerEnt.ExecuteNonQuery(); returnValue = Convert.ToInt32(_cmdInsertCustomerEnt.LastInsertedId); return(returnValue); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdInsertCustomerEnt.Dispose(); _cmdInsertCustomerEnt = null; } }
//添加修改企业客户(企业名称,所属行业,联系人{姓名,手机,座机,email,qq},企业地址,企业资料,客户ID,token) public JsonResult AddEntCustomer(int customerEntId, string entName, string industy, string contactUsername, string contactMobile, string phone, string email, string qq, string address, string Detail) { var Res = new JsonResult(); RespResult result = new RespResult(); int _customerEntId = 0; if (CacheManagerFactory.GetMemoryManager().Contains(token)) { if (!CheckUserFunction(9)) { result.Error = AppError.ERROR_PERMISSION_FORBID; Res.Data = result; Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(Res); } int ownerid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token)); try { CustomerEnt ce = new CustomerEnt(); //通过CustomerEntModel序列化为实体 ce.OwnerId = Convert.ToInt32(ownerid); ce.Address = address; ce.EntName = entName; ce.Industy = industy; ce.ContactUsername = contactUsername; ce.ContactMobile = contactMobile; ce.ContactPhone = phone; ce.ContactEmail = email; ce.ContactQq = qq; ce.Detail = Detail; ce.EntId = CurrentUser.EntId; if (customerEntId == 0) { _customerEntId = CustomerEntAccessor.Instance.Insert(ce); } else { _customerEntId = customerEntId; ce.CustomerEntId = _customerEntId; CustomerEntAccessor.Instance.Update(ce); } result.Error = AppError.ERROR_SUCCESS; } catch (Exception e) { result.Error = AppError.ERROR_FAILED; result.ExMessage = e.ToString(); } } else { result.Error = AppError.ERROR_PERSON_NOT_LOGIN; } Res.Data = result; Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(Res); }
// // GET: /MarketingManagement/Marketing/ /// <summary> /// 销售机会即企业客户以及个人客户信息,此处都是调用客户信息 /// </summary> /// <returns></returns> /// <summary> /// 添加销售机会(机会类型,客户类型,联系人,机会描述,联系方式{},是否同步,token)返回(true/false) /// 客户类型分为:1:企业客户2:个人客户;默认为企业客户 /// </summary> public JsonResult AddMarketingChance(int chanceType, int customerType, string username, string chanceDetail, string tel, string phone, string email, string qq, bool Isasyn) { var Res = new JsonResult(); RespResult result = new RespResult(); try { if (CacheManagerFactory.GetMemoryManager().Contains(token)) { if (!CheckUserFunction("1202")) { result.Error = AppError.ERROR_PERMISSION_FORBID; Res.Data = result; Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(Res); } MarketingChance chance = new MarketingChance(); chance.AddTime = DateTime.Now; chance.ChanceType = chanceType; chance.ContactName = username; chance.CustomerType = customerType; chance.Email = email; chance.EntId = CurrentUser.EntId; chance.Phone = phone; chance.Qq = qq; chance.Remark = chanceDetail; chance.Tel = tel; chance.UserId = CurrentUser.UserId; if (Isasyn) { switch (customerType) { case 1: //添加企业客户 CustomerEnt ce = new CustomerEnt(); ce.EntName = username; ce.ContactUsername = username; ce.ContactMobile = phone; ce.ContactPhone = phone; ce.ContactEmail = email; ce.ContactQq = qq; ce.Detail = chanceDetail; ce.OwnerId = CurrentUser.UserId; ce.EntId = CurrentUser.EntId; CustomerEntAccessor.Instance.Insert(ce); break; case 2: //添加个人客户 CustomerPrivate cp = new CustomerPrivate(); cp.Name = username; cp.Mobile = phone; cp.Phone = phone; cp.Email = email; cp.Qq = qq; cp.Detail = chanceDetail; cp.OwnerId = CurrentUser.UserId; cp.EntId = CurrentUser.EntId; CustomerPrivateAccessor.Instance.Insert(cp); break; } } int i = MarketingChanceAccessor.Instance.Insert(chance); if (i > 0) { result.Id = i; result.Error = AppError.ERROR_SUCCESS; } else { result.Error = AppError.ERROR_FAILED; } } else { result.Error = AppError.ERROR_PERSON_NOT_LOGIN; } } catch (Exception e) { result.Error = AppError.ERROR_FAILED; result.ExMessage = e.ToString(); } Res.Data = result; Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(Res); }
//编辑销售机会详情(机会ID,机会类型,客户类型,机会描述,联系人,联系方式,token) 返回(true/false) public JsonResult EditMarketingInfo(int cid, int chanceType, int customerType, string username, string chanceDetail, string tel, string phone, string email, string qq, int customerId) { var Res = new JsonResult(); RespResult result = new RespResult(); try { if (CacheManagerFactory.GetMemoryManager().Contains(token)) { if (!CheckUserFunction(19)) { result.Error = AppError.ERROR_PERMISSION_FORBID; Res.Data = result; Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(Res); } MarketingChance chance = new MarketingChance(); chance = MarketingChanceAccessor.Instance.Get(cid); chance.ChanceType = chanceType; chance.ContactName = username; chance.CustomerType = customerType; chance.Email = email; chance.Phone = phone; chance.Qq = qq; chance.Remark = chanceDetail; chance.Tel = tel; MarketingChanceAccessor.Instance.Update(chance); switch (customerType) { case 1: //编辑企业客户 CustomerEnt ce = CustomerEntAccessor.Instance.Get(customerId); ce.EntName = username; ce.ContactUsername = username; ce.ContactMobile = phone; ce.ContactPhone = phone; ce.ContactEmail = email; ce.ContactQq = qq; ce.Detail = chanceDetail; CustomerEntAccessor.Instance.Update(ce); break; case 2: //编辑个人客户 CustomerPrivate cp = CustomerPrivateAccessor.Instance.Get(customerId); cp.Name = username; cp.Mobile = phone; cp.Phone = phone; cp.Email = email; cp.Qq = qq; cp.Detail = chanceDetail; CustomerPrivateAccessor.Instance.Update(cp); break; } result.Error = AppError.ERROR_SUCCESS; } else { result.Error = AppError.ERROR_PERSON_NOT_LOGIN; } } catch (Exception e) { result.Error = AppError.ERROR_FAILED; result.ExMessage = e.ToString(); } Res.Data = result; Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(Res); }