TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Guest User
Tech Writer
56
1.9k
Different approach for a repetitive task
Jul 7 2016 12:21 PM
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.
Reply
Answers (
4
)
Why base class constructor is called first ?
when i mouse right click will get some options