void ThemDoDung() { tblDoDung dd = new tblDoDung(); if (dgvDoDung.Rows.Count <= 1) { dd.IDDoDung = 1; } else { dd.IDDoDung = db.tblDoDungs.Select(n => n.IDDoDung).Max() + 1; } dd.TenDoDung = txtTenDoDung.Text; if (txtSoLuong.Text == "") { dd.SoLuong = null; } else { dd.SoLuong = int.Parse(txtSoLuong.Text); } if (txtDonGia.Text == "") { dd.DonGia = null; } else { dd.DonGia = int.Parse(txtDonGia.Text); } db.tblDoDungs.InsertOnSubmit(dd); db.SubmitChanges(); }
void XoaDoDung() { tblDoDung dd = db.tblDoDungs.Where(n => n.IDDoDung == int.Parse(txtIDDoDung.Text)).First(); db.tblDoDungs.DeleteOnSubmit(dd); db.SubmitChanges(); }
void SuaDoDung() { tblDoDung dd = db.tblDoDungs.Where(n => n.IDDoDung == int.Parse(txtIDDoDung.Text)).First(); dd.TenDoDung = txtTenDoDung.Text; if (txtSoLuong.Text == "") { dd.SoLuong = null; } else { dd.SoLuong = int.Parse(txtSoLuong.Text); } if (txtDonGia.Text == "") { dd.DonGia = null; } else { dd.DonGia = int.Parse(txtDonGia.Text); } db.SubmitChanges(); }
partial void DeletetblDoDung(tblDoDung instance);
partial void UpdatetblDoDung(tblDoDung instance);
partial void InserttblDoDung(tblDoDung instance);