public Choose_Priv_Type(ChucNang_form form) { MainForm = form; DataTable const_dt = new DataTable(); const_dt.Columns.Add(new DataColumn("PRIV TYPE", Type.GetType("System.String"))); DataRow dr = const_dt.NewRow(); dr["PRIV TYPE"] = "SELECT"; const_dt.Rows.Add(dr); dr = const_dt.NewRow(); dr["PRIV TYPE"] = "UPDATE"; const_dt.Rows.Add(dr); dr = const_dt.NewRow(); dr["PRIV TYPE"] = "DELETE"; const_dt.Rows.Add(dr); dr = const_dt.NewRow(); dr["PRIV TYPE"] = "INSERT"; const_dt.Rows.Add(dr); InitializeComponent(); Priv_Type_datagridview.DataSource = const_dt; Priv_Type_datagridview.ReadOnly = true; Priv_Type_datagridview.AllowUserToAddRows = false; //Priv_Type_datagridview.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; //Priv_Type_datagridview.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; //Priv_Type_datagridview.AutoResizeColumns(); //Priv_Type_datagridview.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; }
public Choose_Table(ChucNang_form form, string Priv_Type) { this.Priv_Type = Priv_Type; MainForm = form; InitializeComponent(); label1.Text = "CHON BANG DE GRANT QUYEN " + Priv_Type + ": "; All_Table_dataGridView.DataSource = Oracle.Get_All_Table(MainForm.Login_Form.conn); All_Table_dataGridView.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; All_Table_dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; All_Table_dataGridView.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; }
private void button1_Click(object sender, EventArgs e) { try { string username = f_DangNhap_Username_textbox.Text; string password = f_DangNhap_Password_textbox.Text; //Oracle db = new Oracle(); //MainForm = new ChucNang_form(); conn = Oracle.CreateDBConnection(username, password); LogedIn_Username = username; //MainForm.username = f_DangNhap_Username_textbox.Text; MessageBox.Show("Da dang nhap voi username:"******"Error: " + er); } }
public Choose_Priv(ChucNang_form form, string Priv_Type, string table_name = "") { MainForm = form; this.Priv_type = Priv_Type; this.Table_name = table_name; InitializeComponent(); label1.Text = "CHON PRIVILEGES " + Priv_Type + " DE GRANT CHO USER TRONG BANG " + table_name + ": "; if (Priv_Type == "SELECT" || Priv_Type == "UPDATE") //SELECT, UPDATE { name_without_owner = table_name.Split('.')[1]; //name_without_owner = table_name.Split('.')[1]; DataTable Col = Oracle.Get_All_Col(MainForm.Login_Form.conn, name_without_owner); Col.Columns.Add("ENABLED", Type.GetType("System.Boolean")); Col.Columns.Add("WITH GRANT OPTION", Type.GetType("System.Boolean")); foreach (DataRow dr1 in Col.Rows) { dr1["WITH GRANT OPTION"] = false; dr1["ENABLED"] = false; } DataTable Priv_user = Oracle.GetPriv_One_User_2(MainForm.Login_Form.conn, MainForm.username, Priv_Type, name_without_owner); if (Priv_Type == "SELECT") { Select_Priv_Preprocessing(Priv_user); } foreach (DataRow dr in Priv_user.Rows) { foreach (DataRow dr1 in Col.Rows) { if (dr["COLUMN_NAME"].ToString() == dr1["COLUMN_NAME"].ToString()) { if (dr["GRANTABLE"].ToString() == "NO") { dr1["WITH GRANT OPTION"] = false; } else { dr1["WITH GRANT OPTION"] = true; } dr1["ENABLED"] = true; break; } } } Priv_dataGridView.DataSource = Col; } else // INSERT, DELETE { //string name = MainForm.username; DataTable All_tables = Oracle.Get_All_Table(MainForm.Login_Form.conn); All_tables.Columns.Add("ENABLED", Type.GetType("System.Boolean")); All_tables.Columns.Add("WITH GRANT OPTION", Type.GetType("System.Boolean")); foreach (DataRow dr1 in All_tables.Rows) { dr1["WITH GRANT OPTION"] = false; dr1["ENABLED"] = false; } DataTable Priv_user = Oracle.GetPriv_One_User_2(MainForm.Login_Form.conn, MainForm.username, Priv_Type, table_name); foreach (DataRow dr in Priv_user.Rows) { foreach (DataRow dr1 in All_tables.Rows) { if (dr["OBJECT_NAME"].ToString() == dr1["TABLE_NAME"].ToString() && dr["OWNER"].ToString() == dr1["OWNER"].ToString()) { if (dr["GRANTABLE"].ToString() == "NO") { dr1["WITH GRANT OPTION"] = false; } else { dr1["WITH GRANT OPTION"] = true; } dr1["ENABLED"] = true; break; } } } Priv_dataGridView.DataSource = All_tables; //DataTable User_Priv = Oracle.GetPriv_One_User_2(MainForm.Login_Form.conn, name, ); } }
public FormCreateUserRole(ChucNang_form form) { MainForm = form; InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { try { string username = f_DangNhap_Username_textbox.Text; username = username.ToLower(); string password = f_DangNhap_Password_textbox.Text; //Oracle db = new Oracle(); //MainForm = new ChucNang_form(); LogedIn_Username = username; //MainForm.username = f_DangNhap_Username_textbox.Text; //MessageBox.Show("Da dang nhap voi username:"******"sy") == true || username.StartsWith("dba") == true) { conn = Oracle.CreateDBConnection(username, password); ChucNang_form MainFrom = new ChucNang_form(this); MainFrom.Show(); } if (username.StartsWith("tt") == true) { conn = TiepTan.CreateDBConnection(username, password); try { // conn.Open(); FormTiepTan tieptan = new FormTiepTan(this); tieptan.Show(); } catch { MessageBox.Show("Đăng nhập thất bại!"); } } if (username.StartsWith("kt") == true) { conn = Oracle.CreateDBConnection(username, password); conn.Open(); FormKeToan ketoan = new FormKeToan(this); ketoan.Show(); } if (username.StartsWith("bs") == true) { conn = BacSi.CreateDBConnection(username, password); try { conn.Open(); FormBacSi bacsi = new FormBacSi(this); bacsi.Show(); } catch { MessageBox.Show("Đăng nhập thất bại!"); } } if (username.StartsWith("bt") == true) { conn = BacSi.CreateDBConnection(username, password); try { FormBanThuoc bt = new FormBanThuoc(this); bt.Show(); } catch { MessageBox.Show("Đăng nhập thất bại!"); } } if (username.StartsWith("tv") == true) { conn = TaiVu.CreateDBConnection(username, password); try { conn.Open(); FormTaiVu f_tv = new FormTaiVu(this); f_tv.Show(); //this.Hide(); } catch (Exception ex) { MessageBox.Show("Đăng nhập thất bại!"); } } if (username.StartsWith("ql002") == true) { conn = TaiVu.CreateDBConnection(username, password); try { conn.Open(); FormQuanLiTaiVu f_qltv = new FormQuanLiTaiVu(this); f_qltv.Show(); //this.Hide(); } catch (Exception ex) { MessageBox.Show("Đăng nhập thất bại!"); } } if (username.StartsWith("ql001") == true) { conn = QuanLy.CreateDBConnection(username, password); try { conn.Open(); QLTNNS f_qltnns = new QLTNNS(this); f_qltnns.Show(); //this.Hide(); } catch (Exception ex) { MessageBox.Show("Đăng nhập thất bại!"); } } if (username.StartsWith("ql003") == true) { conn = QuanLy.CreateDBConnection(username, password); try { conn.Open(); QLCM f_qlcm = new QLCM(this); f_qlcm.Show(); //this.Hide(); } catch (Exception ex) { MessageBox.Show("Đăng nhập thất bại!"); } } } catch (Exception er) { MessageBox.Show("Error: " + er); } }