public void PopulateItemList(DataTable dtItem) { progressBar1.Visible = true; progressBar1.Minimum = 1; progressBar1.Value = 1; progressBar1.Maximum = dtItem.Rows.Count; GeneralInfo pipline = new GeneralInfo(); pipline.LoadAll(); int min = pipline.Min; int max = pipline.Max; int storeId = (cboStores.SelectedValue != null)?Convert.ToInt32(cboStores.SelectedValue):1; lstItem.Items.Clear(); int col = 0; int count = 1; Balance bal = new Balance(); Items itmIssues = new Items(); int year = Convert.ToInt32(cboYear.SelectedItem); foreach (DataRow dr in dtItem.Rows) { int itemId = Convert.ToInt32(dr["ID"]); string itemName = dr["ItemName"].ToString() + " - " + dr["DosageForm"].ToString() + " - " + dr["Strength"].ToString(); int yer = (dtCurrent.Month < 11) ? year : year - 1;// (dtCurrent.Month < 11) ? Convert.ToInt32(cboYear.SelectedItem) : Convert.ToInt32(cboYear.SelectedItem) - 1; Int64 SOH = bal.GetSOH(Convert.ToInt32(dr["ID"]), storeId, dtCurrent.Month, yer); int[] mon = {11,12,1,2,3,4,5,6,7,8,9,10}; long[] cons = new long[12]; for (int i = 0; i < mon.Length;i++ ) { int yr = (mon[i] < 11) ? year : year - 1; cons[i] = itmIssues.GetQuantityIssuedByItemPerMonth(mon[i], itemId, storeId, yr); } string[] str = { count.ToString(), itemName, ((SOH != 0) ? SOH.ToString("#,###") : "0"), ((cons[0] != 0) ? cons[0].ToString("#,###") : "0"), ((cons[1] != 0) ? cons[1].ToString("#,###") : "0"), ((cons[2] != 0) ? cons[2].ToString("#,###") : "0"), ((cons[3] != 0) ? cons[3].ToString("#,###") : "0"), ((cons[4] != 0) ? cons[4].ToString("#,###") : "0"), ((cons[5] != 0) ? cons[5].ToString("#,###") : "0"), ((cons[6] != 0) ? cons[6].ToString("#,###") : "0"), ((cons[7] != 0) ? cons[7].ToString("#,###") : "0"), ((cons[8] != 0) ? cons[8].ToString("#,###") : "0"), ((cons[9] != 0) ? cons[9].ToString("#,###") : "0"), ((cons[10] != 0) ? cons[10].ToString("#,###") : "0"), ((cons[11] != 0) ? cons[11].ToString("#,###") : "0") }; ListViewItem listItem = new ListViewItem(str); listItem.ToolTipText = itemName; listItem.Tag = dr["ID"]; if (col != 0) { listItem.BackColor = Color.FromArgb(233, 247, 248); col = 0; } else { col++; } lstItem.Items.Add(listItem); count++; progressBar1.PerformStep(); } progressBar1.Visible = false; }