Exemplo n.º 1
0
        private void news_Click(object sender, EventArgs e)
        {
            string logins    = login.Text;
            string passwords = password.Text;
            string namess    = names.Text;

            if (logins != "" && passwords != "" && namess != "")
            {
                using (SqlConnection con = new SqlConnection(@"Data source=" + nameserver + ";Initial Catalog=crud_l001;Integrated Security=True;"))
                {
                    try
                    {
                        con.Open();
                        SqlCommand cmd = con.CreateCommand();
                        cmd.CommandText = "INSERT users (login, password, name) VALUES ('" + logins + "','" + passwords + "','" + namess + "')";
                        cmd.ExecuteScalar();
                        con.Close();

                        full_users uc = new full_users(nameserver);
                        Point      t  = new Point(0, 0);
                        uc.Location = t;
                        Application.OpenForms[0].Controls.Add(uc);
                        this.Parent.Controls.Remove(this);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Convert.ToString(ex));
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void otmena_Click(object sender, EventArgs e)
 {
     full_users uc = new full_users(nameserver);
     Point t = new Point(0, 0);
     uc.Location = t;
     Application.OpenForms[0].Controls.Add(uc);
     this.Parent.Controls.Remove(this);
 }
Exemplo n.º 3
0
        public glav()
        {
            InitializeComponent();
            full_users uc = new full_users();
            Point      t  = new Point(0, 0);

            uc.Location = t;
            this.Controls.Add(uc);
        }
Exemplo n.º 4
0
        private void news_Click(object sender, EventArgs e)
        {
            string logins    = login.Text;
            string passwords = password.Text;
            string namess    = names.Text;

            if (logins != "" && passwords != "" && namess != "")
            {
                using (SqlConnection con = new SqlConnection(@"Data source=.\SQLEXPRESS;Initial Catalog=crud_l001;User ID=user;Password=Passw0rd;"))
                {
                    try
                    {
                        con.Open();
                        SqlCommand cmd = con.CreateCommand();
                        cmd.CommandText = "UPDATE [users] SET login='******', password='******', name='" + namess + "' Where [users].id=" + id;
                        cmd.ExecuteScalar();
                        con.Close();

                        full_users uc = new full_users();
                        Point      t  = new Point(0, 0);
                        uc.Location = t;
                        Application.OpenForms[0].Controls.Add(uc);
                        this.Parent.Controls.Remove(this);
                    }
                    catch (Exception ex)
                    {
                        if ("-2146232060" == Convert.ToString(ex.HResult))
                        {
                            MessageBox.Show("Логин занят");
                        }
                        else
                        {
                            MessageBox.Show(Convert.ToString(ex));
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Заполните все поля");
            }
        }