/// <summary>
        /// Adds new remote server for owner user.
        /// </summary>
        /// <param name="description">Remote server description.</param>
        /// <param name="host">Remote server host name or IP.</param>
        /// <param name="port">Remote server port.</param>
        /// <param name="ssl">Specifies if connected to remote server via SSL.</param>
        /// <param name="userName">Remote server user name.</param>
        /// <param name="password">Remote server password.</param>
        /// <param name="enabled">Specifies if remote server is enabled.</param>
        /// <returns></returns>
        public UserRemoteServer Add(string description,string host,int port,bool ssl,string userName,string password,bool enabled)
        {
            /* AddUserRemoteServer <virtualServerID> "<remoteServerID>" "<userName>" "<description>" "<remoteHost>" <remoteHostPort> "<remoteHostUserName>" "<remoteHostPassword>" <ssl> <enabled>
                  Responses:
                    +OK                     
                    -ERR <errorText>
            */

            string id = Guid.NewGuid().ToString();

            // Call TCP AddUserRemoteServer
            m_pUser.VirtualServer.Server.TcpClient.TcpStream.WriteLine("AddUserRemoteServer " + 
                m_pUser.VirtualServer.VirtualServerID + " " + 
                TextUtils.QuoteString(id) + " " + 
                TextUtils.QuoteString(m_pUser.UserName) + " " + 
                TextUtils.QuoteString(description) + " " + 
                TextUtils.QuoteString(host) + " " + 
                port + " " + 
                TextUtils.QuoteString(userName) + " " + 
                TextUtils.QuoteString(password) + " " +
                ssl + " " +
                enabled
            );
                        
            string response = m_pUser.VirtualServer.Server.ReadLine();
            if(!response.ToUpper().StartsWith("+OK")){
                throw new Exception(response);
            }

            UserRemoteServer server = new UserRemoteServer(m_pUser,this,id,description,host,port,ssl,userName,password,enabled);
            m_pServers.Add(server);
            return server;
        }
        //// <summary>
        /// Edit new constructor.
        /// </summary>
        /// <param name="user">Owner user.</param>
        /// <param name="remoteServer">User remote server to update.</param>
        public wfrm_User_RemoteServers_Server(User user,UserRemoteServer remoteServer)
        {
            m_pRemoteServer = remoteServer;

            InitUI();

            m_pDescription.Text = remoteServer.Description;
            m_pServer.Text = remoteServer.Host;
            m_pPort.Value = remoteServer.Port;
            m_pUser.Text = remoteServer.UserName;
            m_pPassword.Text = remoteServer.Password;
            m_UseSSL.Checked = remoteServer.SSL;
            m_pEnabled.Checked = remoteServer.Enabled;
        }
        /// <summary>
        /// Removes specified remote server.
        /// </summary>
        /// <param name="remoteServer">Remote server to remove.</param>
        public void Remove(UserRemoteServer remoteServer)
        {
            /* DeleteUserRemoteServer <virtualServerID> "<remoteServerID>"
             *    Responses:
             +OK
             *      -ERR <errorText>
             */

            string id = Guid.NewGuid().ToString();

            // Call TCP DeleteUserRemoteServer
            m_pUser.VirtualServer.Server.TcpClient.TcpStream.WriteLine("DeleteUserRemoteServer " + m_pUser.VirtualServer.VirtualServerID + " " + TextUtils.QuoteString(remoteServer.ID));

            string response = m_pUser.VirtualServer.Server.ReadLine();

            if (!response.ToUpper().StartsWith("+OK"))
            {
                throw new Exception(response);
            }

            m_pServers.Remove(remoteServer);
        }
        /// <summary>
        /// Adds new remote server for owner user.
        /// </summary>
        /// <param name="description">Remote server description.</param>
        /// <param name="host">Remote server host name or IP.</param>
        /// <param name="port">Remote server port.</param>
        /// <param name="ssl">Specifies if connected to remote server via SSL.</param>
        /// <param name="userName">Remote server user name.</param>
        /// <param name="password">Remote server password.</param>
        /// <param name="enabled">Specifies if remote server is enabled.</param>
        /// <returns></returns>
        public UserRemoteServer Add(string description, string host, int port, bool ssl, string userName, string password, bool enabled)
        {
            /* AddUserRemoteServer <virtualServerID> "<remoteServerID>" "<userName>" "<description>" "<remoteHost>" <remoteHostPort> "<remoteHostUserName>" "<remoteHostPassword>" <ssl> <enabled>
             *    Responses:
             +OK
             *      -ERR <errorText>
             */

            string id = Guid.NewGuid().ToString();

            // Call TCP AddUserRemoteServer
            m_pUser.VirtualServer.Server.TcpClient.TcpStream.WriteLine("AddUserRemoteServer " +
                                                                       m_pUser.VirtualServer.VirtualServerID + " " +
                                                                       TextUtils.QuoteString(id) + " " +
                                                                       TextUtils.QuoteString(m_pUser.UserName) + " " +
                                                                       TextUtils.QuoteString(description) + " " +
                                                                       TextUtils.QuoteString(host) + " " +
                                                                       port + " " +
                                                                       TextUtils.QuoteString(userName) + " " +
                                                                       TextUtils.QuoteString(password) + " " +
                                                                       ssl + " " +
                                                                       enabled
                                                                       );

            string response = m_pUser.VirtualServer.Server.ReadLine();

            if (!response.ToUpper().StartsWith("+OK"))
            {
                throw new Exception(response);
            }

            UserRemoteServer server = new UserRemoteServer(m_pUser, this, id, description, host, port, ssl, userName, password, enabled);

            m_pServers.Add(server);
            return(server);
        }
        /// <summary>
        /// Removes specified remote server.
        /// </summary>
        /// <param name="remoteServer">Remote server to remove.</param>
        public void Remove(UserRemoteServer remoteServer)
        {
            /* DeleteUserRemoteServer <virtualServerID> "<remoteServerID>"
                  Responses:
                    +OK                     
                    -ERR <errorText>
            */

            string id = Guid.NewGuid().ToString();

            // Call TCP DeleteUserRemoteServer
            m_pUser.VirtualServer.Server.TcpClient.TcpStream.WriteLine("DeleteUserRemoteServer " + m_pUser.VirtualServer.VirtualServerID + " " + TextUtils.QuoteString(remoteServer.ID));
                        
            string response = m_pUser.VirtualServer.Server.ReadLine();
            if(!response.ToUpper().StartsWith("+OK")){
                throw new Exception(response);
            }

            m_pServers.Remove(remoteServer);
        }
 private void m_pOk_Click(object sender, EventArgs e)
 {
     //--- Validate values ---------------------------//
     if(m_pServer.Text == ""){
         MessageBox.Show(this,"Please fill Server !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error);
         return;
     }
     if(m_pUser.Text == ""){
         MessageBox.Show(this,"Please fill User !","Error:",MessageBoxButtons.OK,MessageBoxIcon.Error);
         return;
     }
     //----------------------------------------------//
     
     // Add new user reomte server
     if(m_pRemoteServer == null){
         m_pRemoteServer = m_pOwnerUser.RemoteServers.Add(
             m_pDescription.Text,
             m_pServer.Text,
             (int)m_pPort.Value,
             m_UseSSL.Checked,
             m_pUser.Text,
             m_pPassword.Text,
             m_pEnabled.Checked                    
        );
     }
     // Update user remote server
     else{
         m_pRemoteServer.Enabled     = m_pEnabled.Checked;
         m_pRemoteServer.Description = m_pDescription.Text;                
         m_pRemoteServer.Host        = m_pServer.Text;
         m_pRemoteServer.Port        = (int)m_pPort.Value;
         m_pRemoteServer.SSL         = m_UseSSL.Checked;
         m_pRemoteServer.UserName    = m_pUser.Text;
         m_pRemoteServer.Password    = m_pPassword.Text;
         m_pRemoteServer.Commit();
     }
     
     this.DialogResult = DialogResult.OK;
     this.Close();
 }