Example #1
0
 private void send_message_Click(object sender, EventArgs e)
 {
     GsmModem gm = new GsmModem(GsmModem.FindPort(),9600);
     try
     {
         gm.Open();
     }
     catch { }
     gm.SendAT("AT");
     gm.SendAT("ATE0");
     gm.SendAT("AT+CMGF=0");
     DataTable dt = new DataTable();
     DataTable dt2 = new DataTable();
     string meetingtime= Convert.ToString(mainform.db.query_dt("select meetingtime from meeting where meetingname='" + meeting_select.Text + "'").Rows[0].ItemArray[0]);
     string meetingaddress = Convert.ToString(mainform.db.query_dt("select meetingaddress from meeting where meetingname='" + meeting_select.Text + "'").Rows[0].ItemArray[0]);
     dt = mainform.db.query_dt("select phone from voter where meetingname='"+meeting_select.Text+"' and present=0");
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         string phone = Convert.ToString(dt.Rows[i].ItemArray[0]);
         dt2 = mainform.db.query_dt("select judgename from judges where phone='" + phone + "'");
         string name =Convert.ToString( dt2.Rows[0].ItemArray[0]);
         gm.SendMsg(phone, name+"老师:\n"+"        请您于"+meetingtime+"准时到" +meetingaddress.Trim()+"参加"+ meeting_select.Text + "!");
     }
     gm.Close();
     MessageBox.Show("发送成功!");
 }
Example #2
0
 private void start_Click(object sender, EventArgs e)
 {
     mainform.db.update("delete from result where meetingname='"+meetingname+"' and pollnum='"+pollnum_select.Text+"'");
     mainform.db.update("delete from sms where meetingname='" + meetingname + "' and pollnum='" + pollnum_select.Text + "'");
     for (int i = 0; i < voting_dg.Rows.Count; i++)
     {
         string projectnum = Convert.ToString(voting_dg.Rows[i].Cells[0].Value);
         mainform.db.update("insert into result values('" + meetingname + "','" + pollnum_select.Text + "','" + projectnum + "'," + "0,0,100,0)");
     }
     mainform.db.update("delete from votestate where meetingname='" + meetingname + "' and pollnum='" + pollnum_select.Text + "'");
     DataTable dt = new DataTable();
     dt = mainform.db.query_dt("select phone from voter where meetingname='"+meetingname+"' and present=1");
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         string phone = Convert.ToString(dt.Rows[i].ItemArray[0]);
         mainform.db.update("insert into votestate(meetingname,pollnum,phone,voted,information) values('"+meetingname+"','"+pollnum_select.Text+"','"+phone+"',0,'')");
     }
     this.Invoke(updatestate);
     gm = new GsmModem(GsmModem.FindPort(), 9600);
     gm.OnRecieved += new GsmModem.OnRecievedHandler(gm_OnReceived);
     try
     {
         gm.Open();
     }
     catch{}
     gm.SendAT("AT");
     gm.SendAT("ATE0");
     gm.SendAT("AT+CMGF=0");
     gm.SendAT("AT+CMGDA=6");
     MessageBox.Show("串口开启成功!");
     start.Enabled = false;
     finish.Enabled = true;
     check_result.Enabled = false;
     int num = mainform.db.query_dt("select *from project where meetingname='" + meetingname + "' and pollnum='" + pollnum + "'").Rows.Count;
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         string phone = Convert.ToString(dt.Rows[i].ItemArray[0]);
         string message = "*";
         for (int j = 0; j < num; j++)
             message += "*#";
         gm.SendMsg(phone,message);
     }
 }