I have created a application where multiple people scan QR codes on products before dispatching.
The application is created using WinForms, C# language and SQL Database.
I am using MDI form with multiple forms like scan products, Generate MIS, Dashboard etc.
The application is running pretty well, now I am working on the optimization.
I am stuck in the Dashboard form, which contains multiple pivot count from the database like Scan per Users, Scan per product, Scanning done per hour etc.
The form is working fine but loading so much data takes some time in which I want to show a animated gif untill the process is executed and the listviews and labels are updated.
Using the below code the image is not visible, when the code is run in the background. Please guide what I need to do.
I have pasted only one method for example others are similar:
private void RefreshBtn_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
pictureBox2.Visible = true;
displayStats();
Cursor.Current = Cursors.Arrow;
pictureBox2.Visible = false;
}
private void displayStats()
{
CustScan();
DatewiseQcCount();
UserWiseScan();
UserwiseDScan();
DayWiseDispatchScan();
HourwiseQcCount();
}
private void UserWiseScan()
{
string queryString = "select scanby,count(distinct refno),count(1) from SecRec where scan='Y' group by scanby order by 3,2 desc";
lstVUser.Clear();
lstVUser.Columns.Add("User", 105);
lstVUser.Columns.Add("Cust", 60);
lstVUser.Columns.Add("Imp", 60);
using (SqlConnection conn = new SqlConnection(connectString))
{
SqlCommand cmd = new SqlCommand(queryString, conn);
try
{
conn.Open();
SqlDataAdapter adp = new SqlDataAdapter(queryString, conn);
DataTable dt = new DataTable();
adp.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow dr = dt.Rows[i];
ListViewItem listitem = new ListViewItem(dr[0].ToString());
listitem.SubItems.Add(dr[1].ToString().PadLeft(3));
listitem.SubItems.Add(dr[2].ToString().PadLeft(3));
lstVUser.Items.Add(listitem);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
There is not much activity in the fornt end as return rows are limited. The majority of the process is being done in the backend.
I want to show the pictureBox with animated GIF.