public bool DeleteByRolesId(Roles roles, Database db, DbTransaction transaction) { DbCommand dbCommand = db.GetStoredProcCommand("usp_RoleRightsDelete"); db.AddInParameter(dbCommand, "@RolesId", DbType.Int32, roles.RolesId); db.ExecuteNonQuery(dbCommand, transaction); return true; }
private void LoadRoles() { UserMan.Roles roles= new UserMan.Roles(); roles.CompanyId = SessionManager.SessionHandler.LoggedUser.CompanyId; gvRoles.DataSource = roles.SelectAllDataset(); gvRoles.DataBind(); }
private void LoadRoles() { UserMan.Roles roles = new UserMan.Roles(); roles.CompanyId = SessionManager.SessionHandler.LoggedUser.CompanyId; gvRoles.DataSource = roles.SelectAllDataset(); gvRoles.DataBind(); }
public bool Delete(Roles roles) { Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING); DbCommand command = db.GetStoredProcCommand("usp_RolesDelete"); db.AddInParameter(command, "@RolesId", DbType.String, roles.RolesId); db.ExecuteNonQuery(command); return true; }
public bool InsertRoleRights(Roles roles, Database db, DbTransaction transaction) { DbCommand command = db.GetStoredProcCommand("usp_RoleRightsInsert"); db.AddInParameter(command, "@RolesId", DbType.String, roles.RolesId); db.AddInParameter(command, "@RightId", DbType.String, roles.RightId); db.AddInParameter(command, "@CreatedUser", DbType.Int32, roles.CreatedUser); db.ExecuteNonQuery(command, transaction); return true; }
protected bool UpdateData() { bool result = false; DbConnection connection = null; DbTransaction transaction = null; try { Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING); connection = db.CreateConnection(); connection.Open(); transaction = connection.BeginTransaction(); UserMan.Roles RolesObj = new UserMan.Roles(); RolesObj.RolesId = Convert.ToInt32(this.hdnRoleId.Value); RolesObj.RoleName = txtRoleName.Text.Trim(); RolesObj.RoleDescription = txtRoleDescription.Text.Trim(); RolesObj.CompanyId = Master.CurrentCompany.CompanyId; RolesObj.UpdatedUser = Master.LoggedUser.UsersId; if (RolesObj.Save(db, transaction)) { //Delete exiting role rights RolesObj.DeleteByRolesId(db, transaction); List <object> myList = gvRights.GetSelectedFieldValues("RightId"); if (myList.Count > 0) { for (int i = 0; i <= myList.Count - 1; i++) { RolesObj.RightId = Convert.ToInt32(myList[i].ToString()); RolesObj.SaveRoleRights(db, transaction); } } } transaction.Commit(); result = true; this.DisplayData(); System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowSuccessMessage('" + Messages.Save_Success + "')", true); } catch (System.Exception) { } return(result); }
protected void gvRoles_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { int i = gvRoles.FindVisibleIndexByKeyValue(e.Keys[gvRoles.KeyFieldName]); e.Cancel = true; UserMan.Roles roles = new UserMan.Roles(); roles.RolesId = (int)e.Keys[gvRoles.KeyFieldName]; if (roles.Delete()) { this.LoadRoles(); } }
protected void LoadRoles() { try { UserMan.Roles roles = new UserMan.Roles(); ddlRoles.ValueField = "RolesId"; ddlRoles.TextField = "RoleName"; roles.CompanyId = Master.CurrentCompany.CompanyId; ddlRoles.DataSource = roles.SelectAllDataset(); ddlRoles.DataBind(); } catch (System.Exception) { } }
public bool Insert(Roles roles, Database db, DbTransaction transaction) { DbCommand command = db.GetStoredProcCommand("usp_RolesInsert"); db.AddInParameter(command, "@CompanyId", DbType.Int32, roles.CompanyId); db.AddInParameter(command, "@RoleName", DbType.String, roles.RoleName); db.AddInParameter(command, "@RoleDescription", DbType.String, roles.RoleDescription); db.AddInParameter(command, "@CreatedUser", DbType.Int32, roles.CreatedUser); db.AddOutParameter(command, "@RolesId", DbType.Int32, 8); db.ExecuteNonQuery(command, transaction); roles.RolesId = Convert.ToInt32(db.GetParameterValue(command, "@RolesId").ToString()); return true; }
protected void DisplayData() { try { int currentRoleId = Convert.ToInt32(this.hdnRoleId.Value); UserMan.Roles RolesObj = new UserMan.Roles(); RolesObj.RolesId = currentRoleId; RolesObj.CompanyId = Master.CurrentCompany.CompanyId; RolesObj = RolesObj.Select(); this.txtRoleName.Text = RolesObj.RoleName; this.txtRoleDescription.Text = RolesObj.RoleDescription; UserMan.Rights RightsObj = new UserMan.Rights(); RightsObj.RolesId = RolesObj.RolesId; gvRights.DataSource = RightsObj.SelectByRolesId(); gvRights.DataBind(); } catch (System.Exception) { } }
protected bool UpdateData() { bool result = false; DbConnection connection = null; DbTransaction transaction = null; try { Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING); connection = db.CreateConnection(); connection.Open(); transaction = connection.BeginTransaction(); UserMan.Roles RolesObj = new UserMan.Roles(); RolesObj.RolesId = Convert.ToInt32(this.hdnRoleId.Value); RolesObj.RoleName = txtRoleName.Text.Trim(); RolesObj.RoleDescription = txtRoleDescription.Text.Trim(); RolesObj.CompanyId = Master.CurrentCompany.CompanyId; RolesObj.UpdatedUser = Master.LoggedUser.UsersId; if (RolesObj.Save(db, transaction)) { //Delete exiting role rights RolesObj.DeleteByRolesId(db, transaction); List<object> myList = gvRights.GetSelectedFieldValues("RightId"); if (myList.Count > 0) { for (int i = 0; i <= myList.Count - 1; i++) { RolesObj.RightId = Convert.ToInt32(myList[i].ToString()); RolesObj.SaveRoleRights(db, transaction); } } } transaction.Commit(); result = true; this.DisplayData(); System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowSuccessMessage('" + Messages.Save_Success + "')", true); } catch (System.Exception) { } return result; }
public bool Update(Roles roles, Database db, DbTransaction transaction) { DbCommand command = db.GetStoredProcCommand("usp_RolesUpdate"); db.AddInParameter(command, "@CompanyId", DbType.Int32, roles.CompanyId); db.AddInParameter(command, "@RolesId", DbType.Int32, roles.RolesId); db.AddInParameter(command, "@RoleName", DbType.String, roles.RoleName); db.AddInParameter(command, "@RoleDescription", DbType.String, roles.RoleDescription); db.AddInParameter(command, "@UpdatedUser", DbType.Int32, roles.UpdatedUser); db.ExecuteNonQuery(command); return true; }
public DataSet SelectAll(Roles roles) { Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING); DbCommand dbCommand = db.GetStoredProcCommand("usp_RolesSelectAll"); db.AddInParameter(dbCommand, "@CompanyId", DbType.String, roles.CompanyId); return db.ExecuteDataSet(dbCommand); }