/// <summary> /// /// </summary> /// <param name="dashboardId"></param> /// <param name="splitted"></param> /// <param name="order">if -1 = next order</param> public DashboardRow AddRow(int dashboardId, bool split, int order) { DashboardRow DBRowRet; try { using (SqlCommand oComm = new SqlCommand()) { if (Sqlconn.State == ConnectionState.Closed) Sqlconn.Open(); oComm.Connection = Sqlconn; oComm.CommandType = CommandType.StoredProcedure; oComm.CommandText = "DashBoard.AddRow"; SqlParameter pDSBID = new SqlParameter("@DSBID", SqlDbType.Int); pDSBID.Value = dashboardId; oComm.Parameters.Add(pDSBID); SqlParameter pSplitted = new SqlParameter("@SPLITTED", SqlDbType.Bit); pSplitted.Value = split; oComm.Parameters.Add(pSplitted); SqlParameter pOrder = new SqlParameter("@ORDER", SqlDbType.Int); pOrder.Direction = ParameterDirection.InputOutput; pOrder.Value = order; oComm.Parameters.Add(pOrder); SqlParameter pRowID = new SqlParameter("@ROWID", SqlDbType.Int); pRowID.Direction = ParameterDirection.Output; oComm.Parameters.Add(pRowID); oComm.ExecuteNonQuery(); DBRowRet = new DashboardRow() { id = (int)pRowID.Value, order = (int)pOrder.Value, splitted = split, widgets = null }; } } catch (Exception ex) { throw ex; } finally { if (Sqlconn.State == ConnectionState.Open) Sqlconn.Close(); } return DBRowRet; }
public List<DashboardRow> GetDashBoardRows(int dashboardId) { List<DashboardRow> lRows = new List<DashboardRow>(); SqlDataReader oReader; try { using (SqlCommand oComm = new SqlCommand()) { if (Sqlconn.State == ConnectionState.Closed) Sqlconn.Open(); oComm.Connection = Sqlconn; oComm.CommandType = CommandType.StoredProcedure; oComm.CommandText = "DashBoard.GetDashBoardRow"; SqlParameter pDashBoardID = new SqlParameter("@IDDASHBOARD", SqlDbType.Int); pDashBoardID.Value = dashboardId; oComm.Parameters.Add(pDashBoardID); oReader = oComm.ExecuteReader(); while (oReader.Read()) { DashboardRow dbRow = new DashboardRow() { id = (int)oReader["dsb_row_id"], splitted = (bool)oReader["splitted"], order = (int)oReader["order"] }; lRows.Add(dbRow); } } } catch (Exception ex) { throw ex; } finally { if (Sqlconn.State == ConnectionState.Open) Sqlconn.Close(); } return lRows; }