Beispiel #1
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     try
     {
         if (btnConnect.Text.ToUpper() == "CONNECT")
         {
             SMSconnection();
             btnSendSMS.Enabled     = false;
             tmrSendSMS.Enabled     = true;
             btnConnect.Text        = "DISCONNECT";
             btnClose.Enabled       = true;
             lbl_phone_status.Text  = "CONNECT";
             btnReceivedSMS.Enabled = true;
             btnSendSMS.Enabled     = true;
         }
         else
         {
             btnConnect.Text        = "CONNECT";
             tmrSendSMS.Enabled     = false;
             btnClose.Enabled       = true;
             btnReceivedSMS.Enabled = true;
             lbl_phone_status.Text  = "DISCONNECT";
             btnClose.Enabled       = true;
             ModemCommunication.Close();
         }
     }
     catch (Exception ex)
     {
         LogFile(ex.Message, e.ToString(), ((Control)sender).Name, this.FindForm().Name);
     }
 }
Beispiel #2
0
        private void btnTestConnect_Click(object sender, EventArgs e)
        {
            Port_Configured();
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                ModemCommunication.Open();
                while (!ModemCommunication.IsConnected())
                {
                    Cursor.Current = Cursors.Default;
                    if (MessageBox.Show(this, "No Phone Connectd.", "Connected Setup", MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation) == DialogResult.Cancel)
                    {
                        ModemCommunication.Close();
                        return;
                    }
                    Cursor.Current = Cursors.WaitCursor;
                }
                ModemCommunication.Close();
            }
            catch (Exception ex)
            {
                LogFile(ex.Message, e.ToString(), ((Control)sender).Name, this.FindForm().Name);
                MessageBox.Show(this, "Connection error:" + ex.Message, "Connection Setup", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            MessageBox.Show(this, "Successfully Connection to the phone.", "Connection Setup", MessageBoxButtons.OK, MessageBoxIcon.Information);
            btnConnect.Enabled = true;
        }
Beispiel #3
0
 public void Port_Configured()
 {
     ModemCommunication.Com_Port     = SMS_Constant.Modem_Port;      //Convert.ToInt32(cmbComPortNo.Text);
     ModemCommunication.Com_BaudRate = SMS_Constant.Modem_BraudRate; //Convert.ToInt32(cmbBaudRate.Text);
     ModemCommunication.Com_TimeOut  = SMS_Constant.Modem_TimeOut;   //Convert.ToInt32(cmbTimeout.Text);
     ModemCommunication.Initialization();
 }
Beispiel #4
0
 private void MessageReceived()
 {
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         ModemCommunication mdmObj = new ModemCommunication();
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #5
0
        //private void Phone_Connection()
        //{
        //    Port_Configured();
        //    ModemCommunication.gsObj.PhoneConnected += new EventHandler(Comm_PhoneConnected);
        //    Cursor.Current = Cursors.WaitCursor;
        //    bool retry;
        //    do
        //    {
        //        retry = false;
        //        try
        //        {
        //            Cursor.Current = Cursors.WaitCursor;
        //            ModemCommunication.Open();
        //            Cursor.Current = Cursors.Default;
        //        }
        //        catch (Exception)
        //        {
        //            Cursor.Current = Cursors.Default;
        //            if (MessageBox.Show(this, "Unable to open the port.", "Error",
        //                MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning) == DialogResult.Retry)
        //                retry = true;
        //            else
        //            {
        //                Close();
        //                return;
        //            }
        //        }
        //    }
        //    while (retry);

        //}
        private void Phone_Connection()
        {
            Port_Configured();
            ModemCommunication.gsObj.PhoneConnected += new EventHandler(Comm_PhoneConnected);
            bool retry;

            ModemCommunication.Open();
            //do
            //{
            //    retry = false;
            //    try
            //    {


            //    }
            //    catch (Exception)
            //    {
            //        retry = true;
            //    }
            //}
            //while (retry);
        }
Beispiel #6
0
 private void btnClose_Click(object sender, EventArgs e)
 {
     this.Close();
     ModemCommunication.Close();
 }