Exemple #1
0
        private void buttonBack_Click(object sender, EventArgs e)
        {
            this.Hide();
            FormUser info = new FormUser();

            info.Visible       = true;
            info.ShowInTaskbar = true;
        }
Exemple #2
0
        private void buttonUpDate_Click(object sender, EventArgs e)
        {
            if (textBoxLogin.Text != "" && textBoxPassword.Text != "" && textBoxName.Text != "" && textBoxRoled.Text != "")
            {
                using (SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=I001;User ID=student;Password=Passw0rd"))
                {
                    try
                    {
                        con.Open();
                        SqlCommand cmd = con.CreateCommand();
                        cmd.CommandText = "UPDATE [users] SET name='" + textBoxName.Text + "', login ='******', password='******', isadmin='" + textBoxRoled.Text + "' Where [users].id=" + ID;
                        cmd.ExecuteScalar();
                        con.Close();

                        this.Hide();
                        FormUser info = new FormUser();
                        info.Visible       = true;
                        info.ShowInTaskbar = true;
                    }
                    catch (Exception ex)
                    {
                        //if ("-2146232060" == Convert.ToString(ex.HResult))
                        //{
                        //    MessageBox.Show("Логин занят");
                        //}

                        //else
                        //{
                        //    MessageBox.Show(Convert.ToString(ex));
                        //}
                    }
                }
            }
            else
            {
                MessageBox.Show("Заполните все поля");
            }
        }