Exemple #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DataTable cthd = HoaDonBUS.GetCTHD(MaHD);
            DataTable pn   = HoaDonBUS.GetHoaDon(MaHD);

            ReportParameter[] param = new ReportParameter[5];
            param[0] = new ReportParameter("MaHD", "" + MaHD);
            param[1] = new ReportParameter("KhachHang", pn.Rows[0][1].ToString());
            param[2] = new ReportParameter("NguoiLap", pn.Rows[0][2].ToString());
            param[3] = new ReportParameter("NgayLap", pn.Rows[0][3].ToString());
            param[4] = new ReportParameter("TongTien", pn.Rows[0][4].ToString());
            this.reportViewer1.LocalReport.SetParameters(param);
            ReportDataSource rds = new ReportDataSource("DataSet2", cthd);

            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(rds);
            this.reportViewer1.RefreshReport();
        }
        private void btnThemCTHD_Click(object sender, EventArgs e)
        {
            int slton = SanPhamBUS.GetSoLuongTon(long.Parse(cbbMaSP.SelectedValue.ToString()));

            int sl = int.Parse(txtSoLuong.Text);

            if (slton > sl)
            {
                long        gia       = long.Parse(txtDonGia.Text);
                long        thanhtien = sl * gia;
                DTO.CTHDDTO cthd      = new CTHDDTO(MaHD, long.Parse(cbbMaSP.SelectedValue.ToString()), sl, thanhtien);
                HoaDonBUS.InsertCTHD(cthd);
                dgvNhanVien.DataSource = HoaDonBUS.GetCTHD(MaHD);
            }
            else
            {
                MessageBox.Show("Không đủ số lượng hàng!");
            }
        }