コード例 #1
0
ファイル: Grant_privs.cs プロジェクト: dbhuy2268/bvien
        private void dataGridView3_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (dataGridView3.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
                {
                    dataGridView3.CurrentRow.Selected = true;
                    string Granted_role = dataGridView3.Rows[e.RowIndex].Cells["GRANTED_ROLE"].FormattedValue.ToString();
                    string enabled      = dataGridView3.Rows[e.RowIndex].Cells["ENABLED"].FormattedValue.ToString();

                    string query;
                    if (enabled == "False")
                    {
                        query = "grant " + Granted_role + " to " + Cur_user;
                        Grant_Option go = new Grant_Option(this, 3, Cur_user, Cur_role, query);
                        go.ShowDialog();
                    }
                    else
                    {
                        query = "revoke " + Granted_role + " from " + Cur_user;
                        DBUtils dbu = new DBUtils();
                        if (dbu.ExecuteNonQuery(query))
                        {
                            this.LoadAllRole_ForGrantUser();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return;
            }
        }
コード例 #2
0
ファイル: Grant_privs.cs プロジェクト: dbhuy2268/bvien
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value != null)
                {
                    dataGridView1.CurrentRow.Selected = true;
                    string priv    = dataGridView1.Rows[e.RowIndex].Cells["PRIVILEGE"].FormattedValue.ToString();
                    string enabled = dataGridView1.Rows[e.RowIndex].Cells["ENABLED"].FormattedValue.ToString();

                    if (flag == 1)
                    {
                        if (enabled == "False")
                        {
                            string query = "grant " + priv + " to " + Cur_user;
                            Form   go    = new Grant_Option(this, 1, Cur_user, Cur_role, query);
                            go.ShowDialog();
                        }
                        else
                        {
                            string    query = "revoke " + priv + " from " + Cur_user;
                            DBUtils   dbu   = new DBUtils();
                            DataTable dt    = dbu.ExecuteQuery(query);
                            LoadAllUserSysPriv_gridView();
                            this.privcs.LoadUserSysPriv_gridView();
                        }
                    }

                    else
                    {
                        if (enabled == "False")
                        {
                            string query = "grant " + priv + " to " + Cur_role;
                            Form   go    = new Grant_Option(this, 2, Cur_user, Cur_role, query);
                            go.Show();
                        }
                        else
                        {
                            string    query = "revoke " + priv + " from " + Cur_role;
                            DBUtils   dbu   = new DBUtils();
                            DataTable dt    = dbu.ExecuteQuery(query);
                            LoadAllRoleSysPriv_gridView();
                            this.privcs.LoadRoleSysPriv_gridView();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return;
            }
        }