private void btnxoa_Click(object sender, EventArgs e) { HoaDonBanGTGT n1 = new HoaDonBanGTGT(); n1.SoHoaDon = txtsohd.Text.Trim(); n1.DiaChi = txtdiachigt.Text.Trim(); n1.DvBanHang = txtdvban.Text.Trim(); n1.ThanhTien = Convert.ToDecimal(textBox1.Text.Trim()); n1.DvMuaHang = txtdvmua.Text.Trim(); n1.HinhThucThanhToan = txthinhthuc.Text.Trim(); n1.MsThue = Convert.ToInt32(txtmasothue.Text.Trim()); n1.NgaylapHoaDon = Convert.ToDateTime(txtngaylap.Text.Trim()); n1.SoTaiKhoan = txtsotaikhoan.Text.Trim(); bool kq = hdgtbll.xoaclgd(n1); if (kq == false) { MessageBox.Show("Không có mã để xóa!", "Thông báo!"); } else { MessageBox.Show("Xóa thành công!", "Thông báo!"); dataGridView1.DataSource = hdgtbll.GetAllHDBGTGT(); } }
private void btnthem_Click(object sender, EventArgs e) { HoaDonBanGTGT n = new HoaDonBanGTGT(); //ChiTietHDGTGT n = new ChiTietHDGTGT(); n.SoHoaDon = txtsohd.Text.Trim(); n.DiaChi = txtdiachigt.Text.Trim(); n.DvBanHang = txtdvban.Text.Trim(); n.ThanhTien = Convert.ToDecimal(textBox1.Text.Trim()); n.DvMuaHang = txtdvmua.Text.Trim(); n.HinhThucThanhToan = txthinhthuc.Text.Trim(); n.MsThue = Convert.ToInt32(txtmasothue.Text.Trim()); n.NgaylapHoaDon = Convert.ToDateTime(txtngaylap.Text.Trim()); n.SoTaiKhoan = txtsotaikhoan.Text.Trim(); int kq = hdgtbll.ThemHDGTGT(n); 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); } }
public bool xoaclgd(HoaDonBanGTGT delid) { try { Tbl_HD_GTGT deletema = DB.Tbl_HD_GTGTs.Single(x => x.soHoaDon == delid.SoHoaDon); DB.Tbl_HD_GTGTs.DeleteOnSubmit(deletema); DB.SubmitChanges(); return(true); } catch { return(false); } }
public List <HoaDonBanGTGT> GetAllHDBGTGT() { var updatebgtgt = DB.Tbl_HD_GTGTs.ToList(); List <HoaDonBanGTGT> kq = new List <HoaDonBanGTGT>(); foreach (Tbl_HD_GTGT tmp in updatebgtgt) { HoaDonBanGTGT p = new HoaDonBanGTGT(); p.MsThue = tmp.msThue; p.HinhThucThanhToan = tmp.hinhthucThanhToan; p.NgaylapHoaDon = tmp.ngaylapHoaDon; p.SoHoaDon = tmp.soHoaDon; p.SoTaiKhoan = tmp.soTaiKhoan; p.ThanhTien = tmp.thanhTien; p.DvBanHang = tmp.dvBanHang; p.DvMuaHang = tmp.dvMuaHang; p.DiaChi = tmp.diaChi; kq.Add(p); } return(kq); }
public bool Update(HoaDonBanGTGT updategtgt) { try { Tbl_HD_GTGT update = DB.Tbl_HD_GTGTs.Single(tmp => tmp.soHoaDon == updategtgt.SoHoaDon); update.soHoaDon = updategtgt.SoHoaDon; update.dvBanHang = updategtgt.DvBanHang; update.dvMuaHang = updategtgt.DvMuaHang; update.diaChi = updategtgt.DiaChi; update.hinhthucThanhToan = updategtgt.HinhThucThanhToan; update.soTaiKhoan = updategtgt.SoTaiKhoan; update.msThue = updategtgt.MsThue; update.ngaylapHoaDon = updategtgt.NgaylapHoaDon; update.thanhTien = updategtgt.ThanhTien; DB.SubmitChanges(); return(true); } catch { return(false); } }
public int ThemHDGTGT(HoaDonBanGTGT updategtgt) { var updategtgiatang = DB.Tbl_HD_GTGTs.Where(x => x.soHoaDon == Convert.ToString(updategtgt.SoHoaDon)).FirstOrDefault(); if (updategtgiatang != null) { return(0); } Tbl_HD_GTGT update = new Tbl_HD_GTGT(); update.soHoaDon = updategtgt.SoHoaDon; update.dvBanHang = updategtgt.DvBanHang; update.dvMuaHang = updategtgt.DvMuaHang; update.diaChi = updategtgt.DiaChi; update.hinhthucThanhToan = updategtgt.HinhThucThanhToan; update.soTaiKhoan = updategtgt.SoTaiKhoan; update.msThue = updategtgt.MsThue; update.ngaylapHoaDon = updategtgt.NgaylapHoaDon; update.thanhTien = updategtgt.ThanhTien; DB.Tbl_HD_GTGTs.InsertOnSubmit(update); DB.SubmitChanges(); return(1); }