Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int role = Convert.ToInt32(roleBox.SelectedIndex) + 1;

            using (SqlConnection sc = new SqlConnection())
            {
                sc.ConnectionString = @"Data Source=DESKTOP-43BJ3R7\SQLEXPRESS;Initial Catalog=uchet;Integrated Security=True";
                sc.Open();

                using (SqlCommand com = sc.CreateCommand())
                {
                    com.CommandText = (@"insert into users (name, password, id_role) values(@name, @password, @role)");


                    com.Parameters.Add("@name", SqlDbType.NChar, 255).Value    = logBox.Text;
                    com.Parameters.Add("@password", SqlDbType.NChar, 12).Value = passBox.Text;
                    com.Parameters.Add("@role", SqlDbType.Int).Value           = role;

                    com.ExecuteNonQuery();
                }
                sc.Close();
            }



            FormUsers FormUsers = new FormUsers();

            FormUsers.dataGridView1.Refresh();
            this.Close();
            FormUsers.Show();
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (SqlConnection sc = new SqlConnection())
            {
                sc.ConnectionString = @"Data Source=DESKTOP-43BJ3R7\SQLEXPRESS;Initial Catalog=uchet;Integrated Security=True";
                sc.Open();

                using (SqlCommand com = sc.CreateCommand())
                {
                    com.CommandText = (@"update users set name = @username, password = @pass where id_user = @idUser");


                    com.Parameters.Add("@idUser", SqlDbType.Int).Value          = idUser;
                    com.Parameters.Add("@username", SqlDbType.NChar, 255).Value = loginText.Text;
                    com.Parameters.Add("@pass", SqlDbType.NChar, 12).Value      = passText.Text;

                    com.ExecuteNonQuery();
                }
                sc.Close();
            }
            this.Close();
            FormUsers FormUsers = new FormUsers();

            FormUsers.Show();
        }
Esempio n. 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
            FormUsers FormUsers = new FormUsers();

            FormUsers.Show();
        }
Esempio n. 4
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            mainForm       mainForm   = new mainForm();
            FormUsers      formUsers  = new FormUsers();
            SqlConnection  connection = new SqlConnection();
            SqlCommand     comand     = new SqlCommand();
            SqlDataAdapter adaptor    = new SqlDataAdapter();
            DataSet        dataset    = new DataSet();


            connection.ConnectionString = (@"Data Source=DESKTOP-43BJ3R7\SQLEXPRESS;Initial Catalog=uchet;Integrated Security=True");
            comand.CommandText          = @"SELECT * FROM users WHERE name='" + loginbox.Text + "'AND password='******';";
            connection.Open();


            comand.Connection = connection;

            adaptor.SelectCommand = comand;
            adaptor.Fill(dataset, "0");
            int count = dataset.Tables[0].Rows.Count;

            if (count > 0)
            {
                SqlDataReader reader = comand.ExecuteReader();
                while (reader.Read())
                {
                    textBox1.Text = reader["id_role"].ToString();
                    role          = int.Parse(textBox1.Text);
                }
                if (role == 1)
                {
                    formUsers.Show();
                    this.Hide();
                }
                else
                {
                    mainForm.Show();
                    this.Hide();
                }
            }
            else
            {
                MessageBox.Show("Некоректный логин или пароль", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                loginbox.Clear();
                passbox.Clear();
            }
        }
Esempio n. 5
0
        private void newUser_FormClosed(object sender, FormClosedEventArgs e)
        {
            FormUsers FormUsers = new FormUsers();

            FormUsers.Show();
        }
Esempio n. 6
0
        private void UsersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormUsers formUsers = new FormUsers();

            formUsers.Show();
        }