public bool UpdateCustomerInfo(CustomerInfo customerInfo) { string json = JsonConvert.SerializeObject(customerInfo); byte[] jsonByte = Encoding.UTF8.GetBytes(json); int cByte = ParamFieldLength.PACKAGE_HEAD + jsonByte.Length; byte[] sendByte = new byte[cByte]; int byteOffset = 0; Array.Copy(BitConverter.GetBytes((int)Command.ID_UPDATE_CUSTOMERINFO), sendByte, BasicTypeLength.INT32); byteOffset = BasicTypeLength.INT32; Array.Copy(BitConverter.GetBytes(cByte), 0, sendByte, byteOffset, BasicTypeLength.INT32); byteOffset += BasicTypeLength.INT32; Array.Copy(jsonByte, 0, sendByte, byteOffset, jsonByte.Length); byteOffset += jsonByte.Length; bool result = false; using (SocketClient socket = new SocketClient(ConstantValuePool.BizSettingConfig.IPAddress, ConstantValuePool.BizSettingConfig.Port)) { Byte[] receiveData = null; Int32 operCode = socket.SendReceive(sendByte, out receiveData); if (operCode == (int)RET_VALUE.SUCCEEDED) { result = true; } socket.Close(); } return result; }
private void CallBack(Object stateObject) { if (ConstantValuePool.BizSettingConfig.telCallConfig.Enabled && ConstantValuePool.IsTelCallWorking) { if (ConstantValuePool.BizSettingConfig.telCallConfig.Model == 0 || ConstantValuePool.BizSettingConfig.telCallConfig.Model == 1) { if (LDT.Check_State(ConstantValuePool.TelCallID) == 255) { string strPhoneNo = LDT.GetNumber_Tel(1).ToString(); if (strPhoneNo.Length > 0) { //创建通话记录 CallRecord callRecord = new CallRecord(); callRecord.CallRecordID = Guid.NewGuid(); callRecord.Telephone = strPhoneNo; callRecord.CallTime = DateTime.Now; callRecord.Status = 0; CustomersService.GetInstance().CreateOrUpdateCallRecord(callRecord); this.lbTelephone.Text = strPhoneNo; this.txtCustomerName.Text = string.Empty; this.txtAddress1.Text = string.Empty; this.txtAddress2.Text = string.Empty; this.txtAddress3.Text = string.Empty; _customerInfo = CustomersService.GetInstance().GetCustomerInfoByPhone(strPhoneNo); if (_customerInfo != null) { txtCustomerName.Text = _customerInfo.CustomerName; txtAddress1.Text = _customerInfo.DeliveryAddress1; txtAddress2.Text = _customerInfo.DeliveryAddress2; txtAddress3.Text = _customerInfo.DeliveryAddress3; if (_customerInfo.ActiveIndex == 1) { ckAddress1.Checked = true; } else if (_customerInfo.ActiveIndex == 2) { ckAddress2.Checked = true; } else if (_customerInfo.ActiveIndex == 3) { ckAddress3.Checked = true; } } } } } if (ConstantValuePool.BizSettingConfig.telCallConfig.Model == 0) { ConstantValuePool.IsTelCallWorking = LDT.Plugin_Tel(ConstantValuePool.TelCallID); } } }
public FormIncomingCall(string telephone, string address, int callType) { _customerInfo = CustomersService.GetInstance().GetCustomerInfoByPhone(telephone); _address = address; _callType = callType; InitializeComponent(); this.lbTelephone.Text = telephone; if (callType == 1 && ConstantValuePool.BizSettingConfig.telCallConfig.Enabled && ConstantValuePool.IsTelCallWorking) { timer = new System.Threading.Timer(new TimerCallback(CallBack), null, 15000, 500); } }
public int CreateCustomerInfo(CustomerInfo customerInfo) { Hashtable htParam = new Hashtable(); htParam["Telephone"] = customerInfo.Telephone; htParam["CustomerName"] = customerInfo.CustomerName; htParam["DeliveryAddress1"] = customerInfo.DeliveryAddress1; htParam["DeliveryAddress2"] = customerInfo.DeliveryAddress2; htParam["DeliveryAddress3"] = customerInfo.DeliveryAddress3; htParam["ActiveIndex"] = customerInfo.ActiveIndex; htParam["LastModifiedEmployeeID"] = customerInfo.LastModifiedEmployeeID; htParam["ReturnValue"] = 0; ExecuteInsert("InsertCustomerInfo", htParam); return (int)htParam["ReturnValue"]; }
/// <summary> /// 创建客户信息 0:数据库操作失败, 1:成功, 2:手机号已存在 /// </summary> public int CreateCustomerInfo(CustomerInfo customerInfo) { int result = 0; try { _daoManager.OpenConnection(); result = _customerInfoDao.CreateCustomerInfo(customerInfo); } catch (Exception exception) { result = 0; LogHelper.GetInstance().Error(string.Format("[CreateCustomerInfo]参数:customerInfo_{0}", JsonConvert.SerializeObject(customerInfo)), exception); } finally { _daoManager.CloseConnection(); } return result; }
public bool UpdateCustomerInfo(CustomerInfo customerInfo) { int result = 0; result = ExecuteUpdate("UpdateCustomerInfo", customerInfo); return result > 0; }
private void btnCreate_Click(object sender, EventArgs e) { CustomerInfo customerInfo = new CustomerInfo { Telephone = this.txtTelephone.Text.Trim(), CustomerName = this.txtName.Text.Trim(), DeliveryAddress1 = this.txtAddress1.Text.Trim(), DeliveryAddress2 = this.txtAddress2.Text.Trim(), DeliveryAddress3 = this.txtAddress3.Text.Trim() }; if (!string.IsNullOrEmpty(customerInfo.DeliveryAddress3)) { customerInfo.ActiveIndex = 3; } if (!string.IsNullOrEmpty(customerInfo.DeliveryAddress2)) { customerInfo.ActiveIndex = 2; } if (!string.IsNullOrEmpty(customerInfo.DeliveryAddress1)) { customerInfo.ActiveIndex = 1; } customerInfo.LastModifiedEmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID; if (string.IsNullOrEmpty(customerInfo.Telephone)) { MessageBox.Show("联系电话不能为空!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(customerInfo.CustomerName)) { MessageBox.Show("客户名称不能为空!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (customerInfo.ActiveIndex <= 0) { MessageBox.Show("客户的地址信息不能为空!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int result = CustomersService.GetInstance().CreateCustomerInfo(customerInfo); if (result == 1) { MessageBox.Show("创建客户信息成功!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result == 2) { MessageBox.Show("联系电话已存在,不能重复添加!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("创建客户信息失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnCancel_Click(object sender, EventArgs e) { m_SelectedCustomerInfo = null; this.Close(); }
private void btnConfirm_Click(object sender, EventArgs e) { if (dgvCustomerInfo.CurrentRow != null) { int selectedIndex = dgvCustomerInfo.CurrentRow.Index; m_SelectedCustomerInfo = dgvCustomerInfo.Rows[selectedIndex].Cells["Telephone"].Tag as CustomerInfo; this.Close(); } }
private void dgvCustomerInfo_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (dgvCustomerInfo.CurrentRow != null) { int selectedIndex = dgvCustomerInfo.CurrentRow.Index; m_SelectedCustomerInfo = dgvCustomerInfo.Rows[selectedIndex].Cells["Telephone"].Tag as CustomerInfo; this.Close(); } }
private void btnConfirm_Click(object sender, EventArgs e) { int activeIndex = 1; string address = string.Empty; if (ckAddress1.Checked) { activeIndex = 1; address = txtAddress1.Text.Trim(); } else if (ckAddress2.Checked) { activeIndex = 2; address = txtAddress2.Text.Trim(); } else if (ckAddress3.Checked) { activeIndex = 3; address = txtAddress3.Text.Trim(); } if (string.IsNullOrEmpty(address)) { if (_customerInfo == null) { m_IncomingPhoneNo = lbTelephone.Text; this.Close(); } else { MessageBox.Show("选择的地址不能为空!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } return; } CustomerInfo customerInfo = new CustomerInfo(); customerInfo.Telephone = this.lbTelephone.Text; customerInfo.CustomerName = this.txtCustomerName.Text.Trim(); customerInfo.DeliveryAddress1 = this.txtAddress1.Text.Trim(); customerInfo.DeliveryAddress2 = this.txtAddress2.Text.Trim(); customerInfo.DeliveryAddress3 = this.txtAddress3.Text.Trim(); customerInfo.ActiveIndex = activeIndex; customerInfo.LastModifiedEmployeeID = ConstantValuePool.CurrentEmployee.EmployeeID; if (_customerInfo == null) //新增 { int result = CustomersService.GetInstance().CreateCustomerInfo(customerInfo); if (result == 1) { _selectedAddress = address; m_CustomerInfo = customerInfo; this.Close(); } else if (result == 2) { MessageBox.Show("联系电话已存在,不能重复添加!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("创建客户信息失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else //更新 { if (CustomersService.GetInstance().UpdateCustomerInfo(customerInfo)) { _selectedAddress = address; m_CustomerInfo = customerInfo; this.Close(); } else { MessageBox.Show("更新客户信息失败,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }