public void PopulateItemListByDU(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; int duId = Convert.ToInt32(cboIssuedTo.SelectedValue); lstItem.Items.Clear(); int col = 0; int count = 1; Balance bal = new Balance(); IssueDoc itmIssues = new IssueDoc(); foreach (DataRow dr in dtItem.Rows) { int itemId = Convert.ToInt32(dr["ID"]); string itemName = dr["ItemName"].ToString() + " - " + dr["DosageForm"].ToString() + " - " + dr["Strength"].ToString(); int year = Convert.ToInt32(cboYear.SelectedItem); Int64 SOH = bal.GetDUSOH(Convert.ToInt32(dr["ID"]), duId, dtCurrent.Month, year); 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] > 10) ? year - 1 : year; cons[i] = itmIssues.GetDUConsumptionByMonth(itemId, duId, mon[i], 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; }