private void ViewData()
{
try
{
if (validateBeforeView())
{
grdPendingLeads.DataSource = new DataTable();
if (!(backgroundWorker1.IsBusy))
{
backgroundWorker1.RunWorkerAsync();
pictureBox1.Visible = true;
}
}
}
catch(Exception ex)
{
pictureBox1.Visible = false;
MessageBox.Show(ex.Message.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void GetData()
{
try {
PendingLeadsCls obj = new PendingLeadsCls();
string fromDate = calCmbFrom.Value.ToShortDateString();
string toDate = calCmbTo.Value.AddDays(1).ToShortDateString();
dtResult = obj.GetLeads(mcmbCity.Text, fromDate, toDate);
}
catch (Exception ex)
{
pictureBox1.Visible = false;
MessageBox.Show(ex.Message.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
try {
GetData();
}
catch (Exception ex)
{
pictureBox1.Visible = false;
MessageBox.Show(ex.Message.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
try {
pictureBox1.Visible = false;
if (dtResult.Rows.Count == 0)
{
MessageBox.Show("There is no record for your search criteria.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
grdPendingLeads.Tables[0].Caption = " -Pending Leads for the period of " + calCmbFrom.Text + " to " + calCmbTo.Text + " -";
grdPendingLeads.DataSource = dtResult;
}
}
catch (Exception ex)
{
pictureBox1.Visible = false;
MessageBox.Show(ex.Message.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
No comments:
Post a Comment