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.SMSManagement { public partial class FrmShortSmsMessage : LYFZ.Software.UI.SMSManagement.FrmShortSmsMessage { private delegate void UpdateControl(); int SumCount = 0; //短信条数 public FrmShortSmsMessage() { this.btnContentSelection.Click += new EventHandler(btnContentSelection_Click); this.richNr.TextChanged += new EventHandler(richNr_TextChanged); this.btnScreening.Click += new EventHandler(btnScreening_Click); this.btnClear.Click += new EventHandler(btnClear_Click); this.btnDelete.Click += new EventHandler(btnDelete_Click); this.btnImportNumbers.Click += new EventHandler(btnImportNumbers_Click); this.btnSendSMS.Click += new EventHandler(btnSendSMS_Click); this.Shown += FrmShortSmsMessage_Shown; this.dgvPhoneNumbers.CellClick += dgvPhoneNumbers_CellClick; this.dgvPhoneNumbers.Click += dgvPhoneNumbers_Click; this.rdoAllSelect.Click += rdoAll_Click; this.rdoUnselected.Click += rdoUnselected_Click; #region 短信发送 if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.ShortSmsMessageCompetence, CustomAttributes.OperatingAuthority.SMSSend)) { btnSendSMS.Enabled = true; } else { btnSendSMS.Enabled = false; } #endregion } void rdoUnselected_Click(object sender, EventArgs e) { Unselected(); dgvPhoneNumbers_Click(sender, e); } //反选 private void Unselected() { if (this.dgvPhoneNumbers.Rows.Count > 0) { for (int i = 0; i < this.dgvPhoneNumbers.Rows.Count; i++) { this.dgvPhoneNumbers.Rows[i].Selected = !dgvPhoneNumbers.Rows[i].Selected; } } } void rdoAll_Click(object sender, EventArgs e) { this.dgvPhoneNumbers.SelectAll(); dgvPhoneNumbers_Click(sender, e); } void dgvPhoneNumbers_Click(object sender, EventArgs e) { string Sj = ""; this.richTelPhone.Text = ""; if (this.dgvPhoneNumbers.SelectedRows != null && this.dgvPhoneNumbers.SelectedRows.Count > 0) { for (int i = 0; i < this.dgvPhoneNumbers.SelectedRows.Count; i++) { string tempPhones = dgvPhoneNumbers.SelectedRows[i].Cells["TelPhone"].Value.ToString(); string[] phones = tempPhones.Split('/'); foreach (string phone in phones) { if (phone.Trim().Length > 0 && !Sj.Contains(phone)) { if (LYFZ.WinAPI.CustomPublicMethod.ValidationPhones(phone).Trim().Length <= 0) { Sj += phone + ","; } } } } richTelPhone.Text = Sj.Trim().Trim(','); txtPhoneCount.Text = richTelPhone.Text.Split(',').Length.ToString(); } } void dgvPhoneNumbers_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex >= 0) { } } #region 加载 protected void FrmShortSmsMessage_Shown(object sender, EventArgs e) { lblName.Text = SmsSend.FrmSendSms.GetlblNameTextString(0, 0) + " 特别说明:群发(营销类)短信结尾必须加“回TD退订”字样"; } #endregion #region 选择发送内容模板 protected void btnContentSelection_Click(object sender, EventArgs e) { frmSelectSmsInfo selectInfo = new frmSelectSmsInfo(); if (selectInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (selectInfo.SmsModel.ID > 0) { this.richNr.Text = selectInfo.SmsModel.ST_SMSContent; SumCount = SmsSend.FrmSendSms.GetSmsSizeCount(selectInfo.SmsModel.ST_SMSContent, SmsSend.FrmSendSms.Works64); lblName.Text = SmsSend.FrmSendSms.GetlblNameTextString(selectInfo.SmsModel.ST_SMSContent.Length, SumCount * richTelPhone.Text.Trim().Split(',').Length) + " 特别说明:群发(营销类)短信结尾必须加“回TD退订”字样"; } } } #endregion #region 内容输入事件 protected void richNr_TextChanged(object sender, EventArgs e) { #region 获取67字数 string Nr = richNr.Text; lblName.Text = SmsSend.FrmSendSms.GetlblNameTextString(Nr.Length, SmsSend.FrmSendSms.GetSmsSizeCount(Nr.ToString(), SmsSend.FrmSendSms.Works64) * richTelPhone.Text.Trim().Split(',').Length) + " 特别说明:群发(营销类)短信结尾必须加“回TD退订”字样"; #endregion } #endregion #region 筛选 List tempPhoneNumbers = new List(); /// /// 临时手机号集合 /// public List TempPhoneNumbers { get { return tempPhoneNumbers; } set { tempPhoneNumbers = value; } } protected void btnScreening_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.SMSManagement.ShortSmsMessage.FrmScreening smsFilter = new ShortSmsMessage.FrmScreening(); if (smsFilter.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (smsFilter.SelectPhoneNumbers.Count > 0) { LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker) { int iCount=1; foreach (ItemValue item in smsFilter.SelectPhoneNumbers) { backgroundWorker.ReportProgress(0, "共" + smsFilter.SelectPhoneNumbers.Count.ToString() + "个,已添加" + iCount.ToString()+"个"); DataGridViewRow row = new DataGridViewRow(); this.Invoke(new UpdateControl(delegate() { row.CreateCells(this.dgvPhoneNumbers); row.Cells[0].Value = item.Text.Trim(); row.Cells[1].Value = item.Value.ToString().Trim(); if (!this.TempPhoneNumbers.Contains(item.Value.ToString().Trim())) { this.TempPhoneNumbers.Add(item.Value.ToString().Trim()); this.dgvPhoneNumbers.Rows.Add(row); } })); iCount++; } }); } } } #endregion #region 清空 protected void btnClear_Click(object sender, EventArgs e) { TempPhoneNumbers.Clear(); dgvPhoneNumbers.Rows.Clear(); this.richTelPhone.Text = ""; txtPhoneCount.Text = "0"; } #endregion #region 删除 protected void btnDelete_Click(object sender, EventArgs e) { if (this.dgvPhoneNumbers.SelectedRows != null && this.dgvPhoneNumbers.SelectedRows.Count > 0) { int count = this.dgvPhoneNumbers.SelectedRows.Count; for (int i = 0; i < count; i++) { string delPhone = this.dgvPhoneNumbers.SelectedRows[0].Cells[1].Value.ToString(); this.dgvPhoneNumbers.Rows.Remove(this.dgvPhoneNumbers.SelectedRows[0]); TempPhoneNumbers.Remove(delPhone); } this.richTelPhone.Text = ""; txtPhoneCount.Text = "0"; } else { MessageBoxCustom.Show("请选择你要删除的客户!"); } } #endregion #region 导入号码 protected void btnImportNumbers_Click(object sender, EventArgs e) { LYFZ.Software.MainBusiness.SMSManagement.ShortSmsMessage.FrmImportNumbers set = new ShortSmsMessage.FrmImportNumbers(); if (set.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (!string.IsNullOrEmpty(set.Telphone)) { richTelPhone.Text = set.Telphone; txtPhoneCount.Text = richTelPhone.Text.Trim().Split(',').Length.ToString(); } } } #endregion #region 发送短信 protected void btnSendSMS_Click(object sender, EventArgs e) { SmsSend.FrmSendSms.AddSendSMS(richTelPhone.Text, richNr.Text); } #endregion } }