private void btnThemMoi_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { frmSanPham sp = new frmSanPham(); sp.Dock = DockStyle.Fill; sp.ShowDialog(); gctSanPham.DataSource = sanphambus.DanhSachSanPham(); }
private void btnDSSP_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { Form frm = this.KiemTraTonTai(typeof(frmSanPham)); if (frm != null) { frm.Activate(); } else { frmSanPham sp = new frmSanPham(); sp.MdiParent = this; sp.Dock = DockStyle.Fill; sp.Show(); } }
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; }
private void btnLapHD_Click(object sender, EventArgs e) { GetDuLieu(); if (gridView2.RowCount > 0 || gridView2.RowCount != 0) { try { double tien = 0; foreach (CTHDNhapDTO ct in lstchitiet) { tien += ct.GiaNhap * ct.SoLuong; } HoaDonNhapDTO hdb = new HoaDonNhapDTO(); frmSanPham sp = new frmSanPham(); Form1 frm = (Form1)this.MdiParent; hdb.MaHDN = hdnbus.TangHD(); hdb.MaNV = frm.NhanVienDN.MaNV; hdb.NgayNhap = System.DateTime.Now; hdb.TongTien = tien; int mhd = hdnbus.ThemHoaDonNhap(hdb); CTHDNhapBUS ctbus = new CTHDNhapBUS(); int kq = 0; foreach (CTHDNhapDTO ct in lstchitiet) { ct.MaCTHoaDonNhap = hdb.MaHDN; if (ctbus.ThemCTHoaDonNhap(ct)) { kq++; } if (sanphambus.TimSP(ct.MaSP)) { SanPhamDTO hh = new SanPhamDTO(); hh.MaSP = ct.MaSP; hh.SoLuong = ct.SoLuong; sanphambus.CongSL(hh); } } if (kq == lstchitiet.Count) { XtraMessageBox.Show("Thanh toán thành công", "Thông báo", MessageBoxButtons.OK); frmHoaDonNhapHang frm1 = new frmHoaDonNhapHang(); frm1.MaHDN = txtMHD.Text; frm1.ShowDialog(); } else { XtraMessageBox.Show("Thanh toán thất bại", "Thông báo"); } } catch (Exception) { XtraMessageBox.Show("Bạn chưa nhập hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } gctSanPham.DataSource = sanphambus.DanhSachSanPham(); for (int i = 0; i < gridView2.RowCount;) { gridView2.DeleteRow(i); } } else { XtraMessageBox.Show("Bạn chưa chọn hàng cần nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); } lblThanhTien.Text = ""; lblTT.Text = ""; txtSL.Text = ""; TangHD(); }