예제 #1
0
파일: ConnectForm.cs 프로젝트: operki/Base
 private void ConnectToBD(bool isUser)
 {
     try
     {
         if (!_connectCan)
         {
             return;
         }
         //соединение с базой данных
         if (_sqlConnection == null)
         {
             _sqlConnectionString = "Data Source=" + tbConnectBD.Text +
                                    ";Initial Catalog=DatabasePeopleMain;User ID=sa;Password=operki1991";
             _sqlConnection = new SqlConnection(_sqlConnectionString);
             _sqlConnection.Open();
         }
         if (!isUser)
         {
             //_userName = "******";
             //_userRights = new[] {0, 0, 0, 0, 0};
             var terminalForm = new TerminalForm(_sqlConnectionString);
             Hide();
             terminalForm.Show(this);
         }
         else
         {
             var userIndex = lbUserNames.SelectedIndex;
             if (lbUserPasswords.Items[lbUserNames.SelectedIndex].ToString() != tbUserPass.Text)
             {
                 userIndex = -1;
             }
             if (userIndex < 0)
             {
                 bConnectBD.Text      = "        Неверный пароль";
                 bConnectBD.BackColor = Color.FromArgb(255, 13, 0);
                 tPass.Enabled        = true;
                 _connectCan          = false;
                 return;
             }
             _userName = lbUserNames.Text;
             SetUser();
             //экран добавления человека
             var startForm = new StartForm(_sqlConnectionString, _userName, _userRights);
             startForm.LoadFromConnect();
             Hide();
             startForm.Show(this);
         }
     }
     finally
     {
         _sqlReader?.Close();
     }
 }
예제 #2
0
        private void backbtn_Click(object sender, EventArgs e)
        {
            tabControl.Visible = false;

            UserNametb.Visible = true;
            label7.Visible     = true;
            label6.Visible     = true;
            SignInbtn.Visible  = true;
            Passwordtb.Visible = true;
            //StartForm s = new StartForm();
            s.Show();
            this.Hide();
        }