private void btnUpdate_Click(object sender, EventArgs e) { BLL.Quyen_BLL quyenBLL = new BLL.Quyen_BLL(); foreach (quyen item in listQuyen) { quyenBLL.removeQuyenHT(item.name, role); } foreach (DataGridViewRow row in dataGridView1.Rows) { bool chk = (bool)row.Cells[1].Value; bool grant = (bool)row.Cells[2].Value; if (chk) { quyen quyen; if (grant) { quyen = new quyen(row.Cells[0].Value.ToString(), "1"); } else { quyen = new quyen(row.Cells[0].Value.ToString(), "-1"); } quyens.Add(quyen); } } foreach (quyen item in quyens) { quyenBLL.updateHT(role, item.name, item.grant); } MessageBox.Show("Thanh Cong"); }
private void btnUpdate_Click(object sender, EventArgs e) { BLL.Quyen_BLL quyenBLL = new BLL.Quyen_BLL(); quyenBLL.removeQuyenTable(cbTable.SelectedItem.ToString(), username); foreach (DataGridViewRow row in dataGridView1.Rows) { bool chk = (bool)row.Cells[1].Value; if (chk) { quyen quyen; quyen = new quyen(row.Cells[0].Value.ToString(), "-1"); quyens.Add(quyen); } } foreach (quyen item in quyens) { quyenBLL.updateTable(username, item.name, item.grant, cbTable.SelectedItem.ToString()); } MessageBox.Show("Thanh Cong"); }
private void QUYEN_HT_Load(object sender, EventArgs e) { DataGridViewTextBoxColumn dgvName = new DataGridViewTextBoxColumn(); dgvName.HeaderText = "Name"; DataGridViewCheckBoxColumn dgvSelect = new DataGridViewCheckBoxColumn(); dgvSelect.HeaderText = "Select"; DataGridViewCheckBoxColumn dgvGrant = new DataGridViewCheckBoxColumn(); dgvGrant.HeaderText = "Grant"; dataGridView1.Columns.Add(dgvName); dataGridView1.Columns.Add(dgvSelect); dataGridView1.Columns.Add(dgvGrant); BLL.Quyen_BLL quyen_BLL = new BLL.Quyen_BLL(); DataTable role_quyen = quyen_BLL.getQuyenHT(role); DataTable quyenTable = quyen_BLL.getByType1(); foreach (DataRow row in quyenTable.Rows) { bool select = false; bool grant = false; foreach (DataRow row1 in role_quyen.Rows) { if (row.ItemArray[0].ToString().ToUpper().Equals(row1.ItemArray[0].ToString().ToUpper())) { select = true; if (row1.ItemArray[1].ToString().Equals("YES")) { grant = true; } quyen quyen = new quyen(row.ItemArray[0].ToString(), grant ? "1" : "-1"); listQuyen.Add(quyen); } } dataGridView1.Rows.Add(row.ItemArray[0].ToString(), select, grant); } dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView1.AllowUserToAddRows = false; }