FrmCustomerCalls.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using LYFZ.Command;
  10. using LYFZ.ComponentLibrary;
  11. namespace LYFZ.Software.MainBusiness.CallerWizard
  12. {
  13. public partial class FrmCustomerCalls : LYFZ.Software.UI.CallerWizard.FrmCustomerCalls
  14. {
  15. LYFZ.BLL.BLL_ErpCallWizard cwbll = new BLL.BLL_ErpCallWizard();
  16. private delegate void UpdateControl();
  17. public FrmCustomerCalls(string StrType = "")
  18. {
  19. this.StrLoadType = StrType;
  20. this.Shown += FrmCustomerCalls_Shown;
  21. this.btnQuery.Click += btnQuery_Click;
  22. this.btnDelete.Click += btnDelete_Click;
  23. this.btnCall.Click += btnCall_Click;
  24. this.btnPlayer.Click += btnPlayer_Click;
  25. this.btnClose.Click += btnClose_Click;
  26. this.ucPager.EventPaging += UcPagerEx1_EventPaging;
  27. this.txtQuery.KeyDown += txtQuery_KeyDown;
  28. this.cmbtreevClientType.ComboBoxTree_NodeMouseClick += cmbtreevClientType_ComboBoxTree_NodeMouseClick;
  29. this.Resize += FrmCustomerCalls_Resize;
  30. this.dgvData.RowsAdded += dgvData_RowsAdded;
  31. }
  32. string GetPhoneColumn()
  33. {
  34. string strColumnName = "来电电话";
  35. switch (StrLoadType)
  36. {
  37. case "已接电话": strColumnName = "来电号码"; break;
  38. case "拨出电话": strColumnName = "拨出号码"; break;
  39. case "未接电话": strColumnName = "来电号码"; break;
  40. }
  41. return strColumnName;
  42. }
  43. string GetDateTimeColumn()
  44. {
  45. string strColumnName = "来电时间";
  46. switch (StrLoadType)
  47. {
  48. case "已接电话": strColumnName = "来电时间"; break;
  49. case "拨出电话": strColumnName = "拨出时间"; break;
  50. case "未接电话": strColumnName = "来电时间"; break;
  51. }
  52. return strColumnName;
  53. }
  54. enum CallClientType
  55. {
  56. 全部 = -4,
  57. 订单客户 = 0,
  58. 老客户 = 1,
  59. 意向客户 = 2,
  60. 其他客户 = -1,
  61. 未知来电 = -2,
  62. 员工电话 = -3
  63. }
  64. string StrLoadType;
  65. /// <summary>
  66. /// 窗体加载事件
  67. /// </summary>
  68. /// <param name="sender"></param>
  69. /// <param name="e"></param>
  70. void FrmCustomerCalls_Shown(object sender, EventArgs e)
  71. {
  72. this.UcNavigationTool.LabTitle = this.StrLoadType;
  73. this.dtpDateStart.DateValue = SDateTime.Now.ToString("yyyy-MM") + "-01";
  74. this.dtpDateEnd.DateValue = Convert.ToDateTime(this.dtpDateStart.DateValue).AddMonths(1).AddSeconds(-1).ToString("yyyy-MM-dd");
  75. this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CustomerCallsCompetence, CustomAttributes.OperatingAuthority.Delete);
  76. string[] StrArrayName = Enum.GetNames(typeof(CallClientType));
  77. TreeNode root = null;
  78. for (int i = 0; i < StrArrayName.Length; i++)
  79. {
  80. if (i == 0)
  81. {
  82. root = new TreeNode();
  83. root.Text = "全部";
  84. root.Tag = Convert.ToInt32(Enum.Parse(typeof(CallClientType), "全部"));
  85. root.Name = root.Tag.ToString();
  86. this.cmbtreevClientType.Nodes.Add(root);
  87. }
  88. if (StrArrayName[i].Trim() != "全部")
  89. {
  90. root = new TreeNode();
  91. root.Text = StrArrayName[i].Trim();
  92. root.Tag = Convert.ToInt32(Enum.Parse(typeof(CallClientType), StrArrayName[i].Trim()));
  93. root.Name = root.Tag.ToString();
  94. this.cmbtreevClientType.Nodes.Add(root);
  95. }
  96. }
  97. this.cmbtreevClientType.TextFindTag(CallClientType.全部.ToString());
  98. this.PublicFunctionRows();
  99. bool b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(
  100. VersionControl.VersionFunctionEnum.来电精灵);
  101. if (!b)
  102. {
  103. this.Close();
  104. return;
  105. }
  106. }
  107. /// <summary>
  108. /// 查询
  109. /// </summary>
  110. /// <param name="sender"></param>
  111. /// <param name="e"></param>
  112. void btnQuery_Click(object sender, EventArgs e)
  113. {
  114. this.PublicFunctionRows();
  115. }
  116. /// <summary>
  117. /// 回车查询
  118. /// </summary>
  119. /// <param name="sender"></param>
  120. /// <param name="e"></param>
  121. void txtQuery_KeyDown(object sender, KeyEventArgs e)
  122. {
  123. if (e.KeyCode == Keys.Enter)
  124. { this.PublicFunctionRows(); }
  125. }
  126. /// <summary>
  127. /// 客户类型选择
  128. /// </summary>
  129. /// <param name="sender"></param>
  130. /// <param name="e"></param>
  131. void cmbtreevClientType_ComboBoxTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  132. {
  133. this.PublicFunctionRows();
  134. }
  135. /// <summary>
  136. /// 删除
  137. /// </summary>
  138. /// <param name="sender"></param>
  139. /// <param name="e"></param>
  140. void btnDelete_Click(object sender, EventArgs e)
  141. {
  142. if (this.dgvData.Rows.Count > 0)
  143. {
  144. if (MessageBoxCustom.Show("您确定删除吗?", "温馨提示!", MessageBoxButtons.YesNo) == DialogResult.No)
  145. { return; }
  146. int deleteCount = 0;
  147. if (this.dgvData.SelectedRows.Count > 0)
  148. {
  149. for (int i = 0; i < this.dgvData.SelectedRows.Count; i++)
  150. {
  151. if (!string.IsNullOrEmpty(this.dgvData.SelectedRows[i].Cells["ID"].Value.ToString().Trim()))
  152. {
  153. if (cwbll.Delete(Convert.ToInt32(this.dgvData.SelectedRows[i].Cells["ID"].Value)))
  154. {
  155. deleteCount++;
  156. string StrPath = this.dgvData.SelectedRows[i].Cells["路径"].Value.ToString().Trim();
  157. if (!string.IsNullOrEmpty(StrPath))
  158. {
  159. string StrNewPath = StrPath.Substring(StrPath.IndexOf("ShareDirectory"), StrPath.Length - StrPath.IndexOf("ShareDirectory"));
  160. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  161. {
  162. backgroundWorker.ReportProgress(0, "正在连接服务器...");
  163. try
  164. {
  165. string ret = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.TcpClient.DeleteFile(StrNewPath, backgroundWorker);
  166. if (ret.IndexOf("成功") == -1)
  167. { MessageBoxCustom.Show(ret, backgroundWorker: backgroundWorker); }
  168. }
  169. catch (Exception ex)
  170. { MessageBoxCustom.Show(ex.Message, backgroundWorker: backgroundWorker); }
  171. });
  172. }
  173. string logsContent = "删除客户来电电话号码:" + this.dgvData.SelectedRows[i].Cells[GetPhoneColumn()].Value.ToString();
  174. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除电话记录, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  175. }
  176. }
  177. }
  178. }
  179. if (deleteCount > 0)
  180. {
  181. MessageBoxCustom.Show("删除成功!");
  182. this.PublicFunctionRows();
  183. }
  184. }
  185. }
  186. /// <summary>
  187. /// 呼叫
  188. /// </summary>
  189. /// <param name="sender"></param>
  190. /// <param name="e"></param>
  191. void btnCall_Click(object sender, EventArgs e)
  192. {
  193. if (this.dgvData.Rows.Count > 0)
  194. {
  195. if (this.dgvData.CurrentRow == null)
  196. { MessageBoxCustom.Show("请选中你要录音回放的数据!"); return; }
  197. if (this.dgvData.CurrentRow.Index >= 0 && this.dgvData.CurrentCell.RowIndex >= 0)
  198. {
  199. if (!string.IsNullOrEmpty(this.dgvData.CurrentRow.Cells[GetPhoneColumn()].Value.ToString().Trim()))
  200. {
  201. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.PhoneCall(this.dgvData.CurrentRow.Cells[GetPhoneColumn()].Value.ToString().Trim());
  202. }
  203. else
  204. { MessageBoxCustom.Show("选择的通话记录电话号码为空!"); }
  205. }
  206. }
  207. }
  208. /// <summary>
  209. /// 录音回放
  210. /// </summary>
  211. /// <param name="sender"></param>
  212. /// <param name="e"></param>
  213. void btnPlayer_Click(object sender, EventArgs e)
  214. {
  215. if (this.dgvData.Rows.Count > 0)
  216. {
  217. if (this.dgvData.CurrentRow == null)
  218. { MessageBoxCustom.Show("请选中你要录音回放的数据!"); return; }
  219. if (this.dgvData.CurrentRow.Index >= 0 && this.dgvData.CurrentCell.RowIndex >= 0)
  220. {
  221. string StrPath = this.dgvData.CurrentRow.Cells["路径"].Value.ToString().Trim();
  222. if (!string.IsNullOrEmpty(StrPath))
  223. {
  224. string StrNewPath = StrPath.Substring(StrPath.IndexOf("ShareDirectory"), StrPath.Length - StrPath.IndexOf("ShareDirectory"));
  225. LYFZ.Model.Model_Config mConfig = new LYFZ.BLL.BLL_Config().GetModel_SysConfig();
  226. //播放
  227. FrmPlayer set = new FrmPlayer();
  228. set.Path = "\\\\" + mConfig.ServerHostOrIP + "\\" + StrNewPath;
  229. set.ShowDialog();
  230. }
  231. else
  232. { MessageBoxCustom.Show("选择的通话记录未录音!"); }
  233. }
  234. }
  235. }
  236. /// <summary>
  237. /// 关闭
  238. /// </summary>
  239. /// <param name="sender"></param>
  240. /// <param name="e"></param>
  241. void btnClose_Click(object sender, EventArgs e)
  242. {
  243. this.Close();
  244. }
  245. /// <summary>
  246. /// 窗体大小发生变化
  247. /// </summary>
  248. /// <param name="sender"></param>
  249. /// <param name="e"></param>
  250. void FrmCustomerCalls_Resize(object sender, EventArgs e)
  251. {
  252. int ControlsWidth = 0;
  253. for (int i = 0; i < this.flowLayoutPanel1.Controls.Count; i++)
  254. {
  255. if (this.flowLayoutPanel1.Controls[i].Visible)
  256. { ControlsWidth += this.flowLayoutPanel1.Controls[i].Width; }
  257. }
  258. int PanlHeightCount = 1;
  259. if (this.flowLayoutPanel1.Width < ControlsWidth)
  260. {
  261. PanlHeightCount = ControlsWidth / this.flowLayoutPanel1.Width;
  262. if ((ControlsWidth / this.flowLayoutPanel1.Width) > 0)
  263. { PanlHeightCount++; }
  264. }
  265. this.flowLayoutPanel1.Height = 33 * PanlHeightCount;
  266. //this.panelEx2.Height = this.flowLayoutPanel1.Height + 71;
  267. }
  268. /// <summary>
  269. /// 列表添加行时发生
  270. /// </summary>
  271. /// <param name="sender"></param>
  272. /// <param name="e"></param>
  273. void dgvData_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
  274. {
  275. /*if (!string.IsNullOrEmpty(this.dgvData.Rows[e.RowIndex].Cells[this.GetDateTimeColumn()].Value.ToString().Trim()))
  276. {
  277. 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");
  278. }*/
  279. }
  280. /// <summary>
  281. /// 分页前数据,便于展开时用来查询订单的子数据
  282. /// </summary>
  283. DataTable tblMianSelectData = new DataTable();
  284. /// <summary>
  285. /// 创建行
  286. /// </summary>
  287. private void PublicFunctionRows()
  288. {
  289. this.ucPager.EventPaging -= UcPagerEx1_EventPaging;
  290. this.ucPager.EventPaging += UcPagerEx1_EventPaging;
  291. this.ucPager.PageCurrent = 1;
  292. this.ucPager.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
  293. this.ucPager.Bind();
  294. }
  295. /// <summary>
  296. /// 画分页
  297. /// </summary>
  298. /// <param name="e"></param>
  299. /// <returns></returns>
  300. int UcPagerEx1_EventPaging(UCPager.EventPagingArg e)
  301. {
  302. LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
  303. pageData.TableName = GetTableName_Main();
  304. pageData.PageIndex = this.ucPager.PageCurrent;
  305. pageData.PageSize = this.ucPager.PageSize;
  306. pageData.QueryCondition = GetWhereStr();
  307. pageData.OrderStr = "Callw_DateTime DESC";
  308. pageData.OrderType = 1;
  309. this.dgvData.dgvGuidName = GetGuidName();
  310. this.dgvData.dgvUserEmployeeID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
  311. this.dgvData.dgvFixedHideColumn = "ID";
  312. this.dgvData.dgvCurrentColumnOriginalSet = GetFieldName();
  313. pageData.QueryFieldName = this.dgvData.dgvSetColumnName();
  314. if (string.IsNullOrEmpty(pageData.QueryFieldName))
  315. { pageData.QueryFieldName = this.dgvData.dgvCurrentColumnOriginalSet; }
  316. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  317. {
  318. this.tblMianSelectData = pageData.QueryDataTable().Tables[0];
  319. });
  320. try
  321. {
  322. this.dgvData.DataSource(this.tblMianSelectData, strHideField: this.dgvData.dgvFixedHideColumn, ColumnAsName: this.GetASName());
  323. this.dgvData.FillLastColumn(false);
  324. }
  325. catch
  326. { }
  327. try
  328. {
  329. this.ucPager.TbDataSource = this.tblMianSelectData;
  330. if (StrLoadType == "拨出电话")
  331. { this.dgvData.Columns["拨出时间"].Width = 110; }
  332. else
  333. { this.dgvData.Columns["来电时间"].Width = 110; }
  334. this.dgvData.ColumnHeaderMouseDoubleClick -= dgvData_ColumnHeaderMouseDoubleClick;
  335. this.dgvData.ColumnHeaderMouseDoubleClick += dgvData_ColumnHeaderMouseDoubleClick;
  336. }
  337. catch { }
  338. this.dgvData.ClearSelection();
  339. return pageData.TotalCount;
  340. }
  341. /// <summary>
  342. /// 列表双击事件
  343. /// </summary>
  344. /// <param name="sender"></param>
  345. /// <param name="e"></param>
  346. void dgvData_ColumnHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  347. {
  348. }
  349. /// <summary>
  350. /// 查询要获取的字段
  351. /// </summary>
  352. /// <returns></returns>
  353. private string GetGuidName()
  354. {
  355. CallClientType calltype = (CallClientType)Enum.Parse(typeof(CallClientType), this.cmbtreevClientType.Text.Trim());
  356. switch (calltype)
  357. {
  358. case CallClientType.订单客户: return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0035.ToString().Trim();
  359. case CallClientType.老客户: return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0036.ToString().Trim();
  360. case CallClientType.意向客户: return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0037.ToString().Trim();
  361. case CallClientType.其他客户: return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0038.ToString().Trim();
  362. case CallClientType.未知来电: return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0039.ToString().Trim();
  363. case CallClientType.员工电话: return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0040.ToString().Trim();
  364. default: return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0041.ToString().Trim();
  365. }
  366. }
  367. /// <summary>
  368. /// 查询要获取的字段
  369. /// </summary>
  370. /// <returns></returns>
  371. private string GetASName()
  372. {
  373. string StrColumn = "";
  374. if (this.StrLoadType == "已接电话")
  375. { StrColumn = "来电号码, 来电时间,"; }
  376. else if (this.StrLoadType == "拨出电话")
  377. { StrColumn = "拨出号码, 拨出时间,"; }
  378. else if (this.StrLoadType == "未接电话")
  379. { StrColumn = "来电号码, 来电时间,"; }
  380. StrColumn += "路径";
  381. CallClientType calltype = (CallClientType)Enum.Parse(typeof(CallClientType), this.cmbtreevClientType.Text.Trim());
  382. switch (calltype)
  383. {
  384. case CallClientType.订单客户: return "ID, 订单号, 客户姓名, 客户电话," + StrColumn;
  385. case CallClientType.老客户: return "ID, 客户姓名, 客户性别," + StrColumn;
  386. case CallClientType.意向客户: return "ID, 客户姓名, 客户性别," + StrColumn;
  387. case CallClientType.其他客户: return "ID, 客户姓名, 客户性别," + StrColumn;
  388. case CallClientType.未知来电: return "ID," + StrColumn;
  389. case CallClientType.员工电话: return "ID, 员工姓名," + StrColumn;
  390. default: return "ID, 订单号, 客户姓名, 客户电话," + StrColumn;
  391. }
  392. }
  393. /// <summary>
  394. /// 查询要获取的字段
  395. /// </summary>
  396. /// <returns></returns>
  397. private string GetFieldName()
  398. {
  399. CallClientType calltype = (CallClientType)Enum.Parse(typeof(CallClientType), this.cmbtreevClientType.Text.Trim());
  400. switch (calltype)
  401. {
  402. case CallClientType.订单客户: return "ID,GP_OrderNumber,Cus_Name,Cus_Telephone,Callw_Telephone,Callw_DateTime,Callw_SoundRecording";
  403. case CallClientType.老客户: return "ID,Cus_Name,Cus_Sex_cs,Callw_Telephone,Callw_DateTime,Callw_SoundRecording";
  404. case CallClientType.意向客户: return "ID,Cus_Name,Cus_Sex_cs,Callw_Telephone,Callw_DateTime,Callw_SoundRecording";
  405. case CallClientType.其他客户: return "ID,Cus_Name,Cus_Sex_cs,Callw_Telephone,Callw_DateTime,Callw_SoundRecording";
  406. case CallClientType.未知来电: return "ID,Callw_Telephone,Callw_DateTime,Callw_SoundRecording";
  407. case CallClientType.员工电话: return "ID,Cus_Name,Callw_Telephone,Callw_DateTime,Callw_SoundRecording";
  408. default: return "ID,GP_OrderNumber,Cus_Name,Cus_Telephone,Callw_Telephone,Callw_DateTime,Callw_SoundRecording";
  409. }
  410. }
  411. /// <summary>
  412. /// 返回要操作的条件
  413. /// </summary>
  414. /// <returns></returns>
  415. private string GetWhereStr()
  416. {
  417. string StrWhere = " 1=1 ";
  418. if (!string.IsNullOrEmpty(this.cmbtreevClientType.Text.Trim()))
  419. {
  420. CallClientType calltype = (CallClientType)Enum.Parse(typeof(CallClientType), this.cmbtreevClientType.Text.Trim());
  421. switch (calltype)
  422. {
  423. case CallClientType.订单客户: StrWhere += " And GP_GroupType = '0'"; break;
  424. case CallClientType.老客户: StrWhere += " And GP_GroupType = '1'"; break;
  425. case CallClientType.意向客户: StrWhere += " And GP_GroupType = '2'"; break;
  426. case CallClientType.其他客户: break;
  427. case CallClientType.未知来电: break;
  428. case CallClientType.员工电话: break;
  429. default: break;
  430. }
  431. }
  432. StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Callw_DateTime", this.dtpDateStart.DateValue, this.dtpDateEnd.DateValue);
  433. if (this.txtQuery.Text.Trim() != "")
  434. { StrWhere += " And (Cus_Name like '%" + this.txtQuery.Text.Trim() + "%' or Callw_Telephone like '%" + this.txtQuery.Text.Trim() + "%')"; }
  435. StrWhere += " And Callw_Status = '" + this.StrLoadType + "'";
  436. return StrWhere;
  437. }
  438. /// <summary>
  439. /// 返回要操作的数据表
  440. /// </summary>
  441. /// <returns></returns>
  442. private string GetTableName_Main()
  443. {
  444. CallClientType calltype = (CallClientType)Enum.Parse(typeof(CallClientType), this.cmbtreevClientType.Text.Trim());
  445. switch (calltype)
  446. {
  447. case CallClientType.订单客户: return "BView_CallsElves_OrderClientCalls";
  448. case CallClientType.老客户: return "BView_CallsElves_OrderClientCalls";
  449. case CallClientType.意向客户: return "BView_CallsElves_OrderClientCalls";
  450. case CallClientType.其他客户: return "BView_CallsElves_OtherClientCalls";
  451. case CallClientType.未知来电: return "BView_CallsElves_NotClientCalls";
  452. case CallClientType.员工电话: return "BView_CallsElves_UserCalls";
  453. default: return "BView_CallsElves_ClientCalls";
  454. }
  455. }
  456. }
  457. }