Example #1
0
 private void UsersAdd_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (this.edit == true)
     {
         UserView vv = new UserView();
         vv.Show();
         vv.TopMost = true;
     }
 }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (txtUser.Text == "" || txtPass.Text == "" || cmbPerm.Text == "")
            {
                MessageBox.Show("Fill up all forms!");
            }
            else
            {
                if (txtPass.Text != txtRePass.Text)
                {
                    MessageBox.Show("Password Mismatched!");
                }
                else
                {
                    connect.Open();
                    SqlCommand     cmd = new SqlCommand("SELECT * FROM security WHERE username = '******'", connect);
                    SqlDataAdapter da  = new SqlDataAdapter(cmd);
                    DataTable      dt  = new DataTable();
                    da.Fill(dt);
                    connect.Close();
                    if (dt.Rows.Count > 0)
                    {
                        MessageBox.Show("User exist!");
                    }
                    else
                    {
                        try {
                            SqlDataAdapter sda = new SqlDataAdapter();
                            sda.InsertCommand = new SqlCommand("INSERT INTO security (fullname, username, password, type) VALUES (@fullname, @user, @pass, @type)", connect);
                            sda.InsertCommand.Parameters.Add("@fullname", SqlDbType.VarChar).Value = txtFullName.Text;
                            sda.InsertCommand.Parameters.Add("@user", SqlDbType.VarChar).Value     = txtUser.Text;
                            sda.InsertCommand.Parameters.Add("@pass", SqlDbType.VarChar).Value     = txtPass.Text;
                            sda.InsertCommand.Parameters.Add("@type", SqlDbType.VarChar).Value     = cmbPerm.Text;
                            connect.Open();
                            sda.InsertCommand.ExecuteNonQuery();
                            connect.Close();
                        } catch (Exception ex) {
                            MessageBox.Show(ex.Message);
                        }
                        this.Close();

                        UserView cv = new UserView();
                        cv.Show();
                        MessageBox.Show("New user added!");
                    }
                }
            }
        }
Example #3
0
        private void viewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UserView user = new UserView();

            user.Show();
        }