/// <summary> /// 客户资料来电,格式:kld [telephone] /// </summary> /// <param name="s"></param> public static string kld(string s, string webservice) { char newline = '\xD'; string ret = ""; EagleWebService.wsYzpbtoc ws = new EagleWebService.wsYzpbtoc(webservice); string[] sp = new string[] { " ", ",", ",", ":", ";", ":", ";" }; string[] a = s.Split(sp, StringSplitOptions.RemoveEmptyEntries); if (a.Length > 1) { ret = ws.GetCustomerByPhone(a[1]); if (ret.ToLower().Trim() == "none") { throw new Exception(string.Format("不存在{0}的客户资料", a[1])); } else if (ret.ToLower().Trim() == "failed") { throw new Exception(string.Format("查询失败!")); } } else { ///here to do: give callxml value. string callxml = ""; if (string.IsNullOrEmpty(callxml)) { throw new Exception("没有检测到客户来电记录!"); } System.Xml.XmlDocument xd = new System.Xml.XmlDocument(); xd.LoadXml(callxml);//不能载入,则会抛出异常 if (xd.SelectSingleNode("NewCustomer") != null) { throw new Exception("当前来电为新客户,请先保存该客户信息!"); } ret = callxml; } DataEntity.XMLSchema.Customers customer; customer = DataEntity.XMLSchema.xml_BaseClass.LoadXml <DataEntity.XMLSchema.Customers>(ret); if (customer.Passengers == null || customer.Passengers.Count == 0) { throw new Exception("该来电客户目前没有常旅客!"); } string retString = ""; foreach (DataEntity.XMLSchema.Passenger passenger in customer.Passengers) { retString += passenger.fet_ID + " " + passenger.fet_Name + " " + passenger.fet_CardID1 + newline.ToString(); } return(retString); }
/// <summary> /// 根据当前来电,或者手工输入电话号码查询客户常旅客列表 /// modified by chenqj /// </summary> private void KHZLLD() { string ret = string.Empty; XmlDocument xd = new XmlDocument(); try { string[] arr = cmdex.Split(sp, StringSplitOptions.RemoveEmptyEntries); if (arr.Length > 1)//手工输入电话号码查询 { ret = ws.GetCustomerByPhone(arr[1]); if (ret.ToLower() == "none") { resKHZLLD = ""; throw new Exception("该客户资料不存在!"); } else if (ret.ToLower() == "failed") { resKHZLLD = ""; throw new Exception("查询失败!"); } else { Options.GlobalVar.B2CCallingXml = ret; } } else//1.从CallXml中取CustomID { if (string.IsNullOrEmpty(Options.GlobalVar.B2CCallingXml)) { resKHZLLD = ""; throw new Exception("没有检测到客户来电记录!"); } //if (NewCustomer()) return; string strXml = Options.GlobalVar.B2CCallingXml; try { xd.LoadXml(strXml); } catch (Exception ee) { resKHZLLD = ""; throw new Exception("读取来电记录失败!" + Environment.NewLine + ee.Message); } if (xd.SelectSingleNode("NewCustomer") != null) { throw new Exception("当前来电为新客户,请先保存该客户信息!"); } else { ret = strXml; } } //2.调用WebService返回关联用户资料 resKHZLLD = ret; DataEntity.XMLSchema.Customers customer; customer = DataEntity.XMLSchema.xml_BaseClass.LoadXml <DataEntity.XMLSchema.Customers>(ret); if (customer.Passengers == null || customer.Passengers.Count == 0) { throw new Exception("该来电客户目前没有常旅客!"); } retString = ""; foreach (DataEntity.XMLSchema.Passenger passenger in customer.Passengers) { retString += passenger.fet_ID + " " + passenger.fet_Name + " " + passenger.fet_CardID1 + newline.ToString(); } bFlag = true; } catch (Exception ee) { //resKHZLLD = ""; retString = ee.Message; bFlag = false; } }
private void btSaveCost_Click(object sender, EventArgs e) { btnSaveCustomer.Enabled = false; string name = txtName.Text.Trim(); string customerNo = txtCustomerNo.Text.Trim(); string tel = cmbLandline.Text.Trim(); if (string.IsNullOrEmpty(name)) { errorProvider1.SetError(txtName, "名字不能为空!"); return; } else { errorProvider1.SetError(txtName, ""); } if (string.IsNullOrEmpty(tel)) { errorProvider1.SetError(cmbLandline, "联系电话不能为空!"); return; } else { errorProvider1.SetError(cmbLandline, ""); } DataEntity.XMLSchema.NewCustomers customer = new DataEntity.XMLSchema.NewCustomers(); customer.CustomerName = name; customer.CustomerCode = customerNo; customer.CardID = cmbIdentity.Text.Trim(); customer.DepartmentID = Options.GlobalVar.B2CDepartmentID.Split(':')[0]; customer.OperaterID = Options.GlobalVar.B2CUserID.Split(':')[0]; customer.Sex = this.rbMale.Checked ? "0" : "1"; customer.AccumulatedNum = "0"; customer.VIPcard = txtSepcialNo.Text.Trim(); customer.IsInceptSMS = cbSMS.Checked ? "true" : "false"; //if (tel.Length >= 11) customer.Mobile = tel; //else // customer.Tel = tel;//B2C后台已取消该字段 string xml = new TXIO.XML_IO().SaveToText(customer); try { int ret = ws.NewCustomer(xml); switch (ret) { case -1: //MessageBox.Show("改来电客户已经存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); DataEntity.XMLSchema.UpdateCustomer cus = new UpdateCustomer(); cus.CustomerName = customer.CustomerName; cus.CardID = customer.CardID; cus.IsInceptSMS = Convert.ToInt32(cbSMS.Checked).ToString(); cus.Sex = customer.Sex;// customer.Sex; cus.VIPcard = customer.VIPcard; string xmlUpdate = new TXIO.XML_IO().SaveToText(cus); string retUpdate = ws.UpdateCustomer(int.Parse(this.CustomerID), xmlUpdate); switch (retUpdate) { case "1": MessageBox.Show("更新客户资料成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); break; case "-1": MessageBox.Show("客户不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; case "0": MessageBox.Show("更新客户资料发生错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } break; case -2: MessageBox.Show("数据库错误,保存失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; default: MessageBox.Show("客户资料保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.CustomerID = ret.ToString(); Options.GlobalVar.B2CCallingXml = ws.GetCustomerByPhone(phoneNumber); break; } } catch (Exception ee) { MessageBox.Show("保存客户资料发生错误,详细内容如下:" + System.Environment.NewLine + System.Environment.NewLine + ee.Message + System.Environment.NewLine + System.Environment.NewLine + "[" + ws.Url + "]", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning); } btnSaveCustomer.Enabled = true; }