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
ahmed elbarbary
NA
1.6k
281.4k
When Display data in datagridview it take too much time alth
Jun 19 2018 5:20 AM
Problem
When Display data in datagridview it take too much time although data not more why and how to reduce time .
Data Display in datagridview windows form is 325 members only and not big data .
It take too much time when press buttonshow click event to show data in datagridview
it take may be 45 minutes meaning it take 3/4 hour to show data in datagridview
why and how to reduce time
private
void
GetMemberAccount(
string
MemberCode)
{
Tax = GetTax();
DataTable DTPriceList;
Annual = 0; UnderAge = 0; OverAge = 0; BabySitter = 0;
TotalUnderAge = 0; TotalOverAge = 0; TotalAnnual = 0; NetTotalAnnual = 0;
CridtValue1 = 0; CridtValue2 = 0;
string
SQL = @
"Select * From View_MembersWithPriceList where (MemberCode = N'"
+ MemberCode +
"') and (RelatedMemberCode IS NULL) and (Member ='True') AND (Year = "
+ txtYear.Text +
")"
;
DTPriceList = DataAccess.ExecuteDataTable(SQL);
if
(DTPriceList.Rows.Count > 0)
{
if
(!
string
.IsNullOrEmpty(Convert.ToString(DTPriceList.Rows[0][
"Annual"
])))
{
Annual = Convert.ToDouble(DTPriceList.Rows[0][
"Annual"
]);
}
if
(!
string
.IsNullOrEmpty(Convert.ToString(DTPriceList.Rows[0][
"KidsUnderAge"
])))
{
UnderAge = Convert.ToDouble(DTPriceList.Rows[0][
"KidsUnderAge"
]);
}
if
(!
string
.IsNullOrEmpty(Convert.ToString(DTPriceList.Rows[0][
"OverAgeChildPrice"
])))
{
OverAge = Convert.ToDouble(DTPriceList.Rows[0][
"OverAgeChildPrice"
]);
}
if
(!
string
.IsNullOrEmpty(Convert.ToString(DTPriceList.Rows[0][
"OverAgeChildPrice"
])))
{
OverAge = Convert.ToDouble(DTPriceList.Rows[0][
"OverAgeChildPrice"
]);
}
if
(!
string
.IsNullOrEmpty(Convert.ToString(DTPriceList.Rows[0][
"BabySitter"
])))
{
BabySitter = Convert.ToDouble(DTPriceList.Rows[0][
"BabySitter"
]);
}
if
(!
string
.IsNullOrEmpty(Convert.ToString(DTPriceList.Rows[0][
"ManagmentFees"
])))
{
ManagmentFees = Convert.ToDouble(DTPriceList.Rows[0][
"ManagmentFees"
]);
}
if
(!
string
.IsNullOrEmpty(Convert.ToString(DTPriceList.Rows[0][
"CardFees"
])))
{
CardFees = Convert.ToDouble(DTPriceList.Rows[0][
"CardFees"
]);
}
TotalUnderAge = ChildUndrAge(MemberCode);
TotalOverAge = ChildOverAge(MemberCode);
CountCard = GetCountCards(MemberCode);
if
(CountCard > 0)
{
TotalCardAmount = CountCard * CardFees;
}
if
(TotalUnderAge > 0)
{
TotalUnderAge = TotalUnderAge * UnderAge;
}
if
(TotalOverAge > 0)
{
TotalOverAge = TotalOverAge * OverAge;
}
if
(BabySiter(MemberCode) ==
false
)
{
BabySitter = 0;
}
TotalAnnual = (Annual + TotalUnderAge + TotalOverAge + BabySitter + ManagmentFees + TotalCardAmount);
NetTotalAnnual = TotalAnnual;
int
Diff = DiffDate(MemberCode);
if
(Diff < 12 && Diff !=0)
{
double
CustomAnnual = TotalAnnual / 12;
TotalAnnual = Math.Round(CustomAnnual * Diff, 2);
}
if
(Diff ==0)
{
TotalAnnual = 0;
}
if
(TotalAnnual > 0)
{
TotalDue= CridtValue1 = Math.Round((TotalAnnual / Tax),2);
TotalTax = TotalAnnual - TotalDue;
CridtValue2 = Math.Round(TotalAnnual - CridtValue1, 2);
}
}
}
Under button show this code is written
if
(!
string
.IsNullOrEmpty(txtYear.Text))
{
string
Sql =
"Select * From View_MembersWithPriceList where (RelatedMemberCode IS NULL) and (Member ='True') AND (Year = "
+ txtYear.Text +
")"
;
DT = DataAccess.ExecuteDataTable(Sql);
if
(DT.Rows.Count > 0)
{
Grid.DataBinding(DT);
for
(
int
i = 0; i < Grid.Rows.Count; i++)
{
MemberCode = Convert.ToString(Grid.Rows[i].Cells[
"MemberCode"
].Value);
if
(!
string
.IsNullOrEmpty(MemberCode))
{
GetMemberAccount(MemberCode);
Grid.Rows[i].Cells[
"AnnualValue"
].Value = Annual;
Grid.Rows[i].Cells[
"OverAge"
].Value = TotalOverAge;
Grid.Rows[i].Cells[
"UnderAge"
].Value = TotalUnderAge;
Grid.Rows[i].Cells[
"BabySitter"
].Value = BabySitter;
Grid.Rows[i].Cells[
"NetTotal"
].Value = NetTotalAnnual;
Grid.Rows[i].Cells[
"TotalDue"
].Value = TotalAnnual;
Grid.Rows[i].Cells[
"Total"
].Value = TotalDue;
Grid.Rows[i].Cells[
"TotalTax"
].Value = TotalTax;
}
}
}
}
Reply
Answers (
3
)
HTTP Error 500.19 - Internal Server Error
Session with multiple user