private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { frmHoaDonBanHang frm1 = new frmHoaDonBanHang(); frm1.MaHD = txtMCTHDX.Text; frm1.ShowDialog(); }
private void simpleButton4_Click(object sender, EventArgs e) { GetDuLieu(); if (gridView2.RowCount > 0 || gridView2.RowCount != 0) { try { int tien = 0; foreach (CTHDXuatDTO ct in cthdxDTO) { tien += ct.GiaBan * ct.SoLuong; } HoaDonXuatDTO hdb = new HoaDonXuatDTO(); frmSanPham sp = new frmSanPham(); Form1 frm = (Form1)this.MdiParent; hdb.MaHDX = hdxbus.TangHD(); hdb.MaNV = frm.NhanVienDN.MaNV; hdb.MaKH = lueKH.EditValue.ToString(); hdb.NgayXuat = System.DateTime.Now; hdb.TongTien = tien; int mhd = hdxbus.themHoaDon(hdb); CTHDXuatBUS ctbus = new CTHDXuatBUS(); int kq = 0; foreach (CTHDXuatDTO ct in cthdxDTO) { ct.MaCTHoaDonXuat = hdb.MaHDX; if (ctbus.ThemCTHoaDonXuat(ct)) { kq++; } if (sanphambus.TimSP(ct.MaSP)) { SanPhamDTO hh = new SanPhamDTO(); hh.MaSP = ct.MaSP; hh.SoLuong = ct.SoLuong; sanphambus.TruSL(hh); } } if (kq == cthdxDTO.Count) { XtraMessageBox.Show("Thanh toán thành công", "Thông báo", MessageBoxButtons.OK); frmHoaDonBanHang frm1 = new frmHoaDonBanHang(); frm1.MaHD = txtMHD.Text; frm1.ShowDialog(); txtMHD.Text = hdxbus.TangHD(); } else { XtraMessageBox.Show("Thanh toán thất bại", "Thông báo"); } } catch (Exception) { XtraMessageBox.Show("Bạn chưa mua hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } gctSP.DataSource = sanphambus.DanhSachSanPham(); for (int i = 0; i < gridView2.RowCount;) { gridView2.DeleteRow(i); } } else { XtraMessageBox.Show("Bạn chưa mua hàng", "Thông báo"); } txtSL.Text = ""; lblThanhTien.Text = ""; lblTongTien.Text = ""; lueKH.Enabled = true; btnT.Enabled = true; }