OK friends, so I need your advice. I'm reprogramming another web app that was originally written in .Net 1.1. The page I am working on looks like simple GridView with select, update and delete enabled. But it isn't so simple. In the code I have 10, yes 10 calls to the database. 5 sets of 2 nested DataReaders. All of this data is read and used in calculations, then to populate said table one cell at a time.
Example:
Table MyTable = new Table();
MyTable.BorderWidth = 1;
MyTable.BorderColor = Color.Gray;
TableRow rowx = new TableRow();
TableRow row3 = new TableRow();
TableCell cell3 = new TableCell();
cell3.ColumnSpan = 11;
IDataReader reader = this.Database.ExecuteReader("SELECT * FROM SomeView where SomeViewID in (select id from SomeTable where SomeDate = '" + this.SelectedDate + "')");
DataReaderMapper mapper = new DataReaderMapper(reader);
GridItems RemItems = new GridItems();
GridItem ritem = new GridItem();
while (mapper.Read())
{
ritem = new GridItem();
ritem.CustID = (long)mapper.GetDecimal("CustID");
ritem.InvoiceID = (long)mapper.GetDecimal("InvoiceID");
ritem.AvailTot = (mapper.IsDBNull("Amt1")?0:(float)mapper.GetDecimal("Amt1")); //Total Avail
ritem.ReqAmt = (mapper.IsDBNull("TotReq")?0:(float)mapper.GetDecimal("TotReq")); //Total Requested
ritem.Remaining =(mapper.IsDBNull("Remaining")?0:(float)mapper.GetDecimal("Remaining"));
RemItems.Add(ritem);
}
reader.Close();
mapper.Close();
And then we have some code to populate this table...
Table MyTable = new Table();
MyTable.BorderWidth = 1;
MyTable.BorderColor = Color.Gray;
TableRow rowx = new TableRow();
TableRow row3 = new TableRow();
TableCell cell3 = new TableCell();
cell3.ColumnSpan = 11;
Table MyTablex = new Table();
rowx = new TableRow();
TableCell cellx = new TableCell();
cellx = new TableCell();
cellx.CssClass = "RedCell";
cellx.Text ="--";
rowx.Cells.Add(cellx);
... You get the idea
So my question is... given that the SQL Stored Procedures and Views are already written. They are also somewhat complicated. Should I take the same approach? Should I try to use a GridView? Should I quit and look for another job?