public DataTable dialogServerInsert(String sqlEvent, String IDEventData = "")
        {
            const String KEY = "79B8242B-22A1-4AE8-B52B-D6A298B17AE2";

            switch (sqlEvent)
            {
            case "SEVER_START_MESSAGE":
                return(sqlMessageServer.dialogServerSendMessagePublic("EXECUTE _sp_DIALOG_SMS_SERVER_OPEN @KEY = '" + KEY + "'"));

            case "SERVER_NEW_CUSTOMER":
                return(sqlMessageServer.dialogServerSendMessagePublic("EXECUTE _sp_dialog_NEW_USER_LOGIN  @KEY = '" + KEY + "', @CustAppID	= 8,"+ IDEventData));

            case "SERVER_COMPLAINT":
                return(sqlMessageServer.dialogServerSendMessagePublic("EXECUTE _sp_DIALOG_SMS_SERVER_NEW_COMPLAINT @KEY = '" + KEY + "', " + IDEventData));

            case "SERVER_COMPLAINT_DEG":
                return(sqlMessageServer.dialogServerSendMessagePublic("EXECUTE _sp_DIALOG_SMS_SERVER_NEW_COMPLAINT_DEG @KEY = '" + KEY + "', " + IDEventData));

            case "SERVER_PASS_CHANGE":
                return(sqlMessageServer.dialogServerSendMessagePublic("EXECUTE _sp_DIALOG_SMS_SERVER_CHANGE_PASS @KEY = '" + KEY + "', " + IDEventData));

            case "SERVER_RESTART_PC":
                return(sqlMessageServer.dialogServerSendMessagePublic("EXECUTE _sp_DIALOG_SMS_SERVER_RESTART_PC @KEY = '" + KEY + "', " + IDEventData));
            }
            return(null);
        }
        public DataTable dialogServerInsert(String sqlEvent, String IDEventData = "")
        {
            const String KEY = "C8D918DB-296E-4105-A652-87A0B4BA3A65";

            switch (sqlEvent)
            {
            case "SEVER_START_MESSAGE":
                return(sqlMessageServer.dialogServerSendMessagePublic("EXECUTE _sp_DIALOG_SMS_SERVER_OPEN @KEY = '" + KEY + "'"));

            case "SERVER_NEW_CUSTOMER":
                return(sqlMessageServer.dialogServerSendMessagePublic("EXECUTE _sp_dialog_New_Login  @KEY = '', " + IDEventData));

            case "SERVER_COMPLAINT":
                return(sqlMessageServer.dialogServerSendMessagePublic("EXECUTE _sp_DIALOG_SMS_SERVER_NEW_COMPLAINT @KEY = '" + KEY + "', " + IDEventData));

            case "SERVER_PASS_CHANGE":
                return(sqlMessageServer.dialogServerSendMessagePublic("EXECUTE _sp_DIALOG_SMS_SERVER_CHANGE_PASS @KEY = '" + KEY + "', " + IDEventData));

            case "SERVER_RESTART_PC":
                return(sqlMessageServer.dialogServerSendMessagePublic("EXECUTE _sp_DIALOG_SMS_SERVER_RESTART_PC @KEY = '" + KEY + "', " + IDEventData));
            }
            return(null);
        }
 private String dialogOpenServer()
 {
     try
     {
         if (dialogServerSearchPort() != "")
         {
             const String   KEY = "79B8242B-22A1-4AE8-B52B-D6A298B17AE2";
             SqlConfigClass sqlMessageServerDataTable = new SqlConfigClass();
             DataTable      dt = sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_DIALOG_SMS_SERVER_OPEN @KEY = '" + KEY + "'");
             DataRow        dr = dt.Rows[0];
             if (dr["SUCCES"].ToString() == "1")
             {
                 _dialogServerSerialPort.Write("AT+CMGF=1\r");
                 System.Threading.Thread.Sleep(500);
                 _dialogServerSerialPort.Write("AT+CMGS=\"+" + dr["AdminNumber"].ToString() + "\"\r");
                 System.Threading.Thread.Sleep(1000);
                 _dialogServerSerialPort.Write("Server is started at " + DateTime.Now.ToString("h:mm:ss tt") + " on " + DateTime.Today.ToString("D") + "\r\rDialog Access Network Planning, \rWestern North Region." + (char)(26));
                 System.Threading.Thread.Sleep(1000);
                 _dialogServerSerialPort.Close();
             }
             return(_truePortName);
         }
     }
     catch (SqlException)
     {
         _dialogServerSerialPort.Close();
         MessageBox.Show("The Sql Server can't be opened. Check the internet connection and try again.", "Sql Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return("");
     }
     catch (Exception)
     {
         _dialogServerSerialPort.Close();
         MessageBox.Show("The message server serial port can't be opened. Check the com port and try again.", "Port Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return("");
     }
     _dialogServerSerialPort.Close();
     MessageBox.Show("The message server serial port can't be opened. Check the com port and try again.", "Port Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     return("");
 }
        public DataTable dialogServerInsert(String sqlEvent, String IDEventData = "")
        {
            switch (sqlEvent)
            {
            case "LOAD_APPLICATION":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_dialog_LOAD_APP_KEY @KEY ='" + IDEventData + "'"));

            case "LOGIN_USER_EXISTS":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_dialog_LOAD_LOGIN_APP_USER @APPUSER ='******'"));

            case "CREATE_APPLICATION_KEY":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_dialog_SAVE_APP_KEY " + IDEventData));


            case "TAB_LOAD_CUSTOMER_SMS":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_view_dialog_TAB_LOAD_CUSTOMER_SMS @KEY ='" + IDEventData + "'"));

            case "TAB_LOAD_CUSTOMER_NET":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_view_dialog_TAB_LOAD_CUSTOMER_NET @KEY ='" + IDEventData + "'"));

            case "TAB_LOAD_CUSTOMER_SEARCH":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_view_dialog_TAB_LOAD_CUSTOMER_SEARCH " + IDEventData));

            case "TAB_LOAD_CUSTOMER_SELECT":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("_sp_view_dialog_TAB_LOAD_CUSTOMER_SELECT " + IDEventData));



            case "TAB_LOAD_SMSCOMPLAINT":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_view_dialog_TAB_LOAD_SMSCOMPLAINT"));

            case "TAB_LOAD_COMPLAINT_SELECT":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_view_dialog_TAB_LOAD_COMPLAINT_SELECT @CompID ='" + IDEventData + "'"));

            case "TAB_LOAD_COMPLAINT_BITWEEN":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_view_dialog_TAB_LOAD_DIALOG_SITES_BITWEEN " + IDEventData + ""));


            case "TAB_LOAD_NETCOMPLAINT":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_view_dialog_TAB_LOAD_NETCOMPLAINT"));



            case "TAB_LOAD_DIALOG_SITES":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_view_dialog_TAB_LOAD_DIALOG_SITES"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_AM":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'AM%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_AN":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'AN%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_BA":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'BA%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_BD":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'BD%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_CM":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'CM%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_GA":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'GA%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_GM":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'GM%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_HA":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'HA%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_KA":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'KA%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_KE":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'KE%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_KI":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'KI%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_KL":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'KL%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_KU":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'KU%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_MA":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'MA%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_MO":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'MO%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_MR":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'MR%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_MT":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'MT%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_MU":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'MU%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_NU":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'NU%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_PO":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'PO%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_PU":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'PU%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_RA":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'RA%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_TR":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'TR%' ORDER BY Modified  DESC"));

            case "TAB_LOAD_DIALOG_SITES_LIKE_VA":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo._view_dialog_TAB_LOAD_DIALOG_SITES_LIKE WHERE SiteID LIKE 'VA%' ORDER BY Modified  DESC"));


            case "TAB_LOAD_DIALOG_ANTENNA":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_view_dialog_TAB_LOAD_DIALOG_ANTENNA " + IDEventData));



            case "TAB_LOAD_DIALOG_SECTOR_LIKE_GSM":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_view_dialog_TAB_LOAD_DIALOG_SECTOR_LIKE_GSM @SiteID	= '" + IDEventData + "'"));

            case "TAB_LOAD_DIALOG_SECTOR_LIKE_DCS":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_view_dialog_TAB_LOAD_DIALOG_SECTOR_LIKE_DCS @SiteID	= '" + IDEventData + "'"));

            case "TAB_LOAD_DIALOG_SECTOR_LIKE_3G":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_view_dialog_TAB_LOAD_DIALOG_SECTOR_LIKE_3G @SiteID	= '"+ IDEventData + "'"));

            case "TAB_LOAD_DIALOG_SECTOR_LIKE_4G":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_view_dialog_TAB_LOAD_DIALOG_SECTOR_LIKE_4G @SiteID	= '"+ IDEventData + "'"));



            case "TAB_LOAD_OTHER_SITES":
                return(sqlMessageServerDataTable.dialogServerSendMessagePublic("SELECT * FROM dbo.dialog_Customer WHERE CustName = 'Customer'"));
            }
            return(null);
        }
 private Boolean dialogOpenServer()
 {
     if (dialogServerSearchPort())
     {
         InitializePort();
         _dialogMessageServerSerialPort.PortName = _truePortName;
         _dialogMessageServerSerialPort.Open();
         if (_dialogMessageServerSerialPort.IsOpen)
         {
             try
             {
                 const String   KEY = "C8D918DB-296E-4105-A652-87A0B4BA3A65";
                 SqlConfigClass sqlMessageServerDataTable = new SqlConfigClass();
                 DataTable      dt = sqlMessageServerDataTable.dialogServerSendMessagePublic("EXECUTE _sp_DIALOG_SMS_SERVER_OPEN @KEY = '" + KEY + "'");
                 DataRow        dr = dt.Rows[0];
                 if (dr["SUCCES"].ToString() == "1")
                 {
                     _dialogMessageServerSerialPort.Write("AT+CMGF=1\r");
                     System.Threading.Thread.Sleep(300);
                     _dialogMessageServerSerialPort.Write("AT+CMGS=\"+" + dr["AdminNumber"].ToString() + "\"\r");
                     System.Threading.Thread.Sleep(500);
                     _dialogMessageServerSerialPort.Write("Server is started at " + DateTime.Now.ToString("h:mm:ss tt") + " on " + DateTime.Today.ToString("D") + "\r\rDialog Access Network Planning, \rWestern North Region." + (char)(26));
                     System.Threading.Thread.Sleep(1000);
                     _dialogMessageServerSerialPort.Write("AT+CMGF=1\r");
                     System.Threading.Thread.Sleep(150);
                     _dialogMessageServerSerialPort.Write("AT+CMGD=?\r");
                     System.Threading.Thread.Sleep(1000);
                     _dialogMessageServerSerialPort.Close();
                     return(true);
                 }
                 else if (dr["SUCCES"].ToString() == "0" || dr["ERROR"].ToString() == "1")
                 {
                     _dialogMessageServerSerialPort.Close();
                     _IsTruePortOK = false;
                     _PortMessage  = "401:\r\r" + dr["MESSAGE"].ToString();
                     return(false);
                 }
                 else
                 {
                     _dialogMessageServerSerialPort.Close();
                     _IsTruePortOK = false;
                     _PortMessage  = "402:\r\r" + "The Sql Server can't be opened. Check the internet connection and try again.";
                     return(false);
                 }
             }
             catch (Exception)
             {
                 _dialogMessageServerSerialPort.Close();
                 _IsTruePortOK = false;
                 _PortMessage  = "403:\r\r" + "The message server serial port can't be opened. Check the com port and try again. The GSM SIM 800A COM Port Warning.!";
                 return(false);
             }
         }
         else
         {
             _dialogMessageServerSerialPort.Close();
             _IsTruePortOK = false;
             _PortMessage  = "404:\r\r" + "The message server serial port can't be opened. Check the com port and try again. The GSM SIM 800A COM Port Warning.!";
             return(false);
         }
     }
     else
     {
         _dialogMessageServerSerialPort.Close();
         _IsTruePortOK = false;
         _PortMessage  = "405:\r\r" + "The message server serial port can't be opened. Check the com port and try again. The GSM SIM 800A COM Port Warning.!";
         return(false);
     }
 }