using LYFZ.ComponentLibrary;
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.CallerWizard
{
public partial class FrmOutgoingCalls : LYFZ.Software.UI.CallerWizard.FrmOutgoingCalls
{
LYFZ.BLL.BLL_ErpCallWizard cwbll = new BLL.BLL_ErpCallWizard();
private delegate void UpdateControl();
public FrmOutgoingCalls()
{
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.tabControlEx1.SelectedIndexChanged += tabControlEx1_SelectedIndexChanged;
this.ucPager_ClientOrder.EventPaging += UcPagerEx1_EventPaging;
}
///
/// 窗体加载事件
///
///
///
void FrmCustomerCalls_Shown(object sender, EventArgs e)
{
this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CustomerCallsCompetence, CustomAttributes.OperatingAuthority.Delete);
this.PublicFunctionRows();
}
///
/// 查询
///
///
///
void btnQuery_Click(object sender, EventArgs e)
{
this.PublicFunctionRows();
}
///
/// 删除
///
///
///
void btnDelete_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["ID"].Value.ToString().Trim()))
{
if (MessageBoxCustom.Show("您确定删除吗?", "温馨提示!", MessageBoxButtons.YesNo) == DialogResult.No)
{ return; }
if (cwbll.Delete(Convert.ToInt32(this.dgvData.CurrentRow.Cells["ID"].Value)))
{
string logsContent = "删除客户来电电话号码:" + this.dgvData.CurrentRow.Cells["电话"].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);
MessageBoxCustom.Show("删除成功!"); this.dgvData.Rows.Remove(this.dgvData.CurrentRow);
}
else
{ MessageBoxCustom.Show("删除失败!"); }
}
}
}
}
///
/// 呼叫
///
///
///
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["电话"].Value.ToString().Trim()))
{
LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.PhoneCall(this.dgvData.CurrentRow.Cells["电话"].Value.ToString().Trim());
}
else
{ MessageBoxCustom.Show("选择的通话记录电话号码为空!"); }
}
}
}
///
/// 录音回放
///
///
///
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)
{
if (!string.IsNullOrEmpty(this.dgvData.CurrentRow.Cells["路径"].Value.ToString().Trim()))
{
//播放
FrmPlayer set = new FrmPlayer();
set.Path = this.dgvData.CurrentRow.Cells["路径"].Value.ToString().Trim();
set.ShowDialog();
}
else
{ MessageBoxCustom.Show("选择的通话记录未录音!"); }
}
}
}
///
/// 关闭
///
///
///
void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 选项卡选择事件
///
///
///
void tabControlEx1_SelectedIndexChanged(object sender, EventArgs e)
{
this.PublicFunctionRows();
}
///
/// 分页前数据,便于展开时用来查询订单的子数据
///
DataTable tblMianSelectData = new DataTable();
///
/// 创建行
///
private void PublicFunctionRows()
{
this.UcPagerEx1.EventPaging -= UcPagerEx1_EventPaging;
this.UcPagerEx1.EventPaging += UcPagerEx1_EventPaging;
this.UcPagerEx1.PageCurrent = 1;
this.UcPagerEx1.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
this.UcPagerEx1.Bind();
}
///
/// 画分页
///
///
///
int UcPagerEx1_EventPaging(UCPager.EventPagingArg e)
{
LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
pageData.TableName = GetTableName_Main();
pageData.PageIndex = this.UcPagerEx1.PageCurrent;
pageData.PageSize = this.UcPagerEx1.PageSize;
pageData.QueryCondition = GetWhereStr();
pageData.OrderStr = "时间";
pageData.OrderType = 1;
string StrTabName = this.tabControlEx1.SelectedTab.Name.Trim();
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.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
{
this.dgvData.DataSource(this.tblMianSelectData);
this.dgvData.FillLastColumn(true);
}));
}
catch
{ }
});
try
{
this.UcPagerEx1.TbDataSource = this.tblMianSelectData;
this.dgvData.Columns["时间"].Width = 110;
this.dgvData.ColumnHeaderMouseDoubleClick -= dgvData_ColumnHeaderMouseDoubleClick;
this.dgvData.ColumnHeaderMouseDoubleClick += dgvData_ColumnHeaderMouseDoubleClick;
}
catch { }
this.dgvData.ClearSelection();
return pageData.TotalCount;
}
///
/// 列表双击事件
///
///
///
void dgvData_ColumnHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
}
///
/// 查询要获取的字段
///
///
private string GetGuidName()
{
switch (this.tabControlEx1.SelectedTab.Name.Trim())
{
case "tabPage_ClientOrder":
return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0035.ToString().Trim();
case "tabPage_ClientOld":
return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0036.ToString().Trim();
case "tabPage_ClientIntent":
return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0037.ToString().Trim();
case "tabPage_ClientOther":
return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0038.ToString().Trim();
case "tabPage_ClientUser":
return LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0039.ToString().Trim();
default: return "";
}
}
///
/// 查询要获取的字段
///
///
private string GetFieldName()
{
switch (this.tabControlEx1.SelectedTab.Name.Trim())
{
case "tabPage_ClientOrder":
return "";
case "tabPage_ClientOld":
return "";
case "tabPage_ClientIntent":
return "";
case "tabPage_ClientOther":
return "";
case "tabPage_ClientUser":
return "ID,姓名,电话,时间,路径";
default: return "";
}
}
///
/// 返回要操作的条件
///
///
private string GetWhereStr()
{
string StrWhere = " 1=1 ";
switch (this.tabControlEx1.SelectedTab.Name.Trim())
{
case "tabPage_ClientOrder":
StrWhere += "";
break;
case "tabPage_ClientOld":
StrWhere += "";
break;
case "tabPage_ClientIntent":
StrWhere += "";
break;
case "tabPage_ClientOther":
StrWhere += "";
break;
case "tabPage_ClientUser":
StrWhere += " And 状态 = '拨出电话'";
if (this.txtQuery.Text.Trim() != "")
{ StrWhere += " And (姓名 like '%" + this.txtQuery.Text.Trim() + "%' or 电话 like '%" + this.txtQuery.Text.Trim() + "%')"; }
break;
}
return StrWhere;
}
///
/// 返回要操作的数据表
///
///
private string GetTableName_Main()
{
switch (this.tabControlEx1.SelectedTab.Name.Trim())
{
case "tabPage_ClientOrder":
return "";
case "tabPage_ClientOld":
return "";
case "tabPage_ClientIntent":
return "";
case "tabPage_ClientOther":
return "";
case "tabPage_ClientUser":
return "BView_CallsElves_UserCalls";
default: return "";
}
}
///
/// 定义列表属性
///
public LYFZ.ComponentLibrary.DataGridViewEc dgvData
{
get
{
switch (this.tabControlEx1.SelectedTab.Name.Trim())
{
case "tabPage_ClientOrder":
return this.dgvData_ClientOrder;
case "tabPage_ClientOld":
return this.dgvData_ClientOld;
case "tabPage_ClientIntent":
return this.dgvData_ClientIntent;
case "tabPage_ClientOther":
return this.dgvData_ClientOther;
case "tabPage_ClientUser":
return this.dgvData_ClientUser;
default: return this.dgvData_ClientOrder;
}
}
set
{
switch (this.tabControlEx1.SelectedTab.Name.Trim())
{
case "tabPage_ClientOrder":
this.dgvData_ClientOrder = value;
break;
case "tabPage_ClientOld":
this.dgvData_ClientOld = value;
break;
case "tabPage_ClientIntent":
this.dgvData_ClientIntent = value;
break;
case "tabPage_ClientOther":
this.dgvData_ClientOther = value;
break;
case "tabPage_ClientUser":
this.dgvData_ClientUser = value;
break;
}
}
}
///
/// 定义分页控件属性
///
public LYFZ.UCPager.ucPagerEx UcPagerEx1
{
get
{
switch (this.tabControlEx1.SelectedTab.Name.Trim())
{
case "tabPage_ClientOrder":
return this.ucPager_ClientOrder;
case "tabPage_ClientOld":
return this.ucPager_ClientOld;
case "tabPage_ClientIntent":
return this.ucPager_ClientIntent;
case "tabPage_ClientOther":
return this.ucPager_ClientOther;
case "tabPage_ClientUser":
return this.ucPager_ClientUser;
default: return this.ucPager_ClientOrder;
}
}
set
{
switch (this.tabControlEx1.SelectedTab.Name.Trim())
{
case "tabPage_ClientOrder":
this.ucPager_ClientOrder = value;
break;
case "tabPage_ClientOld":
this.ucPager_ClientOld = value;
break;
case "tabPage_ClientIntent":
this.ucPager_ClientIntent = value;
break;
case "tabPage_ClientOther":
this.ucPager_ClientOther = value;
break;
case "tabPage_ClientUser":
this.ucPager_ClientUser = value;
break;
}
}
}
//string type;
//#region 加载数据
//protected override void FrmOutgoingCalls_Shown(object sender, EventArgs e)
//{
// try
// {
// type = "5";
// GvDataBind();
// #region 权限设置
// #region 删除拨出电话
// if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.OutgoingCallsCompetence, CustomAttributes.OperatingAuthority.Delete))
// {
// btnDelete.Enabled = true;
// }
// else
// {
// btnDelete.Enabled = false;
// }
// #endregion
// #endregion
// }
// catch (Exception ex)
// {
// MessageBoxCustom.Show(ex.Message);
// }
//}
//#endregion
//#region 获取客户来电
//protected override void btnCustomerCalls_Click(object sender, EventArgs e)
//{
// try
// {
// type = "1";
// GvDataBind();
// }
// catch (Exception ex)
// {
// MessageBoxCustom.Show(ex.Message);
// }
//}
//#endregion
//#region 获取老客户来电
//protected override void btnOldCustomers_Click(object sender, EventArgs e)
//{
// try
// {
// type = "2";
// GvDataBind();
// }
// catch (Exception ex)
// {
// MessageBoxCustom.Show(ex.Message);
// }
//}
//#region 获取老客户来电
//public void bindOldCustomers()
//{
// dgv.Rows.Clear();
// dgv.Columns["Cus_Name"].Visible = true;
// dgv.Columns["Sex"].Visible = true;
// LYFZ.BLL.BLL_ErpCallWizard cabll = new BLL.BLL_ErpCallWizard();
// LYFZ.BLL.BLL_ErpCustomer cubll = new BLL.BLL_ErpCustomer();
// DataTable dt = new DataTable();
// string keyword = txtQuery.Text;
// #region 获取来电精灵号码
// if (!string.IsNullOrEmpty(keyword))
// {
// dt = cabll.GetView_tb_ErpCallWizard("(Callw_Status='拨出电话' and Cus_Type='老客户') and (Cus_Name like '%" + keyword + "%' or dbo.tb_Product(Cus_Name) like '%" + keyword + "%' or Cus_Telephone like '%" + keyword + "%') order by tb_ErpCallWizard.Id desc").Tables[0];
// }
// else { dt = cabll.GetView_tb_ErpCallWizard("Callw_Status='拨出电话' and Cus_Type='老客户' order by tb_ErpCallWizard.Id desc").Tables[0]; }
// for (int i = 0; i < dt.Rows.Count; i++)
// {
// DataGridViewRow dgvr = new DataGridViewRow();
// DataGridViewCell cell = null;
// cell = new DataGridViewTextBoxCell();
// cell.Value = dt.Rows[i]["ID"].ToString().Trim(); ;
// dgvr.Cells.Add(cell);
// cell = new DataGridViewTextBoxCell();
// cell.Value = dt.Rows[i]["Cus_Name"].ToString().Trim();
// dgvr.Cells.Add(cell);
// cell = new DataGridViewTextBoxCell();
// if (Convert.ToBoolean(dt.Rows[i]["Cus_Sex"].ToString().Trim()) == false)
// {
// cell.Value = "男";
// }
// else { cell.Value = "女"; }
// dgvr.Cells.Add(cell);
// cell = new DataGridViewTextBoxCell();
// cell.Value = dt.Rows[i]["Callw_Telephone"].ToString(); ;
// dgvr.Cells.Add(cell);
// cell = new DataGridViewTextBoxCell();
// cell.Value = dt.Rows[i]["Callw_DateTime"].ToString(); ;
// dgvr.Cells.Add(cell);
// this.dgv.Rows.Add(dgvr);
// }
// #endregion
//}
//#endregion
//#endregion
//#region 获取意向客户
//protected override void btnIntentionOfCustomers_Click(object sender, EventArgs e)
//{
// try
// {
// type = "3";
// GvDataBind();
// }
// catch (Exception ex)
// {
// MessageBoxCustom.Show(ex.Message);
// }
//}
//#endregion
//#region 获取员工电话
//protected override void btnStaffPhone_Click(object sender, EventArgs e)
//{
//}
//#endregion
//#region 获取其它电话
//protected override void btnOtherPhone_Click(object sender, EventArgs e)
//{
// try
// {
// type = "4";
// GvDataBind();
// }
// catch (Exception ex)
// {
// MessageBoxCustom.Show(ex.Message);
// }
//}
//#endregion
//#region 删除
//protected override void btndelete_Click(object sender, EventArgs e)
//{
// try
// {
// if (this.dgv.SelectedRows.Count == 0)
// {
// MessageBoxCustom.Show("请选中你要删除的数据!");
// return;
// }
// if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
// {
// LYFZ.BLL.BLL_ErpCallWizard bll = new BLL.BLL_ErpCallWizard();
// int id = Convert.ToInt32(this.dgv.CurrentRow.Cells["ID"].Value);
// if (bll.Delete(id) == true)
// {
// #region 写入操作日志
// string logsContent = "删除拨出电话号码:" + dgv.CurrentRow.Cells["Callw_Telephone"].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);
// //LYFZ.BLL.BLL_ErpSystemLogs systemLogsBll = new BLL.BLL_ErpSystemLogs();
// //LYFZ.Model.Model_ErpSystemLogs systemLogsModel = new Model.Model_ErpSystemLogs();
// //systemLogsModel.Slogs_Type = "user";
// //systemLogsModel.Slogs_Topic = "删除拨出电话";
// //systemLogsModel.Slogs_Content = "删除拨出电话号码:" + dgv.CurrentRow.Cells["Callw_Telephone"].Value.ToString();
// //systemLogsModel.Slogs_UserName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name;
// //systemLogsModel.Slogs_IP = "";
// //systemLogsModel.Slogs_CreateDatetime = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetServerDateTime();
// //systemLogsModel.Slogs_CreateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
// //systemLogsBll.Add(systemLogsModel);
// #endregion
// MessageBoxCustom.Show("删除成功!");
// GvDataBind();
// }
// else { MessageBoxCustom.Show("删除失败!"); }
// }
// }
// catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
//}
//#endregion
//#region 关闭
//protected override void btnClose_Click(object sender, EventArgs e)
//{
// this.Close();
//}
//#endregion
//#region 录音回放
//protected override void btnRecordingPlayback_Click(object sender, EventArgs e)
//{
// try
// {
// if (this.dgv.SelectedRows.Count == 0)
// {
// MessageBoxCustom.Show("请选中你要录音回放的数据!");
// return;
// }
// LYFZ.BLL.BLL_ErpCallWizard bll = new BLL.BLL_ErpCallWizard();
// int id = Convert.ToInt32(this.dgv.CurrentRow.Cells["ID"].Value);
// DataTable dt = bll.GetList("ID=" + id + "").Tables[0];
// if (dt.Rows.Count > 0)
// {
// string Callw_SoundRecording = dt.Rows[0]["Callw_SoundRecording"].ToString();
// if (!string.IsNullOrEmpty(Callw_SoundRecording))
// {
// //播放
// FrmPlayer set = new FrmPlayer();
// set.Path = Callw_SoundRecording;
// set.ShowDialog();
// }
// else { MessageBoxCustom.Show("文件未找到!"); }
// }
// }
// catch (Exception ex) { MessageBoxCustom.Show(ex.Message); }
//}
//#endregion
}
}