void cP_Check_Room(object sender, System.EventArgs e) { string sql = "select * from dmphong order by maphong"; tb = _db.GetDataTable(sql); List <cPhong> LstTmp = new List <cPhong>(); LstTmp = lstPhong.GetRange(0, lstPhong.Count - 1); foreach (DataRow dr in tb.Rows) { cPhong cpRemove = null; foreach (cPhong cp in LstTmp) { if (cp.MaPhong == dr["MaPhong"].ToString()) { // if (cp.TTPhong != dr["MaTT"].ToString()) // { cp.TTPhong = dr["MaTT"].ToString(); cp.MaPhong = dr["MaPhong"].ToString(); // } cpRemove = cp; break; } } if (cpRemove != null) { LstTmp.Remove(cpRemove); } } Draw(); }
private void fRoomList_Load(object sender, EventArgs e) { string sql = "select * from dmphong order by maphong"; tb = _db.GetDataTable(sql); foreach (DataRow dr in tb.Rows) { cPhong cP = new cPhong(); cP.TTPhong = dr["MaTT"].ToString(); cP.MaPhong = dr["MaPhong"].ToString(); cP.MaLoaiPhong = dr["MaLoaiPhong"].ToString(); lstPhong.Add(cP); cP.Visible = true; cP.Check_Room += new EventHandler(cP_Check_Room); cP.FineGroup += new EventHandler(cP_FineGroup); } this.Resize += new EventHandler(fRoomList_Resize); this.KeyUp += new KeyEventHandler(fRoomList_KeyUp); }
void cP_FineGroup(object sender, EventArgs e) { try { cPhong c = sender as cPhong; if (c.Mt62id == null) { return; } foreach (cPhong cp in lstPhong) { if (cp.Mt62id == c.Mt62id) { cp.RoomColor = c.RoomColor; } } } catch { } }