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.Customers
{
public partial class IntentionRemind : LYFZ.Software.UI.Customers.IntentionRemind
{
LYFZ.BLL.BLL_ErpOrder orbll = new BLL.BLL_ErpOrder();
public IntentionRemind()
{
this.UcNavigationTool.LabTitle = "今日提醒";
this.Load += IntentionRemind_Load;
this.Shown += IntentionRemind_Shown;
this.ucPagerEx1.EventPaging += ucPagerEx1_EventPaging;
this.btnSelect.Click += btnSelect_Click;
this.btnAll.Click += btnAll_Click;
this.btnCancel.Click += btnCancel_Click;
this.btnClose.Click += btnClose_Click;
this.btnSMS.Click += btnSMS_Click;
this.btnRemind.Click += btnRemind_Click;
this.btnRemind.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights( LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TodayRemindedCustomerCompetence, LYFZ.CustomAttributes.OperatingAuthority.RemindedSet );
this.btnCancel.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights( LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TodayRemindedCustomerCompetence, LYFZ.CustomAttributes.OperatingAuthority.CancelRemindedSet );
this.btnSMS.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights( LYFZ.BLL.BLL_ErpUser.CurrentUserRights.TodayRemindedCustomerCompetence, LYFZ.CustomAttributes.OperatingAuthority.SMSSend );
this.dgvData.CellDoubleClick += dgvData_CellDoubleClick;
}
public IntentionRemind( string p )
: this()
{
ShowType = p;
}
///
/// 是否弹屏提示:“AutoShow” 为判断
///
string ShowType = "";
///
/// 窗体加载事件
///
///
///
void IntentionRemind_Load( object sender, EventArgs e )
{
if ( ShowType == "AutoShow" )
{
if ( this.GetRemindCount() <= 0 )
{
this.IsShadow = false;
this.Close();
return;
}
this.IsShowUcNavigationTool = false;
}
}
///
/// 窗体加载事件
///
///
///
void IntentionRemind_Shown( object sender, EventArgs e )
{
this.dateStart.DateValue = SDateTime.Now.ToString( "yyyy-MM-dd" );
this.dateFinish.DateValue = this.dateStart.DateValue;
this.ucPagerEx1.Bind();
}
///
/// 列表双击事件
///
///
///
void dgvData_CellDoubleClick( object sender, DataGridViewCellEventArgs e )
{
if ( e.RowIndex >= 0 && e.ColumnIndex >= 0 )
{
if ( this.dgvData.Rows.Count > 0 )
{
if ( this.dgvData.CurrentRow != null )
{
if ( this.dgvData.CurrentRow.Index >= 0 && this.dgvData.CurrentCell.RowIndex >= 0 )
{
bool bitemEnum = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(
LYFZ.Software.MainBusiness.VersionControl.VersionFunctionEnum.客户管理沟通再次提醒
, false );
if ( bitemEnum )
{
LYFZ.Software.MainBusiness.Customers.OldCustomer.FrmAddInterestedBuyers frm = new OldCustomer.FrmAddInterestedBuyers();
frm.GMID = this.dgvData.CurrentRow.Cells["客户组ID"].Value.ToString().Trim();
if ( frm.ShowDialog() == DialogResult.OK )
{
this.Bind();
}
}
}
}
}
}
}
///
/// 提醒设置按钮
///
///
///
void btnRemind_Click( object sender, EventArgs e )
{
LYFZ.Software.MainBusiness.HospitalTrackingSystem.RemindSet frm = new HospitalTrackingSystem.RemindSet();
frm.StrRemindSetLoadType = HospitalTrackingSystem.RemindSet.RemindSetLoadType.客户管理今日提醒;
frm.ShowDialog();
}
///
/// 发信息按钮
///
void btnSMS_Click( object sender, EventArgs e )
{
try
{
string Cus_Telephone = "";
string Sj1 = "";
LYFZ.Software.MainBusiness.SMSManagement.SmsSend.FrmSendSms set = new SMSManagement.SmsSend.FrmSendSms();
if ( this.dgvData.SelectedRows.Count == 0 )
{
MessageBoxCustom.Show( "选择你要发送短信的客户!" ); return;
}
for ( int i = 0; i < this.dgvData.SelectedRows.Count; i++ )
{
Cus_Telephone = this.dgvData.SelectedRows[i].Cells["客户电话"].Value.ToString();
//检查手机合法性
if ( !string.IsNullOrEmpty( Cus_Telephone ) )
{
Sj1 += Cus_Telephone + ",";
}
}
set.Phone = Sj1;
set.ShowDialog();
}
catch ( Exception ex )
{
MessageBoxCustom.Show( ex.Message );
}
}
///
/// 查看全部 判断使用
///
bool selectAll = false;
///
/// 关闭 按钮
///
///
///
void btnClose_Click( object sender, EventArgs e )
{
this.Close();
}
///
/// 取消提醒 按钮
///
///
///
void btnCancel_Click( object sender, EventArgs e )
{
if ( dgvData.SelectedRows.Count > 0 )
{
if ( MessageBoxCustom.Show( "确定取消?", "提示信息!", MessageBoxButtons.YesNo ) == DialogResult.Yes )
{
BLL.BLL_ErpCustomerGroup bll = new BLL.BLL_ErpCustomerGroup();
Model.Model_ErpCustomerGroup model = bll.GetModel( "GP_CustomerGroupID", this.dgvData.CurrentRow.Cells["客户组ID"].Value.ToString() );
model.GP_ReminderTime = LYFZ.WinAPI.CustomPublicMethod.GetNullDateTime();
model.GP_RemindEvent = "";
if ( bll.Update( model ) )
{
MessageBoxCustom.Show( "取消成功!" ); Bind();
}
else
{
MessageBoxCustom.Show( "取消失败!" );
}
}
}
else
{
MessageBoxCustom.Show( "请选中要取消提醒的行!" );
}
}
///
/// 全部查看 按钮
///
///
///
void btnAll_Click( object sender, EventArgs e )
{
this.dateStart.DateValue = "";
this.dateFinish.DateValue = "";
this.selectAll = true;
this.Bind();
}
///
/// 查询按钮
///
///
///
void btnSelect_Click( object sender, EventArgs e )
{
if ( this.dateFinish.DateValue != "" && this.dateStart.DateValue != "" && this.dateFinish.DateValue != this.dateStart.DateValue )
{
this.selectAll = false;
if ( DateTime.Compare( this.dateFinish.Value, this.dateStart.Value ) > 0 )
{
this.Bind();
}
else
{
MessageBoxCustom.Show( "第二个时间比第一个小,不能查询!" );
}
}
else
{
// 如果没有选择时间,默认查询全部;
this.selectAll = true;
this.Bind();
}
}
///
/// 刷新事件
///
public void Bind()
{
this.ucPagerEx1.PageCurrent = 1;
this.ucPagerEx1.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
this.ucPagerEx1.Bind();
}
///
/// 画分页
///
///
///
int ucPagerEx1_EventPaging( UCPager.EventPagingArg e )
{
#region 获取条件
string StrSQL = "";
DataTable dthrs = orbll.GetView_Custom( "tb_ErpHospitalRemindSettings", StrWhere: "Hrs_RemindConditions in (0, 2, 3, 4) and Hrs_StartState='0'", ShowColumnName: "Hrs_RemindDays,Hrs_RemindConditions" ).Tables[0];
if ( dthrs.Rows.Count > 0 )
{
string StrNewSQl = "";
#region 新添加宝宝生日满x天的提醒;
DataRow[] dtRow0 = dthrs.Select( "Hrs_RemindConditions = 0" );
for ( int i = 0; i < dtRow0.Length; i++ )
{
StrNewSQl += dtRow0[i]["Hrs_RemindDays"].ToString() + ",";
}
if ( !string.IsNullOrEmpty( StrNewSQl ) )
{
StrSQL += "(距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '出生满天提醒')";
}
#endregion
StrNewSQl = "";
DataRow[] dtRow1 = dthrs.Select( "Hrs_RemindConditions = 2" );
for ( int i = 0; i < dtRow1.Length; i++ )
{
StrNewSQl += dtRow1[i]["Hrs_RemindDays"].ToString() + ",";
}
if ( !string.IsNullOrEmpty( StrNewSQl ) )
{
if ( !string.IsNullOrEmpty( StrSQL ) )
StrSQL += "or (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '生日提醒')";
else
StrSQL += " (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '生日提醒')";
}
StrNewSQl = "";
DataRow[] dtRow2 = dthrs.Select( "Hrs_RemindConditions = 3" );
for ( int i = 0; i < dtRow2.Length; i++ )
{
StrNewSQl += dtRow2[i]["Hrs_RemindDays"].ToString() + ",";
}
if ( !string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
{
StrSQL += " or (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '婚庆提醒')";
}
else if ( string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
{
StrSQL += " (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '婚庆提醒')";
}
StrNewSQl = "";
DataRow[] dtRow3 = dthrs.Select( "Hrs_RemindConditions = 4" );
for ( int i = 0; i < dtRow3.Length; i++ )
{
StrNewSQl += dtRow3[i]["Hrs_RemindDays"].ToString() + ",";
}
if ( !string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
{
StrSQL += " or (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '结婚纪念提醒')";
}
else if ( string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
{
StrSQL += " (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '结婚纪念提醒')";
}
}
if ( !selectAll )
{
if ( !string.IsNullOrEmpty( StrSQL ) )
{
StrSQL += " or ";
}
if ( this.dateStart.DateValue == null )
StrSQL += "( And 提醒类别 = '指定提醒')";
else
StrSQL += " (" + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime( "convert(datetime,提醒时间,120)", this.dateStart.DateValue, this.dateFinish.DateValue, ConnectWord: "" ) + " And 提醒类别 = '指定提醒')";
}
#endregion
DataTable dt = new DataTable();
LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
pageData.TableName = "view_OldRemind";
pageData.PageIndex = this.ucPagerEx1.PageCurrent;
pageData.PageSize = this.ucPagerEx1.PageSize;
pageData.QueryCondition = StrSQL;
pageData.QueryFieldName = "客户姓名,客户性别,客户生日,客户婚期,客户电话,客户QQ,所在区域,地址,工作单位,客户来源,提醒时间,提醒事项,客户组ID,距离提醒,提醒类别";
pageData.OrderStr = "提醒时间";
pageData.OrderType = 1;
LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod( delegate ( object obj, BackgroundWorker backgroundWorker )
{
dt = pageData.QueryDataTable().Tables[0];
} );
try
{
this.dgvData.DataSource( dt, strHideField: "客户组ID,距离提醒" );
}
catch
{
}
try
{
this.ucPagerEx1.TbDataSource = dt;
this.dgvData.ClearSelection();
//this.selectAll = false;
}
catch { }
return pageData.TotalCount;
}
int GetRemindCount()
{
string StrSQL = "";
DataTable dthrs = orbll.GetView_Custom( "tb_ErpHospitalRemindSettings", StrWhere: "Hrs_RemindConditions in (0, 2, 3, 4) and Hrs_StartState='0'", ShowColumnName: "Hrs_RemindDays,Hrs_RemindConditions" ).Tables[0];
if ( dthrs.Rows.Count > 0 )
{
string StrNewSQl = "";
#region 新添加宝宝生日满x天的提醒;
DataRow[] dtRow0 = dthrs.Select( "Hrs_RemindConditions = 0" );
for ( int i = 0; i < dtRow0.Length; i++ )
{
StrNewSQl += dtRow0[i]["Hrs_RemindDays"].ToString() + ",";
}
if ( !string.IsNullOrEmpty( StrNewSQl ) )
{
StrSQL += " (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '出生满天提醒')";
}
#endregion
StrNewSQl = "";
DataRow[] dtRow1 = dthrs.Select( "Hrs_RemindConditions = 2" );
for ( int i = 0; i < dtRow1.Length; i++ )
{
StrNewSQl += dtRow1[i]["Hrs_RemindDays"].ToString() + ",";
}
if ( !string.IsNullOrEmpty( StrNewSQl ) )
{
if(!string.IsNullOrEmpty(StrSQL))
{
StrSQL += " or ";
}
StrSQL += " (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '生日提醒')";
}
StrNewSQl = "";
DataRow[] dtRow2 = dthrs.Select( "Hrs_RemindConditions = 3" );
for ( int i = 0; i < dtRow2.Length; i++ )
{
StrNewSQl += dtRow2[i]["Hrs_RemindDays"].ToString() + ",";
}
if ( !string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
{
StrSQL += " or (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '婚庆提醒')";
}
else if ( string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
{
StrSQL += " (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '婚庆提醒')";
}
StrNewSQl = "";
DataRow[] dtRow3 = dthrs.Select( "Hrs_RemindConditions = 4" );
for ( int i = 0; i < dtRow3.Length; i++ )
{
StrNewSQl += dtRow3[i]["Hrs_RemindDays"].ToString() + ",";
}
if ( !string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
{
StrSQL += " or (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '结婚纪念提醒')";
}
else if ( string.IsNullOrEmpty( StrSQL ) && !string.IsNullOrEmpty( StrNewSQl ) )
{
StrSQL += " (距离提醒 in (" + StrNewSQl.TrimEnd( ',' ) + ") And 提醒类别 = '结婚纪念提醒')";
}
}
if ( !string.IsNullOrEmpty( StrSQL ) )
{
StrSQL += " or ";
}
StrSQL += " (" + LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime( "convert(datetime,提醒时间,120)", SDateTime.Now.ToString( "yyyy-MM-dd" ), SDateTime.Now.ToString( "yyyy-MM-dd" ), ConnectWord: "" ) + " And 提醒类别 = '指定提醒')";
DataTable dt = orbll.GetView_Custom( "view_OldRemind", StrWhere: StrSQL, ShowColumnName: "Count(*) AS CountID" ).Tables[0];
return Convert.ToInt32( dt.Rows[0]["CountID"] );
}
}
}