void FillProdsList() { listViewProds.BeginUpdate(); listViewProds.Items.Clear(); ProdsListRecord[] recs = cache.GetProdsListContents(); if (recs == null) { listViewProds.EndUpdate(); return; } for (int i = 0; i < recs.Length; i++) { ProdsListRecord r = recs[i]; Color foreColor, backColor; if (i % 2 == 0) { foreColor = foreColor1; backColor = backColor1; } else { foreColor = foreColor2; backColor = backColor2; } ListViewItem item; item = new ListViewItem(new string[] { r.prodId, r.timeDateLine }); item.ForeColor = foreColor; item.BackColor = backColor; item.ImageIndex = 0; listViewProds.Items.Add(item); item = new ListViewItem(new string[] { r.defId, r.deffect }); item.ForeColor = foreColor; item.BackColor = backColor; if (r.defsCount == 1) { item.ImageIndex = 1; } if (r.defsCount > 1) { item.ImageIndex = 2; } if (r.defsCount == 0) { item.ImageIndex = 3; } listViewProds.Items.Add(item); item = new ListViewItem(new string[] { r.contId, r.controller }); item.ForeColor = foreColor; item.BackColor = backColor; item.ImageIndex = 4; listViewProds.Items.Add(item); } listViewProds.EndUpdate(); }
public ProdsListRecord[] GetProdsListContents() { ArrayList res = new ArrayList(); string tm, dt, ln; if (products.Count == 0) { return(null); } for (int i = 0; i < ProgSettings.maxProdsListLength && products.Count - i > 0; i++) { Product p = products[products.Count - 1 - i] as Product; Registration r = p.regs[p.regs.Count - 1] as Registration; ProdsListRecord rec = new ProdsListRecord(); tm = r.time.Hour.ToString().PadLeft(2, '0') + ":" + r.time.Minute.ToString().PadLeft(2, '0'); dt = r.time.Day.ToString().PadLeft(2, '0') + "." + r.time.Month.ToString().PadLeft(2, '0'); ln = r.line.ToString(); rec.prodId = p.id; rec.timeDateLine = tm + "|" + dt + "|Л" + ln; rec.defId = r.defId; rec.deffect = GetDef(r.defId).name; rec.contId = r.contId; rec.controller = GetCont(r.contId).name; int dCount = 0; foreach (Registration reg in p.regs) { if (DateTime.Now < reg.time.Add(ProgSettings.period)) { dCount++; } } rec.defsCount = dCount; res.Add(rec); } res.Reverse(); return((ProdsListRecord[])res.ToArray(typeof(ProdsListRecord))); }