示例#1
0
 private void ConnectDisconnetEnabled(SqlServer sqlServer)
 {
     if (sqlServer != null)
     {
         menuServerDisconnect.Enabled = true;
         menuServerConnect.Enabled    = false;
         Roles();
         lblStatus.Text = DataConnection.DataBaseName + "  Сервер: " + DataConnection.Ip + "; Порт: " + DataConnection.Port;
     }
     else
     {
         DataConnection.UserType = "";
         Roles();
         menuServerDisconnect.Enabled = false;
         menuServerConnect.Enabled    = true;
         lblStatus.Text = lblStatus.Tag.ToString();
     }
 }
示例#2
0
        private void Login(string user, string password, string userType, string server, string port)
        {
            string query = "SELECT * FROM Security s WHERE s.[Login] = '" +
                           user + "' AND s.Password = '******'";

            int rowsCount;

            do
            {
                var identity = SqlServer.SelectDataTable(query);
                rowsCount = identity.Rows.Count;
            } while (SqlServer.SqlError());

            try
            {
                if (rowsCount == 1)
                {
                    DataConnection.UserType = userType;
                    DataConnection.User     = user;
                    DataConnection.Password = password;
                    DataConnection.Ip       = server;
                    DataConnection.Port     = port;
                    MessageBox.Show("Успешное подключение!");
                    Close();
                }
                else if (rowsCount <= 0)
                {
                    MessageBox.Show(@"Имя пользователя или пароль некорректны!");
                }
            }

            catch (SqlException exception)
            {
                MessageBox.Show(exception.Message, @"Ошибка");
                SqlServer = null;
            }

            finally
            {
                txtUserName.Clear();
                txtPassword.Clear();
            }
        }
示例#3
0
 public FormPatients(SqlServer sqlServer)
 {
     InitializeComponent();
     _sqlServer = sqlServer;
 }