Esempio n. 1
0
        public void PopulateItemList(DataTable dtItem)
        {
            progressBar1.Visible = true;
            progressBar1.Minimum = 1;
            progressBar1.Value   = 1;
            progressBar1.Maximum = dtItem.Rows.Count;

            lstItem.Items.Clear();
            int col     = 0;
            int count   = 1;
            int storeId = (cboStores.SelectedValue != null) ? Convert.ToInt32(cboStores.SelectedValue) : 1;

            dtDate.Value        = DateTime.Now;
            dtDate.CustomFormat = "MM/dd/yyyy";
            DateTime dtCurrent = new DateTime();

            dtCurrent = ConvertDate.DateConverter(dtDate.Text);

            IssueDoc issues = new IssueDoc();

            foreach (DataRow dr in dtItem.Rows)
            {
                string   itemName = dr["ItemName"].ToString() + " - " + dr["DosageForm"].ToString() + " - " + dr["Strength"].ToString();
                Int64[]  obj      = new Int64[recId.Length];
                int      itemId   = Convert.ToInt32(dr["ID"]);
                string[] str      = new string[recId.Length + 2];
                str[0] = count.ToString();
                str[1] = itemName;
                for (int j = 0; j < recId.Length; j++)
                {
                    obj[j]     = issues.GetIssuedQuantityByReceivingUnit(itemId, storeId, recId[j], dtCurrent.Year);
                    str[j + 2] = (obj[j] != 0)?obj[j].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;
        }