private void button3_Click(object sender, EventArgs e)
        {
            ГлавныйВход form = new ГлавныйВход();

            form.Show();
            this.Hide();
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textBox1.Text) || String.IsNullOrEmpty(textBox2.Text))
            {
                MessageBox.Show("Данные не введены");
            }
            else
            {
                string sql = @"Data Source=.\sqlexpress;Initial Catalog=СервисЦентр;Integrated Security=True";

                SqlConnection con = new SqlConnection(sql);
                try
                {
                    con.Open();
                    string        s   = "Select * from [Сотрудник] where Логин='" + textBox1.Text + "' and Пароль='" + textBox2.Text + "'";
                    SqlCommand    com = new SqlCommand(s, con);
                    SqlDataReader dr  = com.ExecuteReader();
                    string        name;
                    int           role;
                    if (dr.HasRows)
                    {
                        dr.Read();
                        name  = (string)dr["Имя_сотрудника"];
                        role  = (int)dr["Код_должности"];
                        role1 = role;

                        ГлавныйВход form = new ГлавныйВход();

                        form.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Недействительный логин или пароль!");
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("СЕРВЕР УПАЛ, ЧЕЛ", ex.Message);
                }
            }
        }