public bool SendMessage(SMSMessage msg, bool immediate, out String status) { int rs = 0; status = String.Empty; if (msg.id == 0) { //billable, bulkbillable, astStatus, batchID, status, nextPolled, pollCount msg.id = dh.SaveQueuedMessage(msg.building, msg.customer, msg.cbal, msg.smsType, msg.number, msg.reference, msg.message, msg.billable, msg.bulkbillable, msg.sent, msg.sender, msg.astStatus, msg.batchID, msg.status); msg.reference = String.Format("{0}/{1}", msg.customer, msg.id); rs = dh.SaveOutboundMessage(msg.id, msg.building, msg.customer, msg.number, msg.reference, msg.message, msg.billable, msg.bulkbillable, msg.sent, msg.sender, msg.astStatus, msg.batchID, msg.status, msg.nextPolled, msg.pollCount, msg.cbal, msg.smsType, out status); if (msg.smsType == "Disconnection SMS" || immediate) { String bid; bool success = SendSMS(msg.number, String.Format("{0}", msg.message), out status, out bid); if (success) { msg.batchID = bid; msg.status = "SENT"; dh.SaveOutboundMessage(msg.id, msg.building, msg.customer, msg.number, msg.reference, msg.message, msg.billable, msg.bulkbillable, msg.sent, msg.sender, msg.astStatus, msg.batchID, msg.status, msg.nextPolled, msg.pollCount, msg.cbal, msg.smsType, out status); } else { MessageBox.Show("Cannot send sms to " + msg.customer); } } } return(rs != -1 ? true : false); }