private void btnResetPhieu_Click(object sender, EventArgs e) { _lsChiTiet.Clear(); _hoaDon = null; txtTongTien.Text = "0"; dgvChiTietHoaDon.DataSource = null; }
private void btnResetPhieu_Click(object sender, RoutedEventArgs e) { _lsChiTiet.Clear(); _hoaDon = null; txtTongTien.Text = "0"; dgvChiTietHoaDon.ItemsSource = null; MessageBox.Show("Đã Reset Hóa Đơn Thành Công !!!"); btnTruSLM.IsEnabled = false; btnXoaSLM.IsEnabled = false; }
public bool LuuHoaDonXuat(clsHoaDonXuat_DTO hdx_DTO) { string strInsert = "Insert Into HoaDonXuat ([MaHDXuat],[SDTKH],[CMNDNV],[NgayXuat],[TongTien],[TrangThai]) Values (@MaHDXuat,@SDTKH,@CMNDNV,@NgayXuat,@TongTien,1); Select cast(Scope_identity() as int);"; SqlConnection conn = DataProvider.TaoKetNoi(); SqlParameter[] pars = new SqlParameter[5]; pars[0] = new SqlParameter("@MaHDXuat", hdx_DTO.MaHDXuat); pars[1] = new SqlParameter("@SDTKH", hdx_DTO.SDTKH); pars[2] = new SqlParameter("@CMNDNV", hdx_DTO.CMNDNV); pars[3] = new SqlParameter("@NgayXuat", hdx_DTO.NgayXuat); pars[4] = new SqlParameter("@TongTien", hdx_DTO.TongTien); int kq = DataProvider.ThucThiCauLenh(strInsert, pars, conn); return(kq > 0); }
public void InHoaDon(clsHoaDonXuat_DTO _hoaDon, List <clsChiTietHDXuat_DTO> _lsChiTiet) { _lsSanPham = (new clsSanPham_BUS()).DanhSachSanPham(); //Chọn Report hiển thị rpvXemBaoCao.LocalReport.ReportEmbeddedResource = "GUI.rptHoaDon.rdlc"; rpvXemBaoCao.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LayTenSanPhamCTHD); //Đổ dữ liệu rpvXemBaoCao.LocalReport.DataSources.Add(new ReportDataSource("dsChiTiet", _lsChiTiet)); //Set Parameter rpvXemBaoCao.LocalReport.SetParameters(new ReportParameter("paMaHDXuat", _hoaDon.MaHDXuat)); rpvXemBaoCao.LocalReport.SetParameters(new ReportParameter("paCMNDNV", _hoaDon.CMNDNV.ToString())); rpvXemBaoCao.LocalReport.SetParameters(new ReportParameter("paSDTKH", _hoaDon.SDTKH)); rpvXemBaoCao.LocalReport.SetParameters(new ReportParameter("paNgayXuat", _hoaDon.NgayXuat.ToString("dd/MM/yyyy"))); //Hiển thị this.rpvXemBaoCao.RefreshReport(); }
public List <clsHoaDonXuat_DTO> DanhSachHoaDon() { string strSelect = "Select * From HoaDonXuat Where TrangThai = 1"; List <clsHoaDonXuat_DTO> lsResult = new List <clsHoaDonXuat_DTO>(); SqlConnection conn = DataProvider.TaoKetNoi(); SqlDataReader sdr = DataProvider.TruyVanDuLieu(strSelect, conn); while (sdr.Read()) { clsHoaDonXuat_DTO _hdx = new clsHoaDonXuat_DTO(); _hdx.MaHDXuat = sdr["MaHDXuat"].ToString(); _hdx.SDTKH = sdr["SDTKH"].ToString(); _hdx.CMNDNV = int.Parse(sdr["CMNDNV"].ToString()); _hdx.NgayXuat = DateTime.Parse(sdr["NgayXuat"].ToString()); _hdx.TongTien = int.Parse(sdr["TongTien"].ToString()); lsResult.Add(_hdx); } sdr.Close(); conn.Close(); return(lsResult); }
private void btnLuuPhieu_Click(object sender, EventArgs e) { if (txtSDTKH.Text != "") { if (_lsChiTiet.Count > 0) { _lsKhachHang = _khBUS.DanhSachKhachHangTheoSDT(txtSDTKH.Text); _hoaDon = new clsHoaDonXuat_DTO(); if (_lsKhachHang.Count > 0) { } else { try { clsKhachHang_DTO khdto = new clsKhachHang_DTO(); khdto.SDTKH = txtSDTKH.Text; khdto.TenKH = "no-name"; khdto.GioiTinh = false; khdto.DiaChi = "no-express"; khdto.Email = "*****@*****.**"; _khBUS.ThemKhachHang(khdto); } catch (Exception ex) { MessageBox.Show(ex.Message); } //neu khong them } _hoaDon.MaHDXuat = _hdBUS.LayMaTiepTheo(); _hoaDon.SDTKH = txtSDTKH.Text; _hoaDon.CMNDNV = 123456; //_hoaDon.CMNDNV = ((Form1)this.MdiParent).NhanVienDangNhap.CMNDNV; _hoaDon.TongTien = _lsChiTiet.Sum(o => o.ThanhTien); _hoaDon.NgayXuat = DateTime.Now; try { if (_hdBUS.LuuHoaDon(_hoaDon)) { foreach (clsChiTietHDXuat_DTO _cthd in _lsChiTiet) { _cthd.MaHDXuat = _hoaDon.MaHDXuat; _cthdBUS.LuuChiTietHoaDon(_cthd); } MessageBox.Show("Lưu Hóa Đơn Thành công"); btnTinhTien.Enabled = true; } else { MessageBox.Show("Tạo Hóa Đơn Không Thành Công"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Không Có sản Phẩm Nào Để Tạo Hóa Đơn"); } } else { MessageBox.Show("Bạn chưa nhập số điện thoại khách hàng !!!"); } }
public bool LuuHoaDon(clsHoaDonXuat_DTO hdx_DTO) { clsHoaDonXuat_DAO _hoadonDAO = new clsHoaDonXuat_DAO(); return(_hoadonDAO.LuuHoaDonXuat(hdx_DTO)); }