在好例子网,分享、交流、成长!
您当前所在位置:首页C# 开发实例C#语言基础 → 企业短信猫 群发短信示例源码(含dllforvc.dll)

企业短信猫 群发短信示例源码(含dllforvc.dll)

C#语言基础

下载此实例
  • 开发语言:C#
  • 实例大小:2.08M
  • 下载次数:25
  • 浏览次数:218
  • 发布时间:2018-04-06
  • 实例类别:C#语言基础
  • 发 布 人:hanbing3350196
  • 所需积分:2
 相关标签: 短信 短信猫

实例介绍

【实例简介】

【实例截图】

from clipboard


from clipboard


from clipboard


    from clipboard


from clipboard

【核心代码】


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Data.OleDb;
namespace SMS
{
    public partial class frmSendSMS : Form
    {

        public frmSendSMS()
        {
            InitializeComponent();
        }
        public string content;
        public string ResviceNum;
        public static string NUM;
        public static string JQCOM;
        public static string BTL;
        public string Power="YIWU-IJDD-CDQW-JDWG";
        public static int k = 0;
        public static int j = 0;
        private void frmSendSMS_Load(object sender, EventArgs e)
        {
            txtaddnum.Focus();
            NUM = BaseClass.GSM.GSMModemGetSnInfoNew(JQCOM, BTL); //机器号码
            JQCOM = BaseClass.GSM.GSMModemGetDevice();  //COM1
            BTL = BaseClass.GSM.GSMModemGetBaudrate();  //波特率
        }

        private void AddMessage(string num,string strcontent,string sendtime)
        {
            OleDbConnection conn = BaseClass.ConnClass.DataConn();
            conn.Open();
            OleDbCommand cmd = new OleDbCommand("insert into tb_TelSend([TelNum],[TelContent],[TelTime]) values('" num "','" strcontent "','" sendtime "')",conn);
            cmd.ExecuteNonQuery();
            conn.Close();
        }
        private void SendSms(string strcom,string strbtl)
        {
            try
            {
                ////连接设备
                if (BaseClass.GSM.GSMModemInitNew(strcom, strbtl, null, null, false, Power) == false)
                {
                    MessageBox.Show("设备连接失败!"   BaseClass.GSM.GSMModemGetErrorMsg(), "提示", MessageBoxButtons.OK);
                    return;
                }
                // 发送短信
                j = lvInceptNum.Items.Count;
                for (int i = 0; i < lvInceptNum.Items.Count; i  )
                {
                    AddMessage(lvInceptNum.Items[i].Text, txtSmsContent.Text, DateTime.Now.ToString());
                    if (BaseClass.GSM.GSMModemSMSsend(null, 8, content, Encoding.Default.GetByteCount(content), lvInceptNum.Items[i].Text, false) == true)
                        k  ;
                }
                if (k == j)
                {
                    MessageBox.Show("短信发送成功!", "提示", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void txtaddnum_KeyPress(object sender, KeyPressEventArgs e)
        {
            if ((e.KeyChar != 8 && !char.IsDigit(e.KeyChar)) && e.KeyChar != 13)
            {
                MessageBox.Show("请输入数字");
                e.Handled = true;
            }
        }
        private void btnSend_Click(object sender, EventArgs e)
        {
            if (lvInceptNum.Items.Count > 0)
            {
                if (ckbselect.Checked)
                {
                    content = "老朋友:"   txtSmsContent.Text;
                }
                else
                {
                    content = txtSmsContent.Text;
                }
                if (this.lvInceptNum.Items.Count <= 0)
                {
                    MessageBox.Show("手机号码不能为空!", "提示", MessageBoxButtons.OK);
                    this.txtaddnum.Focus();
                    return;
                }
                if (txtSmsContent.Text == "")
                {
                    MessageBox.Show("短信内容不能为空!", "提示", MessageBoxButtons.OK);
                    txtSmsContent.Focus();
                    return;
                }
                SendSms(JQCOM, BTL);
            }
            else
            {
                MessageBox.Show("请输入接收的电话号码");
            }
        }

        private void btnCancol_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnInsert_Click(object sender, EventArgs e)
        {
            frmDy frmd = new frmDy();
            frmd.Owner = this;
            frmd.ShowDialog();
        }

        private void btnIncept_Click(object sender, EventArgs e)
        {
            if (txtaddnum.Text == "")
            {
                MessageBox.Show("电话号码不能为空!");
            }
            else
            {
                if (txtaddnum.Text.Length < 11)
                {
                    MessageBox.Show("手机号码为11位");
                    return;
                }
            }
            if (lvInceptNum.Items.Count > 0)
            {
                for (int i = 0; i < lvInceptNum.Items.Count; i  )
                {
                    if (lvInceptNum.Items[i].Text == txtaddnum.Text)
                    {
                        MessageBox.Show("号码已经添加过了!");
                        return;
                    }
                }
                lvInceptNum.Items.Add(txtaddnum.Text);
                txtaddnum.Text = "";
            }
            else
            {
                lvInceptNum.Items.Add(txtaddnum.Text);
                txtaddnum.Text = "";
            }
        }

        private void btnDelIncept_Click(object sender, EventArgs e)
        {
            if (lvInceptNum.Items.Count > 0)
            {
                foreach (ListViewItem it in lvInceptNum.SelectedItems)
                {
                    lvInceptNum.Items.Remove(it);
                }
            }
            else
            {
                MessageBox.Show("没有电话号码");
            }
        }

        private void btnSelTel_Click(object sender, EventArgs e)
        {
            frmTelNote telnote = new frmTelNote();
            telnote.Owner = this;
            telnote.ShowDialog();
        }

        private void lvInceptNum_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void txtSmsContent_TextChanged(object sender, EventArgs e)
        {

        }
    }
}


标签: 短信 短信猫

实例下载地址

企业短信猫 群发短信示例源码(含dllforvc.dll)

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
;
报警