public int AddDashboardRole(DashboardRole DboardRole) { int DashboardID = -1; DbCommand commandWrapper = GetDbCommand("spr_AddDashboardUserRole"); try { commandWrapper.Parameters.Add(new SqlParameter("@UserID", DboardRole.UserID)); commandWrapper.Parameters.Add(new SqlParameter("@DashboardRoleTypeID", DboardRole.DashboardRoleTypeID)); commandWrapper.Parameters.Add(new SqlParameter("@OrganizationCodeID", DboardRole.OrganizationCodeID)); commandWrapper.Parameters.Add(new SqlParameter("@DashboardRoleLabel", DboardRole.DashboardRoleLabel)); SqlParameter returnParam = new SqlParameter("@DashboardRoleID", SqlDbType.Int); returnParam.Direction = ParameterDirection.Output; commandWrapper.Parameters.Add(returnParam); ExecuteNonQuery(commandWrapper); DashboardID = Convert.ToInt32(returnParam.Value); } catch (Exception ex) { DashboardID = -1; HandleException(ex); } return(DashboardID); }
public List <DashboardRole> GetRoleSearchResult(int RegionID, int OrgCodeID, int RoleTypeID, int UserID) { DbCommand commandWrapper = GetDbCommand("spr_GetRoleSearchResult"); commandWrapper.Parameters.Add(new SqlParameter("@RegionID", RegionID)); commandWrapper.Parameters.Add(new SqlParameter("@OrgCodeID", OrgCodeID)); commandWrapper.Parameters.Add(new SqlParameter("@RoleTypeID", RoleTypeID)); commandWrapper.Parameters.Add(new SqlParameter("@UserID", UserID)); DataTable dataItems = ExecuteDataTable(commandWrapper); List <DashboardRole> listCollection = new List <DashboardRole>(); if (dataItems != null) { for (int i = 0; i < dataItems.Rows.Count; i++) { DashboardRole item = new DashboardRole(dataItems.Rows[i]); listCollection.Add(item); } } else { throw new Exception("Failed to get roles"); } return(listCollection); }
internal static List <DashboardRole> GetCollection(DataTable dataItems) { List <DashboardRole> listCollection = new List <DashboardRole>(); DashboardRole current = null; if (dataItems != null) { for (int i = 0; i < dataItems.Rows.Count; i++) { current = new DashboardRole(dataItems.Rows[i]); listCollection.Add(current); } } else { throw new Exception("You cannot create a DashboardRole collection from a null data table."); } return(listCollection); }
public List <DashboardRole> GetAllDashboardRole() { List <DashboardRole> listCollection = new List <DashboardRole>(); DataTable dataItems = ExecuteDataTable("spr_GetAllDashboardRole"); if (dataItems != null) { for (int i = 0; i < dataItems.Rows.Count; i++) { DashboardRole item = new DashboardRole(dataItems.Rows[i]); listCollection.Add(item); } } else { throw new Exception("Failed to get roles"); } return(listCollection); }