public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { DS_DIEM_LopTC rpt = new DS_DIEM_LopTC(); rpt.Site = this.Site; return(rpt); }
private void btnXuat_SVlopTC_Click(object sender, EventArgs e) { if (tbMalop_SVlopTC.Text.Trim() == "") { MessageBox.Show("Mã lớp không được để trống!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DataTable tb = new DataTable(); string tenGV; using (SqlConnection cnn = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand("dsSVlopTC", cnn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@maloptc", tbMalop_SVlopTC.Text.Trim()); using (SqlDataAdapter ad = new SqlDataAdapter(cmd)) { ad.Fill(tb); } } string query2 = @"select tenGV from LopTinChi ltc inner join GiangVien gv on ltc.maGiangVienFK =gv.maGV where maLopTC=N'" + tbMalop_SVlopTC.Text.Trim() + "'"; using (SqlCommand cmd = new SqlCommand(query2, cnn)) { cmd.CommandType = CommandType.Text; using (SqlDataAdapter ad = new SqlDataAdapter(cmd)) { DataTable tbTemp = new DataTable(); ad.Fill(tbTemp); tenGV = tbTemp.Rows[0]["tenGV"].ToString().Trim(); } } } DS_DIEM_LopTC ds = new DS_DIEM_LopTC(); ((TextObject)ds.Section2.ReportObjects["tbSiso"]).Text = tb.Rows.Count.ToString(); ((TextObject)ds.Section2.ReportObjects["tbGV"]).Text = tenGV; ds.SetDataSource(tb); InBaoCao bc = new InBaoCao(); bc.CrystalReportViewer1.ReportSource = ds; bc.ShowDialog(); }