/// <summary> /// 获取指定记录 /// <param name="id">Id值</param> /// </summary> public CustomerPrivate Get(int CustomerPrivateId) { CustomerPrivate returnValue = null; MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdGetCustomerPrivate = cmdGetCustomerPrivate.Clone() as MySqlCommand; _cmdGetCustomerPrivate.Connection = oc; try { _cmdGetCustomerPrivate.Parameters["@CustomerPrivateId"].Value = CustomerPrivateId; if (oc.State == ConnectionState.Closed) { oc.Open(); } MySqlDataReader reader = _cmdGetCustomerPrivate.ExecuteReader(); if (reader.HasRows) { reader.Read(); returnValue = new CustomerPrivate().BuildSampleEntity(reader); } } finally { oc.Close(); oc.Dispose(); oc = null; _cmdGetCustomerPrivate.Dispose(); _cmdGetCustomerPrivate = null; GC.Collect(); } return(returnValue); }
/// <summary> /// Добавить частных клиентов /// </summary> private void AddCustomerPrivate() { using (var uf = new ApplicationDbContext()) { var client = new CustomerPrivate() { Guid = Guid.NewGuid(), Address = "г. Саратов, ул. Техническая", Name = "Петров", Phone = "(927)111-11-11" }; uf.Set <CustomerPrivate>().Add(client); uf.SaveChanges(); var client2 = new CustomerPrivate() { Guid = Guid.NewGuid(), Address = "г. Саратов, ул. Чернышевского", Name = "Иванов", Phone = "(8452)222-22-22" }; uf.Set <CustomerPrivate>().Add(client2); uf.SaveChanges(); } }
public CustomerPrivateView(CustomerPrivate input) { Mapper.CreateMap <CustomerPrivate, CustomerPrivateView>(); Mapper.Map <CustomerPrivate, CustomerPrivateView>(input, this); this.created = input.created.ToString().Replace('T', ' '); this.updated = input.updated.ToString().Replace('T', ' '); }
public CustomerPrivateView(CustomerPrivate input) { Mapper.CreateMap<CustomerPrivate, CustomerPrivateView>(); Mapper.Map<CustomerPrivate, CustomerPrivateView>(input, this); this.created = input.created.ToString().Replace('T', ' '); this.updated = input.updated.ToString().Replace('T', ' '); }
public CustomerPrivate convert(EntityFrameworkContext context) { var output = new CustomerPrivate(); Mapper.CreateMap <CustomerPrivateView, CustomerPrivate>(); Mapper.Map <CustomerPrivateView, CustomerPrivate>(this, output); return(output); }
/// <summary> /// Валидация /// </summary> /// <param name="element"></param> /// <returns></returns> public ValidationResult Validate(CustomerPrivate element) { //if (string.IsNullOrEmpty(element.Name)) //{ // return new ValidationResult(ValidatorResources.ExpositionValidator_NameIsNull); //} return(new ValidationResult()); }
/// <summary> /// Создать нового клиента /// </summary> public void SaveNewClient() { _customer = new CustomerPrivate() { Guid = Guid.NewGuid(), Address = _customerPrivateView.Address, Name = _customerPrivateView.Name, Phone = _customerPrivateView.Phone, }; }
/// <summary> /// 修改指定的数据 /// <param name="e">修改后的数据实体对象</param> /// <para>数据对应的主键必须在实例中设置</para> /// </summary> public void Update(CustomerPrivate e) { MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdUpdateCustomerPrivate = cmdUpdateCustomerPrivate.Clone() as MySqlCommand; _cmdUpdateCustomerPrivate.Connection = oc; try { if (oc.State == ConnectionState.Closed) { oc.Open(); } _cmdUpdateCustomerPrivate.Parameters["@CustomerPrivateId"].Value = e.CustomerPrivateId; _cmdUpdateCustomerPrivate.Parameters["@Name"].Value = e.Name; _cmdUpdateCustomerPrivate.Parameters["@Sex"].Value = e.Sex; _cmdUpdateCustomerPrivate.Parameters["@Birthday"].Value = e.Birthday; _cmdUpdateCustomerPrivate.Parameters["@Industy"].Value = e.Industy; _cmdUpdateCustomerPrivate.Parameters["@Mobile"].Value = e.Mobile; _cmdUpdateCustomerPrivate.Parameters["@Email"].Value = e.Email; _cmdUpdateCustomerPrivate.Parameters["@Qq"].Value = e.Qq; _cmdUpdateCustomerPrivate.Parameters["@Phone"].Value = e.Phone; _cmdUpdateCustomerPrivate.Parameters["@Address"].Value = e.Address; _cmdUpdateCustomerPrivate.Parameters["@Detail"].Value = e.Detail; _cmdUpdateCustomerPrivate.Parameters["@EntId"].Value = e.EntId; _cmdUpdateCustomerPrivate.Parameters["@OwnerId"].Value = e.OwnerId; _cmdUpdateCustomerPrivate.ExecuteNonQuery(); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdUpdateCustomerPrivate.Dispose(); _cmdUpdateCustomerPrivate = null; GC.Collect(); } }
/// <summary> /// 添加数据 /// <param name="es">数据实体对象数组</param> /// <returns></returns> /// </summary> public int Insert(CustomerPrivate e) { MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdInsertCustomerPrivate = cmdInsertCustomerPrivate.Clone() as MySqlCommand; int returnValue = 0; _cmdInsertCustomerPrivate.Connection = oc; try { if (oc.State == ConnectionState.Closed) { oc.Open(); } _cmdInsertCustomerPrivate.Parameters["@Name"].Value = e.Name; _cmdInsertCustomerPrivate.Parameters["@Sex"].Value = e.Sex; _cmdInsertCustomerPrivate.Parameters["@Birthday"].Value = e.Birthday; _cmdInsertCustomerPrivate.Parameters["@Industy"].Value = e.Industy; _cmdInsertCustomerPrivate.Parameters["@Mobile"].Value = e.Mobile; _cmdInsertCustomerPrivate.Parameters["@Email"].Value = e.Email; _cmdInsertCustomerPrivate.Parameters["@Qq"].Value = e.Qq; _cmdInsertCustomerPrivate.Parameters["@Phone"].Value = e.Phone; _cmdInsertCustomerPrivate.Parameters["@Address"].Value = e.Address; _cmdInsertCustomerPrivate.Parameters["@Detail"].Value = e.Detail; _cmdInsertCustomerPrivate.Parameters["@EntId"].Value = e.EntId; _cmdInsertCustomerPrivate.Parameters["@OwnerId"].Value = e.OwnerId; _cmdInsertCustomerPrivate.ExecuteNonQuery(); returnValue = Convert.ToInt32(_cmdInsertCustomerPrivate.LastInsertedId); return(returnValue); } finally { oc.Close(); oc.Dispose(); oc = null; _cmdInsertCustomerPrivate.Dispose(); _cmdInsertCustomerPrivate = null; } }
public void TestPrivateField() { Siaqodb nop = new Siaqodb(objPath); nop.DropType <CustomerPrivate>(); List <CustomerPrivate> listInitial = new List <CustomerPrivate>(); for (int i = 0; i < 10; i++) { CustomerPrivate c = new CustomerPrivate(); c.IDProp = i; c.Name = "ADH" + i.ToString(); listInitial.Add(c); nop.StoreObject(c); } nop.Flush(); var query = from CustomerPrivate c in nop where c.IDProp < 5 select c; Assert.AreEqual(query.ToList <CustomerPrivate>().Count, 5); }
//添加修改个人客户(姓名,性别,出生日期,联系方式{},所属行业,所在地,个人信息,token)返回(true/false) public JsonResult AddPrivateCustomer(int pivid, string name, int sex, string birthday, string contactMobile, string phone, string email, string qq, string address, string detail) { var Res = new JsonResult(); RespResult result = new RespResult(); int _pivid = 0; if (CacheManagerFactory.GetMemoryManager().Contains(token)) { if (!CheckUserFunction(10)) { result.Error = AppError.ERROR_PERMISSION_FORBID; Res.Data = result; Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(Res); } int ownerid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token)); try { CustomerPrivate cp = new CustomerPrivate(); cp.Name = name; cp.Sex = sex; if (birthday != null) { cp.Birthday = Convert.ToDateTime(birthday); } cp.Mobile = contactMobile; cp.Phone = phone; cp.Email = email; cp.Qq = qq; cp.Detail = detail; cp.Address = address; cp.OwnerId = Convert.ToInt32(ownerid); if (pivid == 0) { _pivid = CustomerPrivateAccessor.Instance.Insert(cp); } else { _pivid = pivid; cp.CustomerPrivateId = _pivid; CustomerPrivateAccessor.Instance.Update(cp); } 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); }
public CustomerPrivate convert(EntityFrameworkContext context) { var output = new CustomerPrivate(); Mapper.CreateMap<CustomerPrivateView, CustomerPrivate>(); Mapper.Map<CustomerPrivateView, CustomerPrivate>(this, output); return output; }
public Tuple <APIMethodControl, string> UpdateCustomerPrivate(BasicStructure basic, CustomerPrivate customerPrivate) { using (var context = WebAPIManagerFactory.CreateContext(ip7913, port7913, _logfile)) { var apc = new APIMethodControl(); var res = ""; var temp = FillBasic((int)FunctionList.UpdateCustomerPrivate, basic); temp.Add(customerPrivate.CustomerPrivateNumber); temp.Add(customerPrivate.Brand); temp.Add(customerPrivate.FirstName); temp.Add(customerPrivate.LastName); temp.Add(customerPrivate.AdressLine1); temp.Add(customerPrivate.AdressLine2); temp.Add(customerPrivate.AdressLine3); temp.Add(customerPrivate.City); temp.Add(customerPrivate.ZipCode); temp.Add(customerPrivate.Country); temp.Add(customerPrivate.Email); temp.Add(customerPrivate.Phone); temp.Add(customerPrivate.DateOfBirth); temp.Add(customerPrivate.DriverLicenseNumber); temp.Add(customerPrivate.Comment); temp.Add(customerPrivate.Status.ToString()); temp.Add(customerPrivate.CommentToStatus); temp.Add((customerPrivate.CardType1)); temp.Add((customerPrivate.CardType2)); temp.Add((customerPrivate.CardType3)); temp.Add((customerPrivate.CompanyReference)); temp.Add(customerPrivate.AskNewsletter); temp.Add(customerPrivate.Newsletter); temp.Add(customerPrivate.Wintertires); temp.Add(customerPrivate.Wt_StarDate); temp.Add(customerPrivate.Wt_EndDate); temp.Add(customerPrivate.Wt_PricePrDay); temp.Add(customerPrivate.Wt_MaxPrice); var str = Helpers.EncodeString(temp.ToArray()); var text = context.GetData(str); var keys = Helpers.DecodeString(text); if (keys[0].ToLower() == errorstring) { apc.Succes = false; apc.ErrorCode = keys[1]; apc.ErrorMessage = keys[2]; } else { apc.Succes = true; res = keys[0]; } return(Tuple.Create(apc, res)); } }
public Tuple <APIMethodControl, CustomerPrivate> GetCustomerPrivate(BasicStructure basic, string customerPrivateNumber) { using (var context = WebAPIManagerFactory.CreateContext(ip7913, port7913, _logfile)) { var apc = new APIMethodControl(); var res = new CustomerPrivate(); basic.CustomerId = customerPrivateNumber; var temp = FillBasic((int)FunctionList.GetCustomerPrivate, basic); var str = Helpers.EncodeString(temp.ToArray()); var text = context.GetData(str); var keys = Helpers.DecodeString(text); if (keys[0].ToLower() == errorstring) { apc.Succes = false; apc.ErrorCode = keys[1]; apc.ErrorMessage = keys[2]; } else { apc.Succes = true; res.CustomerPrivateNumber = keys[0]; res.Brand = keys[2]; res.FirstName = keys[3]; res.LastName = keys[4]; res.AdressLine1 = keys[5]; res.AdressLine2 = keys[6]; res.AdressLine3 = keys[7]; res.City = keys[8]; res.ZipCode = keys[9]; res.Country = keys[10]; res.Email = keys[11]; res.Phone = keys[12]; res.DateOfBirth = keys[13]; res.DriverLicenseNumber = keys[14]; res.AgreementNumber = keys[15]; res.Comment = keys[16]; res.Status = (CustomerStatus)int.Parse(keys[17]); res.CommentToStatus = keys[18]; res.ChangeTimeStamp = keys[19]; res.CRMId = keys[20]; res.CardType1 = keys[21]; res.CardType2 = keys[22]; res.CardType3 = keys[23]; res.CompanyReference = keys[24]; res.AskNewsletter = keys[25]; res.Newsletter = keys[26]; res.Wintertires = keys[27]; res.Wt_StarDate = keys[28]; res.Wt_EndDate = keys[29]; res.Wt_PricePrDay = keys[30]; res.Wt_MaxPrice = keys[31]; } return(Tuple.Create(apc, 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); }