/// <summary> /// Update Security Group information in securitygroups table from frmCreateSecurityGroup form. /// </summary> /// <returns></returns> public bool UpdateSecurityGroups(RBACD.DatalayerDef.sSecurityGroups securityGroupInfo) { OdbcTransaction tran = null; string sql = string.Empty; try { OdbcConnection con = (OdbcConnection)this.DbConnection; OdbcCommand cmd = new OdbcCommand(); cmd.CommandType = CommandType.Text; cmd.Connection = con; tran = con.BeginTransaction(); cmd.Transaction = tran; sql = "UPDATE rbac.securitygroups SET Name='" + securityGroupInfo.Name + "' , DisplayName='" + securityGroupInfo.DisplayName + "' WHERE SecurityGroupID ='" + securityGroupInfo.SecurityGroupID + "'"; cmd.CommandText = sql; cmd.ExecuteNonQuery(); tran.Commit(); return(true); } catch { if (tran != null) { tran.Rollback(); } return(false); } }
/// <summary> /// Retrieve all the Security Group info from securitygroup table /// </summary> /// <returns>Returns list of Security Group information</returns> public List <RBACD.DatalayerDef.sSecurityGroups> RetrieveSecurityGroup() { IDataReader ReturnValue; List <RBACD.DatalayerDef.sSecurityGroups> sgInfo = new List <RBACD.DatalayerDef.sSecurityGroups>(); // create a command object which we can use to retrive security group IDbCommand DbCommand = CreateCommandObject(DbConnection, "Select SecurityGroupID, Name, DisplayName from securitygroups"); try { // open the database, query for the security group ReturnValue = DbCommand.ExecuteReader(); } catch (Exception e) { throw new DataLayerException(GetString(DataAccessException)); } // if the return value is null then we did not find the security group if (ReturnValue != null) { while (ReturnValue.Read()) { RBACD.DatalayerDef.sSecurityGroups sg = new RBACD.DatalayerDef.sSecurityGroups(); sg.SecurityGroupID = ReturnValue[0].ToString(); sg.Name = ReturnValue[1].ToString(); sg.DisplayName = ReturnValue[2].ToString(); sgInfo.Add(sg); } } return(sgInfo); }
/// <summary> /// Save Security Group information in securitygroups table from frmCreateSecurityGroups form. /// </summary> /// <returns></returns> public bool SaveSecurityGroups(RBACD.DatalayerDef.sSecurityGroups securityGroupInfo) { OdbcTransaction tran = null; string sql = string.Empty; try { OdbcConnection con = (OdbcConnection)this.DbConnection; OdbcCommand cmd = new OdbcCommand(); cmd.CommandType = CommandType.Text; cmd.Connection = con; tran = con.BeginTransaction(); cmd.Transaction = tran; sql = "INSERT INTO rbac.securitygroups (Name, DisplayName) VALUES('" + securityGroupInfo.Name + "', '" + securityGroupInfo.DisplayName + "')"; cmd.CommandText = sql; cmd.ExecuteNonQuery(); tran.Commit(); return(true); } catch { if (tran != null) { tran.Rollback(); } return(false); } }
private void btnSave_Click(object sender, EventArgs e) { if (lvwSecurityGroup.SelectedIndices.Count > 0) { foreach (int i in lvwSecurityGroup.SelectedIndices) { RBACD.DatalayerDef.sSecurityGroups sg = sgInfo[i]; //MessageBox.Show(sg.Name); sgId.Add(sg.SecurityGroupID); } usrScuGruAgnInfo.SecurityGroupId = sgId; } if (dbl.SaveSecurityGroupsAssings(usrScuGruAgnInfo)) { lblMessage.Text = "Data saved successfully"; //MessageBox.Show("Data is saved"); } else { lblMessage.Text = "Error while saving the details"; lblMessage.ForeColor = System.Drawing.Color.Red; } }
private void cmdClear_Click(object sender, EventArgs e) { txtName.Text = ""; txtDisplayName.Text = ""; mode = RBAC.Utils.Constants.SAVE; securityGroupInfo = new RBACD.DatalayerDef.sSecurityGroups(); }
private void lvwSecurityGroup_DoubleClick(object sender, EventArgs e) { mode = RBAC.Utils.Constants.EDIT; if (lvwSecurityGroup.SelectedIndices.Count > 0) { int uIndex = lvwSecurityGroup.SelectedIndices[0]; securityGroupInfo = sgInfo[uIndex]; txtName.Text = securityGroupInfo.Name; txtDisplayName.Text = securityGroupInfo.DisplayName; } }
private void lvwSecurityGroup_DoubleClick(object sender, EventArgs e) { mode = RBAC.Utils.Constants.EDIT; if (lvwSecurityGroup.SelectedIndices.Count > 0) { int uIndex = lvwSecurityGroup.SelectedIndices[0]; securityGroupInfo = sgInfo[uIndex]; txtName.Text = securityGroupInfo.Name; txtDisplayName.Text = securityGroupInfo.DisplayName; } }
private void cmdClear_Click(object sender, EventArgs e) { txtName.Text = ""; txtDisplayName.Text = ""; mode = RBAC.Utils.Constants.SAVE; securityGroupInfo = new RBACD.DatalayerDef.sSecurityGroups(); }
/// <summary> /// Retrieve all the Security Group info from securitygroup table /// </summary> /// <returns>Returns list of Security Group information</returns> public List<RBACD.DatalayerDef.sSecurityGroups> RetrieveSecurityGroup() { IDataReader ReturnValue; List<RBACD.DatalayerDef.sSecurityGroups> sgInfo = new List<RBACD.DatalayerDef.sSecurityGroups>(); // create a command object which we can use to retrive security group IDbCommand DbCommand = CreateCommandObject(DbConnection, "Select SecurityGroupID, Name, DisplayName from securitygroups"); try { // open the database, query for the security group ReturnValue = DbCommand.ExecuteReader(); } catch (Exception e) { throw new DataLayerException(GetString(DataAccessException)); } // if the return value is null then we did not find the security group if (ReturnValue != null) { while (ReturnValue.Read()) { RBACD.DatalayerDef.sSecurityGroups sg = new RBACD.DatalayerDef.sSecurityGroups(); sg.SecurityGroupID = ReturnValue[0].ToString(); sg.Name = ReturnValue[1].ToString(); sg.DisplayName = ReturnValue[2].ToString(); sgInfo.Add(sg); } } return sgInfo; }