private void btnSend_Click(object sender, EventArgs e) { SMS sm = new SMS(cboPorts.Text); sm.Opens(); sm.sendSMS(txtPhone.Text, txtMessage.Text); sm.Closes(); MessageBox.Show("Message Sent!"); //sendmessagetomobile(); }
private void btnSendSmsList_Click(object sender, EventArgs e) { GTRLibrary.clsConnection clsCon = new GTRLibrary.clsConnection(); ArrayList arQuery = new ArrayList(); //GTRLibrary.clsConnection clsCon = new GTRLibrary.clsConnection("GTRHRIS"); string sqlQuery = ""; Int32 NewId = 0; try { SMS sm = new SMS(cboPorts.Text); sm.Opens(); int count = 0; foreach (UltraGridRow row in gridList.Rows) { if ((Int16.Parse(row.Cells["isChecked"].Value.ToString()) == 1) && (Int16.Parse(row.Cells["Mobileno"].Text.Length.ToString()) > 10) && (Int16.Parse(row.Cells["Mobileno"].Text.Length.ToString()) < 15) && (Int16.Parse(row.Cells["Remarks"].Text.Length.ToString()) > 0)) { row.Appearance.BackColor = Color.Coral; row.Cells["Sending_Sts"].Value = "Running"; row.Cells["Sending_Sts"].Refresh(); gridList.Refresh(); //sqlQuery = "Exec prcDBBackup '" + row.Cells["SLNo"].Value + "','','','" + Common.Classes.clsMain.intUserId + "'"; //clsCon.GTRSaveDataWithSQLCommand(sqlQuery); sm.sendSMS(row.Cells["MobileNo"].Text.ToString(), row.Cells["empname"].Text.ToString() + " - " + row.Cells["status"].Text.ToString() + " - " + row.Cells["Remarks"].Text.ToString()); row.Appearance.BackColor = Color.BlanchedAlmond; row.Cells["Sending_Sts"].Value = "Complete"; row.Cells["Sending_Sts"].Refresh(); gridList.Refresh(); count = count + 1; //SMS Insert //NewId //sqlQuery = "Select Isnull(Max(EmpId),0)+1 As NewId from tblEmp_Info"; //NewId = clsCon.GTRCountingData(sqlQuery); sqlQuery = "Insert Into tblsms_send (ComId, empId, emp_Code, dtSent,tmSent, sendSMS, aId, PCName)" + " Values (" + Common.Classes.clsMain.intComId + ", '" + row.Cells["empId"].Value.ToString() + "', '" + row.Cells["emp_Code"] + "', '" + row.Cells["dtSent"] + "', '" + row.Cells["tmSent"] + "', '" + row.Cells["sendSMS"] + "', " + NewId + ", " + Common.Classes.clsMain.intUserId + "' "; arQuery.Add(sqlQuery); } } sm.Closes(); MessageBox.Show("Message Sent ! " + count + " "); //MessageBox.Show("AT+CMGF=1" + (char)(13)); // dbName = dbName.Substring(0, dbName.Length - 1); // MessageBox.Show("Data backup SuccessFully"); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { clsCon = null; } }