{ int port; int baud; string status, acknowlegde; GsmCommMain myport; public Form1() { InitializeComponent(); } private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { try { port = int.Parse(cmbport.Text); baud = int.Parse(cmbbaud.Text); myport = new GsmCommMain(port, baud); myport.Open(); if (myport.IsConnected()) { status = "Connected"; lblstatus.Text = status; } else { status = "Not connected"; lblstatus.Text = status; } myport.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); MessageBox.Show("Invalid Connection Setting"); status = "Not Connected"; lblstatus.Text = status; } } public void showack(string acknowlegde) { lsthistory.Items.Add(acknowlegde); lsthistory.Items.Add("Recipent::" + lsthistory.Text + "\n"); lsthistory.Items.Add("Message:\n"); lsthistory.Items.Add(txtmsg.Text); lsthistory.Items.Add("-------------------------\n"); } private void button1_Click_1(object sender, EventArgs e) { try { if (status == "Connected") { SmsSubmitPdu pdu = new SmsSubmitPdu(txtmsg.Text, lsthistory.Text); myport.Open(); myport.SendMessage(pdu); Cursor.Current = Cursors.WaitCursor; myport.Close(); acknowlegde = "Message Sent Sucessfuly!"; showack(acknowlegde); } else { acknowlegde = "Message not sent! Retry?"; showack(acknowlegde); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)