void GetRoomType() { int i = 1; dgRoomType.Rows.Clear(); using (Maintenance maintain = new Maintenance()) { maintain.GetRoomType().OrderBy(o => o.Code).ToList().ForEach(x => { dgRoomType.Rows.Add(x.ID, i, x.Code, x.Type, x.Active); i++; }); } ObjEnable(false); }
void dgRoomType_CellClick(object sender, DataGridViewCellEventArgs e) { if (dgRoomType.Rows.Count > 0) { using (Maintenance _maintain = new Maintenance()) { var value = _maintain.GetRoomType().Where(x => x.ID == Convert.ToInt64(dgRoomType.SelectedRows[0].Cells[0].Value)).FirstOrDefault(); if (value != null) { txtCode.Text = value.Code; txtRoomType.Text = value.Type; cbActive.Checked = value.Active.Value; btnDelete = SystemProperties.BtnProperties(btnDelete, true, Imagename.Delete.ToString(), Imagename._delete.ToString()); btnEdit = SystemProperties.BtnProperties(btnEdit, true, Imagename.Edit.ToString(), Imagename._edit.ToString()); } } } }