private void btnXoa_Click(object sender, EventArgs e) { using (QLBanXeEntities1 quanli = new QLBanXeEntities1()) { CTPHIEUNHAP hd = quanli.CTPHIEUNHAPs.Where(p => p.MaPN == cbmaPN.Text).Where(p => p.MaSP == cbmasp.Text).FirstOrDefault(); if (hd != null) { quanli.CTPHIEUNHAPs.Remove(hd); quanli.SaveChanges(); MessageBox.Show("Đã xóa!"); frmCTPhieuNhap_Load(sender, e); } } }
private void btnSua_Click(object sender, EventArgs e) { using (QLBanXeEntities1 quanli = new QLBanXeEntities1()) { CTPHIEUNHAP kh = quanli.CTPHIEUNHAPs.Where(p => p.MaPN == cbmaPN.Text).Where(p => p.MaSP == cbmasp.Text).FirstOrDefault(); //kh.MaPN = txtmaphieunhap.Text; kh.GiaNhap = Convert.ToInt32(txtgianhap.Text); kh.SoLuong = Convert.ToInt32(txtsoluong.Text); kh.ThanhTien = Convert.ToInt32(txtthanhtien.Text); quanli.SaveChanges(); MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information); frmCTPhieuNhap_Load(sender, e); } }