private void UpdateListPhong() { PhongData data = new PhongData(); listView.Items.Clear(); foreach (DataRow dr in data.LayMaPhong().Rows) { PhongInFo phongInFo = new PhongInFo(); phongInFo.MaPhong = (string)dr.ItemArray[0]; phongInFo.MaLoaiPhong = (string)dr.ItemArray[1]; phongInFo.MaTinhTrangPhong = (string)dr.ItemArray[2]; ListViewItem item = new ListViewItem(phongInFo.TenPhong); if (phongInFo.MaTinhTrangPhong == "TTP1") { item.ImageIndex = 0; } else if (phongInFo.MaTinhTrangPhong == "TTP2") { item.ImageIndex = 1; } else if (phongInFo.MaTinhTrangPhong == "TTP3") { item.ImageIndex = 2; } else { item.ImageIndex = 3; } listView.Items.Add(item); } }
private void cậpNhậtToolStripMenuItem_Click(object sender, EventArgs e) { PhongData data = new PhongData(); listView.Items.Clear(); foreach (DataRow dr in data.LayMaPhong().Rows) { PhongInFo phongInFo = new PhongInFo(); phongInFo.MaLoaiPhong = (string)dr.ItemArray[1]; phongInFo.MaPhong = (string)dr.ItemArray[0]; phongInFo.MaTinhTrangPhong = (string)dr.ItemArray[2]; ListViewItem item = new ListViewItem(phongInFo.MaPhong); if (phongInFo.MaTinhTrangPhong == "TTP01") { item.ImageIndex = 0; } else if (phongInFo.MaTinhTrangPhong == "TTP02") { item.ImageIndex = 1; } else if (phongInFo.MaTinhTrangPhong == "TTP03") { item.ImageIndex = 2; } else { item.ImageIndex = 3; } listView.Items.Add(item); } }