using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace LYFZ.Software.MainBusiness.CameraControlBook.SuperSmallForm
{
public partial class A_CommunicationDetails : LYFZ.Software.UI.CameraControlBook.SuperSmallForm.A_CommunicationDetails
{
LYFZ.BLL.BLL_ErpCustomersTrackRecord ambll = new BLL.BLL_ErpCustomersTrackRecord();
LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
public A_CommunicationDetails()
{
this.Load += A_CommunicationDetails_Load;
//this.cmbtreevName.ComboBoxTree_NodeMouseClick += cmbtreevName_ComboBoxTree_NodeMouseClick;
this.btnClose.Click += btnClose_Click;
this.btnDelete.Click += btnDelete_Click;
this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CommunicationAide, CustomAttributes.OperatingAuthority.Delete);
this.dgvDetails.CellDoubleClick += DgvDetails_CellDoubleClick;
this.btnSearch.Click += BtnSearch_Click;
panelEx3.Visible = true;
//dtpEndDate.Value = DateTime.Now;
//dtpStartDate.Value = DateTime.Now;
}
private void BtnSearch_Click(object sender, EventArgs e)
{
string where = "";
if (!string.IsNullOrEmpty(txtOrdernumber.Text.Trim()))
{
if (!string.IsNullOrEmpty(where))
{
where += " and ";
}
where += "( GP_OrderNumber like '%" + txtOrdernumber.Text.Trim() + "%' or Cus_Name like '%" + txtOrdernumber.Text.Trim() + "%' or Cus_Telephone like '%" + txtOrdernumber.Text.Trim() + "%' )";
}
if (txtOrdernumber.Tag!=null)
{
if (!string.IsNullOrEmpty(where))
{
where += " and ";
}
where += " TR_CustomerID like '%" + txtOrdernumber.Tag.ToString() + "%' ";
}
if (!string.IsNullOrEmpty(dtpStartDate.Text.Trim()))
{
if (!string.IsNullOrEmpty(where))
{
where += " and ";
}
where += " TR_TraceDateTime >='"+ dtpStartDate.Value.ToString("yyyy-MM-dd") + " 00:00:00' ";
}
if (!string.IsNullOrEmpty(dtpEndDate.Text.Trim()))
{
if (!string.IsNullOrEmpty(where))
{
where += " and ";
}
where += " TR_TraceDateTime <='" + dtpEndDate.Value.ToString("yyyy-MM-dd") + " 23:59:59' ";
}
GetDetailLog(where);
}
#region 查看沟通附件;
///
/// 双击沟通记录,弹出对话框;
///
///
///
private void DgvDetails_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (this.dgvDetails.SelectedRows.Count > 0)
{
// 沟通id;
string strTrackRecordId = this.dgvDetails.CurrentRow.Cells["ID"].Value.ToString();
// 沟通的顾客编号;
string strCustomerId = this.dgvDetails.CurrentRow.Cells["TR_CustomerID"].Value.ToString();
// 沟通的附件地址;
string strTrackImages = this.dgvDetails.CurrentRow.Cells["TR_Images"].Value.ToString();
// 沟通日期;
string strCommunicateDate = this.dgvDetails.CurrentRow.Cells["沟通时间"].Value.ToString();
// 沟通时长;
string strCommunicateDuration = this.dgvDetails.CurrentRow.Cells["沟通时长"].Value.ToString();
// 沟通事项;
string strCommunicateMatters = this.dgvDetails.CurrentRow.Cells["沟通事项"].Value.ToString();
// 沟通类型;
string strCommunicateType = this.dgvDetails.CurrentRow.Cells["沟通类型"].Value.ToString();
// 沟通方式;
string strCommunicateWay = this.dgvDetails.CurrentRow.Cells["沟通方式"].Value.ToString();
// 沟通备注;
string strCommunicateRemark = this.dgvDetails.CurrentRow.Cells["沟通备注"].Value.ToString();
// 沟通状态;
string strCommunicateState = this.dgvDetails.CurrentRow.Cells["沟通状态"].Value.ToString();
// 下次沟通日期;
string strNextCommunicateDate = this.dgvDetails.CurrentRow.Cells["下次提醒"].Value.ToString();
// 获取顾客信息;
LYFZ.BLL.BLL_ErpCustomer bll = new BLL.BLL_ErpCustomer();
LYFZ.Model.Model_ErpCustomer model = bll.GetModel("Cus_CustomerNumber", strCustomerId);
// 创建查看对话框;
A_AddCommunicateRecords dlg = new A_AddCommunicateRecords();
dlg.IsSaveDailog = false;
//dlg.strTrackRecordId = strTrackRecordId;
//dlg.strCustomerName = model.Cus_Name;
//dlg.strCustomerPhone = model.Cus_Telephone;
dlg.CusCommInfo.strTrackRecordId = strTrackRecordId;
dlg.CusCommInfo.strCustomerName = model.Cus_Name;
dlg.CusCommInfo.strCustomerPhone = model.Cus_Telephone;
dlg.CusCommInfo.strTrackImages = strTrackImages;
dlg.CusCommInfo.strCommunicateDate = strCommunicateDate;
dlg.CusCommInfo.strCommunicateDuration = strCommunicateDuration;
dlg.CusCommInfo.strCommunicateMatters = strCommunicateMatters;
dlg.CusCommInfo.strCommunicateType = strCommunicateType;
dlg.CusCommInfo.strCommunicateWay = strCommunicateWay;
dlg.CusCommInfo.strCommunicateRemark = strCommunicateRemark;
dlg.CusCommInfo.strCommunicateState = strCommunicateState;
dlg.CusCommInfo.strNextCommunicateDate = strNextCommunicateDate;
dlg.ShowDialog();
}
}
#endregion
///
/// 客户组编号
///
public string StrClientGroupNumber = "";
///
/// 客户编号
///
public string StrClientNumber = "";
///
/// 订单号
///
public string StrNumber = "";
///
/// 来单批号
///
public string StrHctOddnumber = "";
///
/// 是否保存
///
public bool IsSaveed = false;
///
/// 当前登录者的ID
///
string strUserID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
///
/// 窗体加载
///
///
///
void A_CommunicationDetails_Load(object sender, EventArgs e)
{
txtOrdernumber.Text = StrNumber;
if(!string.IsNullOrEmpty(StrClientNumber)&&string.IsNullOrEmpty(txtOrdernumber.Text))
{
string sql = " select Cus_Name from tb_ErpCustomer where Cus_CustomerNumber = '" + StrClientNumber + "' ";
DataTable cusDt = orbll.GetView_Custom(sql).Tables[0];
if(cusDt.Rows.Count>0)
{
txtOrdernumber.Text = cusDt.Rows[0]["Cus_Name"].ToString_s();
}
}
//LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.HidePhoneControls(this.txtPhone);
//DataTable tbl = new DataTable();
//TreeNode trNode = null;
//if (!string.IsNullOrEmpty(this.StrNumber) || !string.IsNullOrEmpty(this.StrClientGroupNumber))
//{
// string StrWhere = "";
// if (!string.IsNullOrEmpty(this.StrNumber))
// { StrWhere = "GP_OrderNumber = '" + this.StrNumber + "'"; }
// else if (!string.IsNullOrEmpty(this.StrClientGroupNumber))
// { StrWhere = "GP_CustomerGroupID = '" + this.StrClientGroupNumber + "'"; }
// tbl = orbll.GetView_Custom("tb_ErpCustomerGroupMembers Left Join tb_ErpCustomer on GM_CustomerID = Cus_CustomerNumber Left Join tb_ErpCustomerGroup on GP_CustomerGroupID = GM_CustomerGroupID", StrWhere: StrWhere, filedOrder: "GM_Master DESC", ShowColumnName: "Cus_CustomerNumber,Cus_Type,Cus_Name,Cus_Telephone").Tables[0];
//}
//else if (!string.IsNullOrEmpty(this.StrClientNumber))
//{ tbl = orbll.GetView_Custom("tb_ErpCustomer", StrWhere: "Cus_CustomerNumber = '" + this.StrClientNumber + "'", ShowColumnName: "Cus_CustomerNumber,Cus_Type,Cus_Name,Cus_Telephone").Tables[0]; }
////else if (!string.IsNullOrEmpty(this.StrHctOddnumber))
//{
// DataTable dt = orbll.GetView_Custom("tb_ErpHospitalClient", StrWhere: "Hct_Oddnumber = '" + this.StrHctOddnumber + "'", ShowColumnName: "Hct_CustomerName,Hct_MyselfMobile").Tables[0];
// trNode = new TreeNode();
// trNode.Text = dt.Rows[0]["Hct_CustomerName"].ToString().Trim();
// trNode.Tag = dt.Rows[0]["Hct_CustomerName"].ToString().Trim();
// trNode.Name = dt.Rows[0]["Hct_MyselfMobile"].ToString().Trim();
// this.cmbtreevName.Nodes.Add(trNode);
// this.cmbtreevName.TextFindTag(dt.Rows[0]["Hct_CustomerName"].ToString().Trim());
// this.cmbtreevName.Enabled = false;
// this.txtPhone.Text = dt.Rows[0]["Hct_MyselfMobile"].ToString().Trim();
//}
//string StrCurrentClientNumber = "";
//for (int i = 0; i < tbl.Rows.Count; i++)
//{
// if (i == 0)
// {
// trNode = new TreeNode();
// trNode.Text = "";
// trNode.Tag = "";
// trNode.Name = "";
// this.cmbtreevName.Nodes.Add(trNode);
// }
// if (tbl.Rows[i]["Cus_Type"].ToString().Trim() != "儿童")
// {
// if (StrCurrentClientNumber == "")
// { StrCurrentClientNumber = tbl.Rows[i]["Cus_CustomerNumber"].ToString().Trim(); }
// trNode = new TreeNode();
// trNode.Text = tbl.Rows[i]["Cus_Name"].ToString().Trim();
// trNode.Tag = tbl.Rows[i]["Cus_CustomerNumber"].ToString().Trim();
// trNode.Name = tbl.Rows[i]["Cus_Telephone"].ToString().Trim();
// this.cmbtreevName.Nodes.Add(trNode);
// }
//}
//if (!string.IsNullOrEmpty(this.StrNumber))
//{
// this.txtOrdernumber.Text = this.StrNumber;
// this.panelEx3.Visible = true;
//}
//else if (!string.IsNullOrEmpty(this.StrHctOddnumber))
//{
// this.txtOrdernumber.Text = this.StrHctOddnumber;
// this.panelEx3.Visible = true;
//}
//else
//{ this.panelEx4.Width += this.panelEx3.Width; }
//if (this.cmbtreevName.Nodes.Count == 2)
//{ this.GetClientData(StrCurrentClientNumber); }
//this.GetDetailLog("");
BtnSearch_Click(null, null);
txtOrdernumber.Tag = null;
}
///
/// 删除数据
///
///
///
void btnDelete_Click(object sender, EventArgs e)
{
try
{
if (this.dgvDetails.Rows.Count > 0)
{
if (this.dgvDetails.CurrentRow.Index >= 0 && this.dgvDetails.CurrentCell.ColumnIndex >= 0)
{
if (this.dgvDetails.CurrentRow != null)
{
if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
if (ambll.Delete(Convert.ToInt32(this.dgvDetails.CurrentRow.Cells["ID"].Value)))
{
this.IsSaveed = true;
MessageBoxCustom.Show("删除成功!");
//this.GetDetailLog(this.cmbtreevName.Tag.ToString().Trim());
BtnSearch_Click(null, null);
}
else
{ MessageBoxCustom.Show("删除失败!"); }
}
return;
}
MessageBoxCustom.Show("请选中你要删除的数据!");
}
}
}
catch (Exception ex)
{ MessageBoxCustom.Show(ex.Message); }
}
///
/// 关闭窗体
///
///
///
void btnClose_Click(object sender, EventArgs e)
{ this.Close(); }
///
/// 选择客户事件
///
///
///
void cmbtreevName_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
this.GetClientData(e.Node.Tag.ToString().Trim());
this.GetDetailLog(e.Node.Tag.ToString().Trim());
}
///
/// 获取当前选择的客户信息
///
///
void GetClientData(string StrTag)
{
//this.cmbtreevName.TagFindText(StrTag);
//this.txtPhone.Text = this.cmbtreevName.StrGetName;
}
///
/// 定义显示
///
void GetDetailLog(string StrTag)
{
//if (string.IsNullOrEmpty(StrTag))
//{
// for (int i = 0; i < this.cmbtreevName.Nodes.Count; i++)
// {
// if (this.cmbtreevName.Nodes[i].Tag.ToString().Trim() != "")
// { StrTag += "'" + this.cmbtreevName.Nodes[i].Tag.ToString().Trim() + "',"; }
// }
//}
//else
//{ StrTag = "'" + StrTag + "'"; }
//DataTable tbl = orbll.GetView_Custom(@"tb_ErpCustomersTrackRecord
// inner join tb_ErpCustomerGroup on TR_CustomerGroupID = GP_CustomerGroupID
// inner join tb_ErpCustomer on TR_CustomerID = Cus_CustomerNumber",
// StrWhere: "TR_CustomerID in (" + StrTag.TrimEnd(',') + ")",
// ShowColumnName: "ID, TR_CustomerID, dbo.fn_CheckUserIDGetUserName(TR_TracePersonID) as 客服人员, TR_Communicationstatus as 沟通状态, dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(TR_TraceDateTime)) as 沟通时间, TR_TraceTimeLength as 沟通时长, TR_TraceType as 沟通类型,TR_SpecificMatters AS 沟通事项 , TR_TraceWay as 沟通方式, dbo.fn_CheckDateTime(TR_CreateDateTime) as 录入时间, dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(TR_NextRemindTime)) AS 下次提醒, TR_Remark as 沟通备注, TR_Images"
//).Tables[0];
if(string.IsNullOrEmpty(StrTag))
{
StrTag = " 1=-1 ";
}
DataTable tbl = orbll.GetView_Custom(@"select distinct
tb_ErpCustomersTrackRecord.ID, TR_CustomerID, dbo.fn_CheckUserIDGetUserName(TR_TracePersonID) as 客服人员,
TR_Communicationstatus as 沟通状态, dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(TR_TraceDateTime)) as 沟通时间,
TR_TraceTimeLength as 沟通时长, TR_TraceType as 沟通类型,TR_SpecificMatters AS 沟通事项 ,
TR_TraceWay as 沟通方式, dbo.fn_CheckDateTime(TR_CreateDateTime) as 录入时间, dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(TR_NextRemindTime)) AS 下次提醒,
TR_Remark as 沟通备注, TR_Images
from tb_ErpCustomersTrackRecord
left join tb_ErpCustomerGroup on TR_CustomerGroupID = GP_CustomerGroupID
left join tb_ErpCustomer on TR_CustomerID = Cus_CustomerNumber" +
" where "+ StrTag
).Tables[0];
this.dgvDetails.DataSource(tbl, strHideField: "ID,TR_CustomerID,TR_Images");
try
{
this.dgvDetails.Columns["沟通时长"].Width = 60;
this.dgvDetails.Columns["沟通时间"].Width = 70;
this.dgvDetails.Columns["下次提醒"].Width = 70;
this.dgvDetails.Columns["录入时间"].Width = 110;
this.dgvDetails.Columns["沟通备注"].Width = 250;
}
catch
{ }
}
}
}