123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422 |
- 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;
- }
- /// <summary>
- /// 是否弹屏提示:“AutoShow” 为判断
- /// </summary>
- string ShowType = "";
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void IntentionRemind_Load( object sender, EventArgs e )
- {
- if ( ShowType == "AutoShow" )
- {
- if ( this.GetRemindCount() <= 0 )
- {
- this.IsShadow = false;
- this.Close();
- return;
- }
- this.IsShowUcNavigationTool = false;
- }
- }
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- /// <summary>
- /// 列表双击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- }
- }
- }
- }
- }
- }
- /// <summary>
- /// 提醒设置按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnRemind_Click( object sender, EventArgs e )
- {
- LYFZ.Software.MainBusiness.HospitalTrackingSystem.RemindSet frm = new HospitalTrackingSystem.RemindSet();
- frm.StrRemindSetLoadType = HospitalTrackingSystem.RemindSet.RemindSetLoadType.客户管理今日提醒;
- frm.ShowDialog();
- }
- /// <summary>
- /// 发信息按钮
- /// </summary>
- 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 );
- }
- }
- /// <summary>
- /// 查看全部 判断使用
- /// </summary>
- bool selectAll = false;
- /// <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 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( "请选中要取消提醒的行!" );
- }
- }
- /// <summary>
- /// 全部查看 按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnAll_Click( object sender, EventArgs e )
- {
- this.dateStart.DateValue = "";
- this.dateFinish.DateValue = "";
- this.selectAll = true;
- this.Bind();
- }
- /// <summary>
- /// 查询按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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();
- }
- }
- /// <summary>
- /// 刷新事件
- /// </summary>
- public void Bind()
- {
- this.ucPagerEx1.PageCurrent = 1;
- this.ucPagerEx1.PageSize = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetPageSize();//3;分页条数
- this.ucPagerEx1.Bind();
- }
- /// <summary>
- /// 画分页
- /// </summary>
- /// <param name="e"></param>
- /// <returns></returns>
- 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"] );
- }
- }
- }
|