void ThemPhong() { tblPhong dd = new tblPhong(); if (dgvPhong.Rows.Count <= 1) { dd.IDPhong = 1; } else { dd.IDPhong = db.tblPhongs.Select(n => n.IDPhong).Max() + 1; } dd.SucChua = int.Parse(txtSucChua.Text); dd.GiaPhong = int.Parse(txtGiaPhong.Text); if (ckTrangThai.Checked == true) { dd.TrangThai = "Đã Thuê"; } else { dd.TrangThai = null; } db.tblPhongs.InsertOnSubmit(dd); db.SubmitChanges(); }
void XoaPhong() { tblPhong dd = db.tblPhongs.Where(n => n.IDPhong == int.Parse(txtIDPhong.Text)).First(); db.tblPhongs.DeleteOnSubmit(dd); db.SubmitChanges(); }
void SuaPhong() { tblPhong dd = db.tblPhongs.Where(n => n.IDPhong == int.Parse(txtIDPhong.Text)).First(); dd.SucChua = int.Parse(txtSucChua.Text); dd.GiaPhong = int.Parse(txtGiaPhong.Text); if (ckTrangThai.Checked == true) { dd.TrangThai = "Đã Thuê"; } else { dd.TrangThai = null; } db.SubmitChanges(); }
partial void DeletetblPhong(tblPhong instance);
partial void UpdatetblPhong(tblPhong instance);
partial void InserttblPhong(tblPhong instance);