private void deleteUserDutyFromModuleText(string moduleName) { /* 删除该用户此module对应的所有权限 * 1、根据moduleText得到moduleID * 2、得到ModuleID对应的所有Action的ID * 3、根据当前用户ID和acitonID,删除BASE_ACTION_STAFF对应的记录 */ int moduleID = SystemModule.getInctance().getModuleIDFromModuleName(moduleName); ArrayList actions = MainProgram.model.Action.getInctance().getAllActionPkeyFromModuleID(moduleID); for (int i = 0; i < actions.Count; i++) { ActionAndStaff.getInctance().delete(Staff.getInctance().getStaffPkeyFromName(m_userName), (int)actions[i]); } }
private void updateDataGridViewAction(SortedDictionary <int, ArrayList> data) { // 数据初始化 for (int rowIndex = 0; rowIndex < m_dataGridViewActionRowCount; rowIndex++) { ArrayList temp = new ArrayList(); temp = (ArrayList)data[rowIndex]; for (int columnIndex = 0; columnIndex < temp.Count; columnIndex++) { dataGridViewActionList.Rows[rowIndex].Cells[columnIndex + 1] = new DataGridViewCheckBoxCellExtend(temp[columnIndex].ToString()); dataGridViewActionList.Rows[rowIndex].Height = 19; } for (int i = temp.Count; i < m_dataGridViewActionColumnCount; i++) { dataGridViewActionList.Rows[rowIndex].Cells[i + 1] = new DataGridViewCheckBoxCellExtend(""); dataGridViewActionList.Rows[rowIndex].Height = 19; } } // 查询数据库,把该用户已有的权限响应的复选框中打上勾 for (int rowIndex = 0; rowIndex < m_dataGridViewActionRowCount; rowIndex++) { string moduleText = this.dataGridViewActionList.Rows[rowIndex].Cells[0].Value.ToString(); for (int columnIndex = 1; columnIndex < m_dataGridViewActionColumnCount; columnIndex++) { DataGridViewCheckBoxCellExtend dataGridViewCheckBoxCell; dataGridViewCheckBoxCell = (DataGridViewCheckBoxCellExtend)this.dataGridViewActionList.Rows[rowIndex].Cells[columnIndex]; string checkBoxText = dataGridViewCheckBoxCell.getCheckText(); if (checkBoxText.Length > 0) { int actionID = MainProgram.model.Action.getInctance().getActionPkey(moduleText, checkBoxText); if (ActionAndStaff.getInctance().isAccess(Staff.getInctance().getStaffPkeyFromName(m_userName), actionID)) { this.dataGridViewActionList.Rows[rowIndex].Cells[columnIndex].Value = true; } } } } }
private void insertActionAndStaffTableData(string moduleText, int rowIndex, int columnIndex) { string checkBoxText; DataGridViewCheckBoxCellExtend dataGridViewCheckBoxCell; dataGridViewCheckBoxCell = (DataGridViewCheckBoxCellExtend)this.dataGridViewActionList.Rows[rowIndex].Cells[columnIndex]; checkBoxText = dataGridViewCheckBoxCell.getCheckText(); if (checkBoxText.Length > 0) { int actionID = MainProgram.model.Action.getInctance().getActionPkey(moduleText, checkBoxText); if (this.dataGridViewActionList.Rows[rowIndex].Cells[columnIndex].EditedFormattedValue.ToString().CompareTo("True") == 0) { AtionAndStaffTable record = new AtionAndStaffTable(); record.actionID = actionID; record.staffID = Staff.getInctance().getStaffPkeyFromName(m_userName); ActionAndStaff.getInctance().insert(record); } } }