Пример #1
0
        private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult reply = MessageBox.Show(this, "Are you sure you want to close the server?", "Close?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (reply == DialogResult.No)
            {
                e.Cancel = true;
            }
            else
            {
                // Add closing of sockets and stuff here!
                _server.Stop();
                DatabaseCommunication.Disconnect();
            }
        }
Пример #2
0
 private void btnSqlConnect_Click(object sender, EventArgs e)
 {
     tbxSqlUser.ReadOnly     = !tbxSqlUser.ReadOnly;
     tbxSqlPassword.ReadOnly = !tbxSqlPassword.ReadOnly;
     tbxSqlAddress.ReadOnly  = !tbxSqlAddress.ReadOnly;
     nudSqlPort.Enabled      = !nudSqlPort.Enabled;
     btnSqlTest.Enabled      = !btnSqlTest.Enabled;
     if (DatabaseCommunication.Active)
     {
         DatabaseCommunication.Disconnect();
         btnSqlConnect.Text = "Start Database Connection";
         tabSqlTest.Parent  = null;
     }
     else
     {
         DatabaseCommunication.Connect(tbxSqlUser.Text, tbxSqlPassword.Text, tbxSqlAddress.Text, (int)nudSqlPort.Value);
         btnSqlConnect.Text = "Stop Database Connection";
         tabSqlTest.Parent  = tabControl1;
     }
     UpdateServerStatus();
 }