Esempio n. 1
0
        private void DgvData_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (cbHoaDon.Checked == true || cbDTNam.Checked == true || cbDTThang.Checked == true)
            {
                if (e.ColumnIndex == DgvData.Columns["Detail"].Index && e.RowIndex >= 0 && e.RowIndex < DgvData.Rows.Count - 1)
                {
                    DTO_HoaDon hd = busTK.curHD(DgvData.CurrentRow.Cells["MaHD"].FormattedValue.ToString());

                    string TenNV = (from DataRow dr in busNv.DanhSachNhanVienAll().Rows
                                    where string.Compare(dr[0].ToString(), hd.MaNV, true) == 0
                                    select dr[2].ToString()).FirstOrDefault();


                    string TenBan = (from DataRow dr in busBan.DanhSachBanALL().Rows
                                     where (int)dr[0] == hd.IdBan
                                     select dr[1].ToString()).FirstOrDefault();


                    DataTable            dtHDCT = busTK.ThongkeHoaDonChitiet(hd.MaHD);
                    CrystalReport.Detail cb     = new CrystalReport.Detail();
                    TextObject           txtnv  = (TextObject)cb.ReportDefinition.Sections["Section1"].ReportObjects["txtTenNV"];
                    txtnv.Text = TenNV;
                    TextObject txtDate = (TextObject)cb.ReportDefinition.Sections["Section1"].ReportObjects["TxtNgayHD"];
                    txtDate.Text = hd.NgayHD.ToString("dd/MM/yyyy");
                    TextObject txthd = (TextObject)cb.ReportDefinition.Sections["Section2"].ReportObjects["txtMaHD"];
                    txthd.Text = hd.MaHD;
                    TextObject txtvt = (TextObject)cb.ReportDefinition.Sections["Section2"].ReportObjects["txtViTri"];
                    txtvt.Text = TenBan;
                    TextObject txtkh = (TextObject)cb.ReportDefinition.Sections["Section2"].ReportObjects["txtKH"];
                    txtkh.Text = hd.SDT_KH;
                    TextObject txtkm = (TextObject)cb.ReportDefinition.Sections["Section4"].ReportObjects["TextKM"];
                    txtkm.Text = hd.KhuyenMai.ToString() + "%";
                    TextObject txttongtien = (TextObject)cb.ReportDefinition.Sections["Section5"].ReportObjects["TxtTongTien"];
                    txttongtien.Text = (hd.ThanhTien * 100 / (100 - hd.KhuyenMai)).ToString();
                    TextObject txtThanhTien = (TextObject)cb.ReportDefinition.Sections["Section5"].ReportObjects["txtThanhtien"];
                    txtThanhTien.Text = hd.ThanhTien.ToString();

                    TextObject txtname = (TextObject)cb.ReportDefinition.Sections["Section1"].ReportObjects["TextName"];
                    txtname.Text = "CHI TIẾT HOÁ ĐƠN";

                    cb.Database.Tables["CTHD"].SetDataSource(dtHDCT);

                    frmDetail frm = new frmDetail(cb);
                    frm.Show();
                }
            }
        }
Esempio n. 2
0
        public frmDetail(CrystalReport.Detail detail)
        {
            InitializeComponent();

            crystalReportViewer1.ReportSource = detail;
        }