123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462 |
- 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;
- using LYFZ.Command;
- using LYFZ.ComponentLibrary;
- namespace LYFZ.Software.MainBusiness.CallerWizard
- {
- public partial class FrmCustomerCalls : LYFZ.Software.UI.CallerWizard.FrmCustomerCalls
- {
- LYFZ.BLL.BLL_ErpCallWizard cwbll = new BLL.BLL_ErpCallWizard();
- private delegate void UpdateControl();
- public FrmCustomerCalls(string StrType = "")
- {
- this.StrLoadType = StrType;
- this.Shown += FrmCustomerCalls_Shown;
- this.btnQuery.Click += btnQuery_Click;
- this.btnDelete.Click += btnDelete_Click;
- this.btnCall.Click += btnCall_Click;
- this.btnPlayer.Click += btnPlayer_Click;
- this.btnClose.Click += btnClose_Click;
- this.ucPager.EventPaging += UcPagerEx1_EventPaging;
- this.txtQuery.KeyDown += txtQuery_KeyDown;
- this.cmbtreevClientType.ComboBoxTree_NodeMouseClick += cmbtreevClientType_ComboBoxTree_NodeMouseClick;
- this.Resize += FrmCustomerCalls_Resize;
- this.dgvData.RowsAdded += dgvData_RowsAdded;
- }
- string GetPhoneColumn()
- {
- string strColumnName = "来电电话";
- switch (StrLoadType)
- {
- case "已接电话": strColumnName = "来电号码"; break;
- case "拨出电话": strColumnName = "拨出号码"; break;
- case "未接电话": strColumnName = "来电号码"; break;
- }
- return strColumnName;
- }
- string GetDateTimeColumn()
- {
- string strColumnName = "来电时间";
- switch (StrLoadType)
- {
- case "已接电话": strColumnName = "来电时间"; break;
- case "拨出电话": strColumnName = "拨出时间"; break;
- case "未接电话": strColumnName = "来电时间"; break;
- }
- return strColumnName;
- }
- enum CallClientType
- {
- 全部 = -4,
- 订单客户 = 0,
- 老客户 = 1,
- 意向客户 = 2,
- 其他客户 = -1,
- 未知来电 = -2,
- 员工电话 = -3
- }
- string StrLoadType;
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void FrmCustomerCalls_Shown(object sender, EventArgs e)
- {
- this.UcNavigationTool.LabTitle = this.StrLoadType;
- this.dtpDateStart.DateValue = SDateTime.Now.ToString("yyyy-MM") + "-01";
- this.dtpDateEnd.DateValue = Convert.ToDateTime(this.dtpDateStart.DateValue).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
- this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CustomerCallsCompetence, CustomAttributes.OperatingAuthority.Delete);
- string[] StrArrayName = Enum.GetNames(typeof(CallClientType));
- TreeNode root = null;
- for (int i = 0; i < StrArrayName.Length; i++)
- {
- if (i == 0)
- {
- root = new TreeNode();
- root.Text = "全部";
- root.Tag = Convert.ToInt32(Enum.Parse(typeof(CallClientType), "全部"));
- root.Name = root.Tag.ToString();
- this.cmbtreevClientType.Nodes.Add(root);
- }
- if (StrArrayName[i].Trim() != "全部")
- {
- root = new TreeNode();
- root.Text = StrArrayName[i].Trim();
- root.Tag = Convert.ToInt32(Enum.Parse(typeof(CallClientType), StrArrayName[i].Trim()));
- root.Name = root.Tag.ToString();
- this.cmbtreevClientType.Nodes.Add(root);
- }
- }
- this.cmbtreevClientType.TextFindTag(CallClientType.全部.ToString());
- this.PublicFunctionRows();
- bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(
- VersionControl.VersionFunctionEnum.来电精灵);
- if (!b)
- {
- this.Close();
- return;
- }
- }
- /// <summary>
- /// 查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnQuery_Click(object sender, EventArgs e)
- {
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 回车查询
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void txtQuery_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyCode == Keys.Enter)
- { this.PublicFunctionRows(); }
- }
- /// <summary>
- /// 客户类型选择
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void cmbtreevClientType_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
- {
- this.PublicFunctionRows();
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnDelete_Click(object sender, EventArgs e)
- {
- if (this.dgvData.Rows.Count > 0)
- {
- if (MessageBoxCustom.Show("您确定删除吗?", "温馨提示!", MessageBoxButtons.YesNo) == DialogResult.No)
- { return; }
- int deleteCount = 0;
- if (this.dgvData.SelectedRows.Count > 0)
- {
- for (int i = 0; i < this.dgvData.SelectedRows.Count; i++)
- {
- if (!string.IsNullOrEmpty(this.dgvData.SelectedRows[i].Cells["ID"].Value.ToString().Trim()))
- {
- if (cwbll.Delete(Convert.ToInt32(this.dgvData.SelectedRows[i].Cells["ID"].Value)))
- {
- deleteCount++;
- string StrPath = this.dgvData.SelectedRows[i].Cells["路径"].Value.ToString().Trim();
- if (!string.IsNullOrEmpty(StrPath))
- {
- string StrNewPath = StrPath.Substring(StrPath.IndexOf("ShareDirectory"), StrPath.Length - StrPath.IndexOf("ShareDirectory"));
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- backgroundWorker.ReportProgress(0, "正在连接服务器...");
- try
- {
- string ret = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.TcpClient.DeleteFile(StrNewPath, backgroundWorker);
- if (ret.IndexOf("成功") == -1)
- { MessageBoxCustom.Show(ret, backgroundWorker: backgroundWorker); }
- }
- catch (Exception ex)
- { MessageBoxCustom.Show(ex.Message, backgroundWorker: backgroundWorker); }
- });
- }
- string logsContent = "删除客户来电电话号码:" + this.dgvData.SelectedRows[i].Cells[GetPhoneColumn()].Value.ToString();
- LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除电话记录, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
- }
- }
- }
- }
- if (deleteCount > 0)
- {
- MessageBoxCustom.Show("删除成功!");
- this.PublicFunctionRows();
- }
- }
- }
- /// <summary>
- /// 呼叫
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnCall_Click(object sender, EventArgs e)
- {
- if (this.dgvData.Rows.Count > 0)
- {
- if (this.dgvData.CurrentRow == null)
- { MessageBoxCustom.Show("请选中你要录音回放的数据!"); return; }
- if (this.dgvData.CurrentRow.Index >= 0 && this.dgvData.CurrentCell.RowIndex >= 0)
- {
- if (!string.IsNullOrEmpty(this.dgvData.CurrentRow.Cells[GetPhoneColumn()].Value.ToString().Trim()))
- {
- LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.PhoneCall(this.dgvData.CurrentRow.Cells[GetPhoneColumn()].Value.ToString().Trim());
- }
- else
- { MessageBoxCustom.Show("选择的通话记录电话号码为空!"); }
- }
- }
- }
- /// <summary>
- /// 录音回放
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnPlayer_Click(object sender, EventArgs e)
- {
- if (this.dgvData.Rows.Count > 0)
- {
- if (this.dgvData.CurrentRow == null)
- { MessageBoxCustom.Show("请选中你要录音回放的数据!"); return; }
- if (this.dgvData.CurrentRow.Index >= 0 && this.dgvData.CurrentCell.RowIndex >= 0)
- {
- string StrPath = this.dgvData.CurrentRow.Cells["路径"].Value.ToString().Trim();
- if (!string.IsNullOrEmpty(StrPath))
- {
- string StrNewPath = StrPath.Substring(StrPath.IndexOf("ShareDirectory"), StrPath.Length - StrPath.IndexOf("ShareDirectory"));
- LYFZ.Model.Model_Config mConfig = new LYFZ.BLL.BLL_Config().GetModel_SysConfig();
- //播放
- FrmPlayer set = new FrmPlayer();
- set.Path = "\\\\" + mConfig.ServerHostOrIP + "\\" + StrNewPath;
- set.ShowDialog();
- }
- else
- { MessageBoxCustom.Show("选择的通话记录未录音!"); }
- }
- }
- }
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 窗体大小发生变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void FrmCustomerCalls_Resize(object sender, EventArgs e)
- {
- int ControlsWidth = 0;
- for (int i = 0; i < this.flowLayoutPanel1.Controls.Count; i++)
- {
- if (this.flowLayoutPanel1.Controls[i].Visible)
- { ControlsWidth += this.flowLayoutPanel1.Controls[i].Width; }
- }
- int PanlHeightCount = 1;
- if (this.flowLayoutPanel1.Width < ControlsWidth)
- {
- PanlHeightCount = ControlsWidth / this.flowLayoutPanel1.Width;
- if ((ControlsWidth / this.flowLayoutPanel1.Width) > 0)
- { PanlHeightCount++; }
- }
- this.flowLayoutPanel1.Height = 33 * PanlHeightCount;
- //this.panelEx2.Height = this.flowLayoutPanel1.Height + 71;
- }
- /// <summary>
- /// 列表添加行时发生
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvData_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
- {
- /*if (!string.IsNullOrEmpty(this.dgvData.Rows[e.RowIndex].Cells[this.GetDateTimeColumn()].Value.ToString().Trim()))
- {
- this.dgvData.Rows[e.RowIndex].Cells[this.GetDateTimeColumn()].Value = LYFZ.Command.Command_Validate.DateTimeToString(this.dgvData.Rows[e.RowIndex].Cells[this.GetDateTimeColumn()].Value, "yyyy-MM-dd HH:mm");
- }*/
- }
- /// <summary>
- /// 分页前数据,便于展开时用来查询订单的子数据
- /// </summary>
- DataTable tblMianSelectData = new DataTable();
- /// <summary>
- /// 创建行
- /// </summary>
- private void PublicFunctionRows()
- {
- this.ucPager.EventPaging -= UcPagerEx1_EventPaging;
- this.ucPager.EventPaging += UcPagerEx1_EventPaging;
- this.ucPager.PageCurrent = 1;
- this.ucPager.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
- this.ucPager.Bind();
- }
- /// <summary>
- /// 画分页
- /// </summary>
- /// <param name="e"></param>
- /// <returns></returns>
- int UcPagerEx1_EventPaging(UCPager.EventPagingArg e)
- {
- LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
- pageData.TableName = GetTableName_Main();
- pageData.PageIndex = this.ucPager.PageCurrent;
- pageData.PageSize = this.ucPager.PageSize;
- pageData.QueryCondition = GetWhereStr();
- pageData.OrderStr = "Callw_DateTime DESC";
- pageData.OrderType = 1;
- this.dgvData.dgvGuidName = GetGuidName();
- this.dgvData.dgvUserEmployeeID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
- this.dgvData.dgvFixedHideColumn = "ID";
- this.dgvData.dgvCurrentColumnOriginalSet = GetFieldName();
- pageData.QueryFieldName = this.dgvData.dgvSetColumnName();
- if (string.IsNullOrEmpty(pageData.QueryFieldName))
- { pageData.QueryFieldName = this.dgvData.dgvCurrentColumnOriginalSet; }
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- this.tblMianSelectData = pageData.QueryDataTable().Tables[0];
- });
- try
- {
- this.dgvData.DataSource(this.tblMianSelectData, strHideField: this.dgvData.dgvFixedHideColumn, ColumnAsName: this.GetASName());
- this.dgvData.FillLastColumn(false);
- }
- catch
- { }
- try
- {
- this.ucPager.TbDataSource = this.tblMianSelectData;
- if (StrLoadType == "拨出电话")
- { this.dgvData.Columns["拨出时间"].Width = 110; }
- else
- { this.dgvData.Columns["来电时间"].Width = 110; }
- this.dgvData.ColumnHeaderMouseDoubleClick -= dgvData_ColumnHeaderMouseDoubleClick;
- this.dgvData.ColumnHeaderMouseDoubleClick += dgvData_ColumnHeaderMouseDoubleClick;
- }
- catch { }
- this.dgvData.ClearSelection();
- return pageData.TotalCount;
- }
- /// <summary>
- /// 列表双击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void dgvData_ColumnHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
- {
- }
- /// <summary>
- /// 查询要获取的字段
- /// </summary>
- /// <returns></returns>
- private string GetGuidName()
- {
- CallClientType calltype = (CallClientType)Enum.Parse(typeof(CallClientType), this.cmbtreevClientType.Text.Trim());
- switch (calltype)
- {
- case CallClientType.订单客户: return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0035.ToString().Trim();
- case CallClientType.老客户: return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0036.ToString().Trim();
- case CallClientType.意向客户: return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0037.ToString().Trim();
- case CallClientType.其他客户: return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0038.ToString().Trim();
- case CallClientType.未知来电: return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0039.ToString().Trim();
- case CallClientType.员工电话: return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0040.ToString().Trim();
- default: return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0041.ToString().Trim();
- }
- }
- /// <summary>
- /// 查询要获取的字段
- /// </summary>
- /// <returns></returns>
- private string GetASName()
- {
- string StrColumn = "";
- if (this.StrLoadType == "已接电话")
- { StrColumn = "来电号码, 来电时间,"; }
- else if (this.StrLoadType == "拨出电话")
- { StrColumn = "拨出号码, 拨出时间,"; }
- else if (this.StrLoadType == "未接电话")
- { StrColumn = "来电号码, 来电时间,"; }
- StrColumn += "路径";
- CallClientType calltype = (CallClientType)Enum.Parse(typeof(CallClientType), this.cmbtreevClientType.Text.Trim());
- switch (calltype)
- {
- case CallClientType.订单客户: return "ID, 订单号, 客户姓名, 客户电话," + StrColumn;
- case CallClientType.老客户: return "ID, 客户姓名, 客户性别," + StrColumn;
- case CallClientType.意向客户: return "ID, 客户姓名, 客户性别," + StrColumn;
- case CallClientType.其他客户: return "ID, 客户姓名, 客户性别," + StrColumn;
- case CallClientType.未知来电: return "ID," + StrColumn;
- case CallClientType.员工电话: return "ID, 员工姓名," + StrColumn;
- default: return "ID, 订单号, 客户姓名, 客户电话," + StrColumn;
- }
- }
- /// <summary>
- /// 查询要获取的字段
- /// </summary>
- /// <returns></returns>
- private string GetFieldName()
- {
- CallClientType calltype = (CallClientType)Enum.Parse(typeof(CallClientType), this.cmbtreevClientType.Text.Trim());
- switch (calltype)
- {
- case CallClientType.订单客户: return "ID,GP_OrderNumber,Cus_Name,Cus_Telephone,Callw_Telephone,Callw_DateTime,Callw_SoundRecording";
- case CallClientType.老客户: return "ID,Cus_Name,Cus_Sex_cs,Callw_Telephone,Callw_DateTime,Callw_SoundRecording";
- case CallClientType.意向客户: return "ID,Cus_Name,Cus_Sex_cs,Callw_Telephone,Callw_DateTime,Callw_SoundRecording";
- case CallClientType.其他客户: return "ID,Cus_Name,Cus_Sex_cs,Callw_Telephone,Callw_DateTime,Callw_SoundRecording";
- case CallClientType.未知来电: return "ID,Callw_Telephone,Callw_DateTime,Callw_SoundRecording";
- case CallClientType.员工电话: return "ID,Cus_Name,Callw_Telephone,Callw_DateTime,Callw_SoundRecording";
- default: return "ID,GP_OrderNumber,Cus_Name,Cus_Telephone,Callw_Telephone,Callw_DateTime,Callw_SoundRecording";
- }
- }
- /// <summary>
- /// 返回要操作的条件
- /// </summary>
- /// <returns></returns>
- private string GetWhereStr()
- {
- string StrWhere = " 1=1 ";
- if (!string.IsNullOrEmpty(this.cmbtreevClientType.Text.Trim()))
- {
- CallClientType calltype = (CallClientType)Enum.Parse(typeof(CallClientType), this.cmbtreevClientType.Text.Trim());
- switch (calltype)
- {
- case CallClientType.订单客户: StrWhere += " And GP_GroupType = '0'"; break;
- case CallClientType.老客户: StrWhere += " And GP_GroupType = '1'"; break;
- case CallClientType.意向客户: StrWhere += " And GP_GroupType = '2'"; break;
- case CallClientType.其他客户: break;
- case CallClientType.未知来电: break;
- case CallClientType.员工电话: break;
- default: break;
- }
- }
- StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Callw_DateTime", this.dtpDateStart.DateValue, this.dtpDateEnd.DateValue);
- if (this.txtQuery.Text.Trim() != "")
- { StrWhere += " And (Cus_Name like '%" + this.txtQuery.Text.Trim() + "%' or Callw_Telephone like '%" + this.txtQuery.Text.Trim() + "%')"; }
- StrWhere += " And Callw_Status = '" + this.StrLoadType + "'";
- return StrWhere;
- }
- /// <summary>
- /// 返回要操作的数据表
- /// </summary>
- /// <returns></returns>
- private string GetTableName_Main()
- {
- CallClientType calltype = (CallClientType)Enum.Parse(typeof(CallClientType), this.cmbtreevClientType.Text.Trim());
- switch (calltype)
- {
- case CallClientType.订单客户: return "BView_CallsElves_OrderClientCalls";
- case CallClientType.老客户: return "BView_CallsElves_OrderClientCalls";
- case CallClientType.意向客户: return "BView_CallsElves_OrderClientCalls";
- case CallClientType.其他客户: return "BView_CallsElves_OtherClientCalls";
- case CallClientType.未知来电: return "BView_CallsElves_NotClientCalls";
- case CallClientType.员工电话: return "BView_CallsElves_UserCalls";
- default: return "BView_CallsElves_ClientCalls";
- }
- }
- }
- }
|