I was handed this P.O.S. that was mostly generated by some software that sucks.
Altering any of the important stuff breaks the whole project.
Essentially, I have an order source listing for a company... there are plenty of ways people can order from this application.
What this needs to do is display each order source, with a month-to-date count and a "Fiscal Year-to-date" count.
However, the client wants to see all of the order sources and if there are any order source details for each order,
to list them out under each order source.
Ideally, it would look something like this: (details will be any kind of special promo that they may have used while ordering)
Order source | MTD | FYTD | Chart Email 3 25 [button for popup] Phone 14 100 [button for popup] Detail 1 Detail 2 Detail 3 Fax 67 256 [button for popup] Detail 1 Detail 2 Web-Site 0 10 [button for popup] ETC.....
This is the front end on how it's called.
<fieldset>
<legend>Order Source</legend>
<table cellpadding="3" cellspacing="0">
<tr>
<td>
</td>
<td align="right">
<b>Current Month</b>
</td>
<td align="right">
<b>FYTD</b>
</td>
</tr>
<asp:Repeater runat="server" ID="rptsources">
<ItemTemplate>
<tr>
<td>
<table cellpadding="0" cellspacing="0">
<tr>
<td style="text-align: left;" valign="top">
<asp:Label ID="lblpromorpt" runat="server" Text="<%# Bind('OrderSource') %>" Font-Bold="True"></asp:Label>
</td>
</tr>
<tr>
<td style="text-align: left;" align="left">
<asp:Label ID="lblDetails" Font-Size="9px" runat="server" Text="<%# Bind('OrderSourceDetail') %>"></asp:Label>
</td>
</tr>
</table>
</td>
<td align="right" style="width: 60px;" valign="top">
<asp:Label ID="lblpromomonthrpt" Text="<%# Bind('OrderCount') %>" runat="server"></asp:Label>
</td>
<td align="right" style="width: 60px;" valign="top">
<asp:Label ID="lblpromoytdrpt" Text="<%# Bind('OrderCountYTD') %>" runat="server"></asp:Label>
</td>
<td align="right" style="width: 60px;" valign="top">
<asp:LinkButton ID="LinkButton1" onclick="ShowGraph" CommandArgument="<%# Bind('OrderSource') %>"
runat="server"><asp:Image ID="Image1" runat="server" ImageUrl="~/ImageMcCain/chart_icon.png" /></asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</fieldset>
This is how its being populated on the back end... I've almost got it... however, the order source details are showing up ABOVE the order source, and they need to be below each order source. (see screen shot)

//Data Table
DataTable dataTable = new DataTable();
dataTable.Columns.Add("OrderSource");
dataTable.Columns.Add("OrderCount", Type.GetType("System.Int32"));
dataTable.Columns.Add("OrderCountYTD", Type.GetType("System.Int32"));
dataTable.Columns.Add("OrderSourceDetail");
dataTable.Columns.Add("Id");
dataTable.Columns["Id"].AutoIncrement = true;
dataTable.Columns["Id"].AutoIncrementSeed = 1;
dataTable.Columns["Id"].AutoIncrementStep = 1;
//Set Primary Key
DataColumn[] columns = new DataColumn[1];
columns[0] = dataTable.Columns["Id"];
dataTable.PrimaryKey = columns;
using (CP_McCain db = new CP_McCain())
{
OrderSourceRow[] orderSources = db.OrderSourceCollection.GetAsArray("[Active] = 1", "[Order Source Code]");
if (orderSources.Length > 0)
{
foreach (var orderSourceRow in orderSources)
{
vw_Dash_OrderSourceRow[] viewRows =
db.vw_Dash_OrderSourceCollection.GetAsArray(
string.Format("[Order Source] = '{0}'", orderSourceRow.OrderSourceCode), null);
if (viewRows.Length > 0)
{
double fiscalYTD = 0;
DataRow newRow = dataTable.NewRow();
foreach (var viewRow in viewRows)
{
if (viewRow.Month == DateTime.Now.Month)
{
newRow["OrderCount"] = viewRow.OrdCount;
if (!String.IsNullOrEmpty(
viewRow.OrderSourceDetail.Replace(string.Format("{0}-", viewRow.OrderSource),
string.Empty))
&&
viewRow.OrderSourceDetail.Replace(string.Format("{0}-", viewRow.OrderSource),
string.Empty).ToUpper() != "NONE")
{
DataRow detailRow = dataTable.NewRow();
detailRow["OrderSourceDetail"] = viewRow.OrderSourceDetail;//.Replace(viewRow.OrderSource, string.Empty);
dataTable.Rows.Add(detailRow);
}
}
newRow["OrderSource"] = viewRow.OrderSource;
fiscalYTD += viewRow.OrdCount;
}
newRow["OrderCountYTD"] = fiscalYTD;
dataTable.Rows.Add(newRow);
}
}
}
}
rptsources.DataSource = dataTable;
rptsources.DataBind();
Any thoughts or hints you have would be appreciated...
I'm racking my brain on this and I hate - absolutely HATE - auto generated code.
If it were up to me, I'd re-write the entire application from scratch.
This post has been edited by mb2000inc: 30 January 2012 - 03:27 PM

New Topic/Question
Reply




MultiQuote



|