Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
4
Answers
Different approach for a repetitive task
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
Optimus Vulgaris
8y
321
1
Reply
I'm looking for an alternative towards a process that takes too much code and generates significant overhead...
This code fills in a Chartview (LineChart) and in order to display the progression of 6 different "Areas" it runs a query 6 times and add the series 6 times...
public
static
void
FillLineChart(ChartView chartView, CheckedDropDownList checkedDropDown,
string
dateFrom,
string
dateTo)
{
foreach
(var i
in
checkedDropDown.CheckedItems)
{
var iindex = i.RowIndex + 1;
if
(iindex == 1)
{
LineSeries crime =
new
LineSeries();
FunctionsDAL cr =
new
FunctionsDAL();
foreach
(var caseType
in
cr.ListCases(1, dateFrom, dateTo))
{
crime.DataPoints.Add(
new
CategoricalDataPoint(caseType.IncrementalTotal,
CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(caseType.MonthNum)));
}
chartView.Series.Add(crime);
crime.LegendTitle =
"Crime"
;
crime.Spline =
true
;
}
else
if
(iindex == 2)
{
}
else
if
(iindex == 3)
{
}
// The same 3 more times
}
}
How could I shorten up this process? or is this the way is supposed to be working?
Regards.
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
Why base class constructor is called first ?
when i mouse right click will get some options