private void FrmWarnGoodsList_FormClosed(object sender, FormClosedEventArgs e) { if (list.Count > 0) { if (MessageBox.Show("是否全部标记为已读", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { //将未读数据标记为已读 foreach (var item in list) { item.IsRead = true; WarnLogDAL.edit(item); } } } }
private void getlist() { list = WarnLogDAL.getlist(); if (list.Count > 0) { list = list.Where(x => x.IsRead == false).ToList(); if (list != null && list.Count > 0) { dgvlist.RowCount = list.Count; for (int i = 0; i < list.Count; i++) { dgvlist[0, i].Value = list[i].GoodsId; dgvlist[1, i].Value = diclist.ContainsKey(list[i].GoodsId) ? diclist[list[i].GoodsId].GoodsName.ToString() : ""; dgvlist[2, i].Value = string.IsNullOrEmpty(list[i].OnlyNum.ToString()) ? "" : list[i].OnlyNum.ToString(); dgvlist[3, i].Value = string.IsNullOrEmpty(list[i].AddTime.ToString("yyyy-MM-dd hh:mm:ss")) ? "" : list[i].AddTime.ToString("yyyy-MM-dd hh:mm:ss"); dgvlist[4, i].Value = diclist.ContainsKey(list[i].GoodsId) ? diclist[list[i].GoodsId].WarnNum.ToString() : ""; } } else { dgvlist.Rows.Clear(); } } }