private ChiTietHoaDonBanLe passingData() { try { tempCTHDBanLe = new ChiTietHoaDonBanLe(); tempCTHDBanLe.SoHoaDon = txtmahdbanle.Text; tempCTHDBanLe.MaSP = txtmasp.Text; tempCTHDBanLe.SoLuong = Convert.ToDouble(txtsoluong.Text); tempCTHDBanLe.GhiChu = txtghichu.Text; tempCTHDBanLe.DonGia = Convert.ToDecimal(txtghichu.Text); return(tempCTHDBanLe); } catch { } return(null); }
public bool Update(ChiTietHoaDonBanLe cthdbl) { try { Tbl_CTHDBanLe update = DB.Tbl_CTHDBanLes.Single(tmp => tmp.soHoaDon == cthdbl.SoHoaDon); update.soHoaDon = cthdbl.SoHoaDon; update.maSP = cthdbl.MaSP; update.ghiChu = cthdbl.GhiChu; update.soLuong = cthdbl.SoLuong; update.donGia = cthdbl.DonGia; DB.SubmitChanges(); return(true); } catch { return(false); } }
public int XoaCTHDBanLe(ChiTietHoaDonBanLe cthdbl) { Tbl_CTHDBanLe tbhdbl = new Tbl_CTHDBanLe(); tbhdbl = DB.Tbl_CTHDBanLes.Where(x => x.soHoaDon == cthdbl.SoHoaDon).FirstOrDefault(); if (tbhdbl != null) { return(0); } tbhdbl.soHoaDon = cthdbl.SoHoaDon; tbhdbl.maSP = cthdbl.MaSP; tbhdbl.ghiChu = cthdbl.GhiChu; tbhdbl.soLuong = cthdbl.SoLuong; tbhdbl.donGia = cthdbl.DonGia; DB.Tbl_CTHDBanLes.DeleteOnSubmit(tbhdbl); DB.SubmitChanges(); return(1); }
public int ThemCTHDBanLe(ChiTietHoaDonBanLe cthdbl) { var cthdbanle = DB.Tbl_CTHDBanLes.Where(x => x.soHoaDon == cthdbl.SoHoaDon).FirstOrDefault(); if (cthdbanle != null) { return(0); } Tbl_CTHDBanLe hd = new Tbl_CTHDBanLe(); hd.soHoaDon = cthdbl.SoHoaDon; hd.maSP = cthdbl.MaSP; hd.ghiChu = cthdbl.GhiChu; hd.soLuong = cthdbl.SoLuong; hd.donGia = cthdbl.DonGia; DB.Tbl_CTHDBanLes.InsertOnSubmit(hd); DB.SubmitChanges(); return(1); }
private void btnluu_Click(object sender, EventArgs e) { passingData(); ChiTietHoaDonBanLe cthdbl = new ChiTietHoaDonBanLe(); cthdbl.SoHoaDon = txtmahdbanle.Text; cthdbl.MaSP = txtmasp.Text; cthdbl.SoLuong = Convert.ToDouble(txtsoluong.Text); cthdbl.GhiChu = txtghichu.Text; cthdbl.DonGia = Convert.ToDecimal(txtdongia.Text); int kq = cthdblBLL.ThemCTHDBanLe(cthdbl); if (kq == 0) { MessageBox.Show("Trùng mã hóa đơn !", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } else if (kq == 1) { MessageBox.Show("Thêm thành công !", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); } }