private void LoadListViewCombo() { ComboBLL comboBLL = new ComboBLL(); DataTable dataTable; if (clickSearch) { dataTable = comboBLL.Search(dateStart.Value, dateEnd.Value, txtSeachCombo.Text); } else { dataTable = comboBLL.GetAllCombo(); } LoadImage(dataTable, folder_combo, 120, 70); listViewData.Clear(); listViewData.View = View.Details; listViewData.FullRowSelect = true; listViewData.SmallImageList = imageList; listViewData.Columns.Add("Hình ảnh", 120); listViewData.Columns.Add("Tên Combo", 80); listViewData.Columns.Add("Ngày bắt đầu", 140); listViewData.Columns.Add("Ngày kết thúc", 140); listViewData.Columns.Add("Total", 70); listViewData.Columns.Add("Giảm giá"); ListViewItem lvitem; foreach (DataRow row in dataTable.Rows) { lvitem = new ListViewItem(); lvitem.ImageKey = row.Field <int>("Id").ToString(); lvitem.SubItems.Add(row.Field <string>("ComboName")); lvitem.SubItems.Add(row.Field <DateTime>("DayStart").ToString()); lvitem.SubItems.Add(row.Field <DateTime>("DayEnd").ToString()); lvitem.SubItems.Add(row.Field <int>("Total").ToString("0,0")); lvitem.SubItems.Add(int.Parse(row.Field <string>("DiscountMoney")).ToString("0,0")); listViewData.Items.Add(lvitem); } }
public void LoadListView() { ComboBLL comboBLL = new ComboBLL(); DataTable dataTable; if (clickSearch) { dataTable = comboBLL.Search(dateSearchStart.Value, dateSearchEnd.Value, txtSearch.Text); } else { dataTable = comboBLL.GetAllCombo(); } LoadImage(dataTable); listViewCombo.Clear(); listViewCombo.View = View.Details; listViewCombo.FullRowSelect = true; listViewCombo.SmallImageList = imageList; listViewCombo.Columns.Add("Image", 120); listViewCombo.Columns.Add("Combo Name", 80); listViewCombo.Columns.Add("Date begin", 140); listViewCombo.Columns.Add("Date end", 140); listViewCombo.Columns.Add("Total", 70); listViewCombo.Columns.Add("Discount"); ListViewItem lvitem; foreach (DataRow row in dataTable.Rows) { lvitem = new ListViewItem(); lvitem.ImageKey = row.Field <int>("Id").ToString(); lvitem.SubItems.Add(row.Field <string>("ComboName")); lvitem.SubItems.Add(row.Field <DateTime>("DayStart").ToString()); lvitem.SubItems.Add(row.Field <DateTime>("DayEnd").ToString()); lvitem.SubItems.Add(row.Field <int>("Total").ToString("0,0")); lvitem.SubItems.Add(int.Parse(row.Field <string>("DiscountMoney")).ToString("0,0")); listViewCombo.Items.Add(lvitem); } }