private void btnPrint_Click(object sender, EventArgs e)
        {
            if (m_SoLuuTru.Trim() == "")
            {
                MessageBox.Show("Bạn vui lòng chọn giấy chuyển tuyến để in!", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                //lblThongBao.Text = "Bạn vui lòng chọn bảng kê để in!";
                //timerThongBao.Enabled = true;
                return;
            }

            try
            {
                clsBaoCao bc = new clsBaoCao();
                clsDM_CSKCB objCSKCB = new clsDM_CSKCB();
                SystemConfig sys = SystemConfig.Instance;

                objCSKCB.GetByKey(sys.MaCSKCB);

                DataTable dt = new DataTable("BaoCao");
                dt = bc.GetBySoLuuTru(m_SoLuuTru,Code);

                string path = string.Format("{0}/Reports/{1}.rpt", Directory.GetCurrentDirectory(), "GiayRaVien");

                ReportDocument rpDocument = new ReportDocument();
                rpDocument.Load(path);
                rpDocument.SetDataSource(dt);

                ParameterDiscreteValue val = new ParameterDiscreteValue();
                val.Value = objCSKCB.TenCSKCB;

                ParameterDiscreteValue TenSYT = new ParameterDiscreteValue();
                TenSYT.Value = conf.TenSYT;

                ParameterValues paramVals = new ParameterValues();
                ParameterValues paramSYT = new ParameterValues();

                paramVals.Add(val);

                paramSYT.Add(TenSYT);

                rpDocument.ParameterFields["TenBenhVien"].CurrentValues = paramVals;

                rpDocument.ParameterFields["TenSYT"].CurrentValues = paramSYT;

                rpDocument.DataDefinition.ParameterFields["TenBenhVien"].ApplyCurrentValues(paramVals);
                rpDocument.DataDefinition.ParameterFields["TenSYT"].ApplyCurrentValues(paramSYT);

                int nCopy = (int)nupPage.Value;
                string PrinterName = cboMayIn.Text;
                rpDocument.PrintOptions.PrinterName = PrinterName;
                rpDocument.PrintToPrinter(nCopy, false, 0, 0);
            }
            catch
            {
                lblThongBao.Text = "Vui lòng kiểm tra lại máy in.";
                timerThongBao.Enabled = true;
            }
        }
        private void frmReport_Load(object sender, EventArgs e)
        {
            try
            {
                clsBaoCao bc = new clsBaoCao();
                clsDM_CSKCB objCSKCB = new clsDM_CSKCB();
                SystemConfig sys = SystemConfig.Instance;

                objCSKCB.GetByKey(sys.MaCSKCB);

                ParameterFields paramFields = new ParameterFields();

                //add ten benh vien
                ParameterField paramField = new ParameterField();
                ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
                paramField.Name = "TenBenhVien";
                paramDiscreteValue.Value = objCSKCB.TenCSKCB;
                paramField.CurrentValues.Add(paramDiscreteValue);
                paramFields.Add(paramField);
                //
                ParameterField paramField1 = new ParameterField();
                ParameterDiscreteValue paramDiscreteValue1 = new ParameterDiscreteValue();
                paramField1.Name = "TenSYT";
                paramDiscreteValue1.Value = sys.TenSYT;
                paramField1.CurrentValues.Add(paramDiscreteValue1);
                paramFields.Add(paramField1);
                DataTable dt = new DataTable("BaoCao");
                if (reportname.Trim().ToLower() == "BCVP".ToLower())
                {

                    dt = bc.GetBangKeNhom1(m_BangKe_Id);
                    dt.Columns.Add("BarCode", typeof(byte[]));

                    //BarcodeLib.Barcode b = new BarcodeLib.Barcode();

                    //if (dt.Rows.Count > 0)
                    //{
                    //    if (!string.IsNullOrEmpty(dt.Rows[0]["MaNguoiBenh"].ToString()))
                    //    {
                    //        Image bar = b.Encode(BarcodeLib.TYPE.CODE128, dt.Rows[0]["MaNguoiBenh"].ToString(), Color.Black, Color.White, 300, 150);
                    //        byte[] imageData = converterByte(bar);
                    //        dt.Rows[0]["BarCode"] = imageData;
                    //    }
                    //}

                    string path = string.Format("{0}/Reports/BCVP_{1}.rpt", Directory.GetCurrentDirectory(), m_LoaiBangKe);
                    rpDocument.Load(path);
                    rpDocument.SetDataSource(dt);

                    repordView.ParameterFieldInfo = paramFields;
                    repordView.ReportSource = rpDocument;
                }
                else
                {
                    dt = bc.GetBySoLuuTru(m_SoLuuTru, m_LoaiGiay);

                    string path = string.Format("{0}/Reports/{1}.rpt", Directory.GetCurrentDirectory(), reportname);
                    rpDocument.Load(path);
                    rpDocument.SetDataSource(dt);

                    repordView.ParameterFieldInfo = paramFields;
                    repordView.ReportSource = rpDocument;
                }
            }
            catch(Exception ex)
            {
            }
        }