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 FrmMissedCall : LYFZ.Software.UI.CallerWizard.FrmMissedCall
{
LYFZ.BLL.BLL_ErpCallWizard cwbll = new BLL.BLL_ErpCallWizard();
private delegate void UpdateControl();
public FrmMissedCall()
{
this.Shown += FrmMissedCall_Shown;
this.btnQuery.Click += btnQuery_Click;
this.btnDelete.Click += btnDelete_Click;
this.btnClose.Click += btnClose_Click;
this.UcPagerEx1.EventPaging += UcPagerEx1_EventPaging;
}
string strUsrID = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
///
/// 加载数据
///
///
///
void FrmMissedCall_Shown(object sender, EventArgs e)
{
this.PublicFunctionRows();
}
///
/// 查询
///
///
///
void btnQuery_Click(object sender, EventArgs e)
{
this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.CustomerCallsCompetence, CustomAttributes.OperatingAuthority.Delete);
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 btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 分页前数据,便于展开时用来查询订单的子数据
///
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 = "";
pageData.PageIndex = this.UcPagerEx1.PageCurrent;
pageData.PageSize = this.UcPagerEx1.PageSize;
pageData.QueryCondition = GetWhereStr();
pageData.OrderStr = "";
pageData.OrderType = 1;
this.dgvData.dgvGuidName = LYFZ.EnumPublic.dgvGuidName.E_FormAll_A0002.ToString().Trim();
this.dgvData.dgvUserEmployeeID = strUsrID;
this.dgvData.dgvFixedHideColumn = "";
this.dgvData.dgvCurrentColumnOriginalSet = "";
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.QueryOrderDataTable().Tables[0];
try
{
this.Invoke(new LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.UpdateControl(delegate()
{
this.dgvData.DataSourceMain(this.tblMianSelectData);
this.dgvData.FillLastColumn(true);
}));
}
catch
{ }
});
try
{
this.UcPagerEx1.TbDataSource = this.tblMianSelectData;
this.dgvData.Columns["电话时间"].Width = 110;
}
catch { }
this.dgvData.ClearSelection();
return pageData.TotalCount;
}
///
/// 返回要操作的条件
///
///
private string GetWhereStr()
{
string StrWhere = " 1=1 ";
string StrText = txtQuery.Text.Trim();
return StrWhere;
}
//public void bindCustomerCalls()
//{
// dgv.Rows.Clear();
// LYFZ.BLL.BLL_ErpCallWizard cabll = new BLL.BLL_ErpCallWizard();
// LYFZ.BLL.BLL_ErpCustomer cubll = new BLL.BLL_ErpCustomer();
// DataTable dt = new DataTable();
// string keyword = txtkeyword.Text;
// #region 获取来电精灵号码
// if (!string.IsNullOrEmpty(keyword))
// {
// dt = cabll.GetList("(Callw_Status='未接电话' and Callw_Telephone like '%" + keyword + "%')").Tables[0];
// }
// else { dt = cabll.GetList("Callw_Status='未接电话'").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 = "";
// 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);
// cell = new DataGridViewTextBoxCell();
// cell.Value = "";
// dgvr.Cells.Add(cell);
// this.dgv.Rows.Add(dgvr);
// dgv.ClearSelection();
// }
// #endregion
// if (dgv.Rows.Count > 0)
// {
// for (int t = 0; t < dgv.Rows.Count; t++)
// {
// string Callw_Telephone = dgv.Rows[t].Cells["Callw_Telephone"].Value.ToString();
// #region 获取客户姓名和员工姓名和状态
// DataTable dtcu = cabll.GetView_tb_ErpCallWizard("tb_ErpCallWizard.Callw_Telephone='" + Callw_Telephone + "' order by tb_ErpCallWizard.Id desc").Tables[0];
// if (dtcu.Rows.Count > 0)
// {
// dgv.Rows[t].Cells["Cus_Name"].Value = dtcu.Rows[0]["Cus_Name"].ToString();
// dgv.Rows[t].Cells["Type"].Value = dtcu.Rows[0]["Cus_Type"].ToString() + "来电";
// }
// DataTable dtus = cabll.GetView_tb_ErpCallWizard_tb_ErpUser("tb_ErpCallWizard.Callw_Telephone='" + Callw_Telephone + "' order by tb_ErpCallWizard.Id desc").Tables[0];
// if (dtus.Rows.Count > 0)
// {
// dgv.Rows[t].Cells["Cus_Name"].Value = dtus.Rows[0]["User_Name"].ToString();
// dgv.Rows[t].Cells["Type"].Value = "员工来电";
// }
// if (string.IsNullOrEmpty(dgv.Rows[t].Cells["Cus_Name"].Value.ToString()) && string.IsNullOrEmpty(dgv.Rows[t].Cells["Type"].Value.ToString()))
// {
// dgv.Rows[t].Cells["Cus_Name"].Value = "";
// dgv.Rows[t].Cells["Type"].Value = "未知电话来电";
// }
// #endregion
// }
// }
//}
//public void GvDataBind()
//{
// this.ucPagerEx1.PageCurrent = 1;
// this.ucPagerEx1.PageSize = 100;
// this.ucPagerEx1.Bind();
//}
/////
///// 画分页
/////
/////
/////
//private int ucPagerEx1_EventPaging(UCPager.EventPagingArg e)
//{
// LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
// dgv.Rows.Clear();
// DataTable dt = new DataTable();
// StringBuilder sql = new StringBuilder();
// if (!string.IsNullOrEmpty(txtkeyword.Text))
// {
// sql.Append(" 1=1 and (Callw_Status='未接电话' and Callw_Telephone like '%" + txtkeyword.Text + "%')");
// }
// else
// {
// sql.Append(" 1=1 and Callw_Status='未接电话'");
// }
// LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
// {
// pageData.TableName = "View_CallWizard";
// pageData.PageIndex = this.ucPagerEx1.PageCurrent;
// pageData.PageSize = this.ucPagerEx1.PageSize;
// pageData.QueryCondition = sql.ToString();
// pageData.QueryFieldName = "ID,Callw_Telephone,Callw_DateTime,Callw_Status,Callw_Remark,Callw_SoundRecording,Callw_UpdateDatetime,Cus_Name,Cus_Sex,Cus_CustomerNumber,Cus_Type";
// pageData.OrderStr = " ID desc ";
// DataSet da = pageData.QueryDataTable();
// dt = da.Tables[0];
// if (dt.Rows.Count > 0)
// {
// this.Invoke(new UpdateControl(delegate()
// {
// #region
// 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();
// dgvr.Cells.Add(cell);
// cell = new DataGridViewTextBoxCell();
// cell.Value = dt.Rows[i]["Callw_Telephone"].ToString();
// dgvr.Cells.Add(cell);
// cell = new DataGridViewTextBoxCell();
// cell.Value = Convert.ToDateTime(dt.Rows[i]["Callw_DateTime"]).ToString("yyyy-MM-dd");
// dgvr.Cells.Add(cell);
// cell = new DataGridViewTextBoxCell();
// cell.Value = dt.Rows[i]["Cus_Type"].ToString() == "" ? "其它电话来电" : dt.Rows[i]["Cus_Type"].ToString();
// dgvr.Cells.Add(cell);
// this.dgv.Rows.Add(dgvr);
// dgv.ClearSelection();
// }
// #endregion
// }));
// }
// });
// try
// {
// this.ucPagerEx1.TbDataSource = dt;
// }
// catch { }
// return pageData.TotalCount;
//}
}
}