Beispiel #1
0
        public void PopulateItemListByDateRange(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;

            dtFrom.CustomFormat = "MM/dd/yyyy";
            dtTo.CustomFormat   = "MM/dd/yyyy";
            DateTime dteFrm = new DateTime();
            DateTime dteTo  = new DateTime();

            if (Convert.ToInt32(dtFrom.Text.Substring(0, 2)) != 13)
            {
                dteFrm = Convert.ToDateTime(dtFrom.Text);
            }
            else
            {
                string dtValid = dtFrom.Text;
                string year    = dtValid.Substring(dtValid.Length - 4, 4);
                dteFrm = Convert.ToDateTime("12/30/" + year);
            }

            if (Convert.ToInt32(dtTo.Text.Substring(0, 2)) != 13)
            {
                dteTo = Convert.ToDateTime(dtTo.Text);
            }
            else
            {
                string dtValid = dtTo.Text;
                string year    = dtValid.Substring(dtValid.Length - 4, 4);
                dteTo = Convert.ToDateTime("12/30/" + year);
            }

            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.GetIssuedQuantityByReceivingUnitDate(itemId, storeId, recId[j], dteFrm.ToShortDateString(), dteTo.ToShortDateString());
                    str[j + 2] = obj[j].ToString();
                }

                ListViewItem listItem = new ListViewItem(str);
                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;
        }