private void SetVariables(DevExpress.XtraReports.UI.XtraReport rptTmp) { foreach (DictionaryEntry de in Config.Variables) { string key = de.Key.ToString(); if (key.Contains("@")) { key = key.Remove(0, 1); } XRControl xrc = rptTmp.FindControl(key, true); if (xrc != null) { string value = de.Value.ToString(); try { if (value.Contains("/")) { xrc.Text = DateTime.Parse(value).ToShortDateString(); } else { xrc.Text = value; } } catch { xrc.Text = value; } xrc = null; } } }
private void simpleButtonPreview_Click(object sender, EventArgs e) { // if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2) // gridViewReport.ActiveFilterString = "InBaoCao = 1"; DevExpress.XtraReports.UI.XtraReport rptTmp = null; string reportFile, title; if (lcisysFormReport.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always) { DataTable dtFormReport = lookUpEditsysFormReport.Properties.DataSource as DataTable; DataRow dr = dtFormReport.Rows[lookUpEditsysFormReport.ItemIndex]; reportFile = checkEditNgoaiTe.Checked ? dr["ReportFile2"].ToString() : dr["ReportFile"].ToString(); title = checkEditNgoaiTe.Checked ? dr["ReportName2"].ToString() : dr["ReportName"].ToString(); } else { reportFile = checkEditNgoaiTe.Checked ? _data.DrTable["ReportFile2"].ToString() : _data.DrTable["ReportFile"].ToString(); title = checkEditNgoaiTe.Checked ? _data.DrTable["ReportName2"].ToString() : _data.DrTable["ReportName"].ToString(); } string path = ""; if (Config.GetValue("DuongDanBaoCao") != null) { path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("Package").ToString() + "\\" + reportFile + ".repx"; } else { path = Application.StartupPath + "\\Reports\\" + Config.GetValue("Package").ToString() + "\\" + reportFile + ".repx"; } if (System.IO.File.Exists(path)) { rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true); rptTmp.DataSource = gridViewReport.DataSource; if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2) { (rptTmp.DataSource as DataView).RowFilter = "InBaoCao = 1"; } XRControl xrcTitle = rptTmp.FindControl("title", true); if (xrcTitle != null) { xrcTitle.Text = title; } SetVariables(rptTmp); rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; rptTmp.ShowPreviewDialog(); } else { ShowDefaultReport(this.gridControlReport, false); } //gridControlReport.ShowPrintPreview(); if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2) { gridViewReport.ActiveFilterString = ""; } }
//void i_CreateReportFooterArea(object sender, CreateAreaEventArgs e) //{ // if (drDefaultReport == null) return; // e.Graph.BackColor = Color.Transparent; // e.Graph.StringFormat = new BrickStringFormat(StringAlignment.Center); // e.Graph.Font = new Font("Times New Roman", 10, FontStyle.Italic); // if (drDefaultReport["Fleft"].ToString() != string.Empty) // { // e.Graph.DrawString(drDefaultReport["Fleft"].ToString(), Color.Black, new RectangleF(0, 40, (e.Graph.ClientPageSize.Width) / 3, 30), BorderSide.None); // } // if (drDefaultReport["FMid"].ToString() != string.Empty) // { // e.Graph.DrawString(drDefaultReport["FMid"].ToString(), Color.Black, new RectangleF((e.Graph.ClientPageSize.Width - 100) / 3, 40, (e.Graph.ClientPageSize.Width) / 3, 30), BorderSide.None); // } // if (drDefaultReport["FRight"].ToString() != string.Empty) // { // e.Graph.DrawString(drDefaultReport["FRight"].ToString(), Color.Black, new RectangleF(2 * (e.Graph.ClientPageSize.Width - 100) / 3, 40, (e.Graph.ClientPageSize.Width) / 3, 30), BorderSide.None); // } //} //void i_CreateReportHeaderArea(object sender, CreateAreaEventArgs e) //{ // string TenCongTy = Config.GetValue("TenCongTy").ToString(); // string DiaChiCty ; // try // { // DiaChiCty = Config.GetValue("DiaChiCty").ToString(); // } // catch // { // DiaChiCty = Config.GetValue("DiaChi").ToString(); // } // int imagewidth = 0; // if (drDefaultReport != null && drDefaultReport["Logo"].ToString() != string.Empty) // { // imagewidth = 100; // Image im = GetImage(drDefaultReport["Logo"] as byte[]); // e.Graph.DrawImage(im, new RectangleF(0, 0, 100, 100), BorderSide.None, Color.Transparent); // } // //tên công ty // e.Graph.StringFormat = new BrickStringFormat(StringAlignment.Near); // e.Graph.Font = new Font("Times New Roman", 12, FontStyle.Bold); // e.Graph.DrawString(TenCongTy, Color.Black, new RectangleF(imagewidth + 1, 0, e.Graph.ClientPageSize.Width - 150, 20), BorderSide.None); // e.Graph.Font = new Font("Times New Roman", 10, FontStyle.Italic); // e.Graph.DrawString(DiaChiCty, Color.Black, new RectangleF(imagewidth + 1, 20, e.Graph.ClientPageSize.Width - 150, 20), BorderSide.None); // if (drDefaultReport != null && drDefaultReport["Hleft"].ToString() != string.Empty) // { // e.Graph.StringFormat = new BrickStringFormat(StringAlignment.Near); // e.Graph.Font = new Font("Times New Roman", 10, FontStyle.Italic); // e.Graph.DrawString(drDefaultReport["Hleft"].ToString(), Color.Black, new RectangleF(imagewidth + 1, 40, (e.Graph.ClientPageSize.Width - 100) / 3, 30), BorderSide.None); // } // if (drDefaultReport != null && drDefaultReport["HMid"].ToString() != string.Empty) // { // e.Graph.StringFormat = new BrickStringFormat(StringAlignment.Center); // e.Graph.Font = new Font("Times New Roman", 10, FontStyle.Italic); // e.Graph.DrawString(drDefaultReport["HMid"].ToString(), Color.Black, new RectangleF(imagewidth + 1 + (e.Graph.ClientPageSize.Width - 100) / 3, 40, (e.Graph.ClientPageSize.Width - 100) / 3, 30), BorderSide.None); // } // if (drDefaultReport != null && drDefaultReport["HR"].ToString() != string.Empty) // { // e.Graph.StringFormat = new BrickStringFormat(StringAlignment.Far); // e.Graph.Font = new Font("Times New Roman", 10, FontStyle.Italic); // e.Graph.DrawString(drDefaultReport["HR"].ToString(), Color.Black, new RectangleF(imagewidth + 1 + 2 * (e.Graph.ClientPageSize.Width - 100) / 3, 40, (e.Graph.ClientPageSize.Width - 150) / 3, 30), BorderSide.None); // } // e.Graph.StringFormat = new BrickStringFormat(StringAlignment.Center); // e.Graph.Font = new Font("Times New Roman", 14, FontStyle.Bold); // e.Graph.DrawString(_data.DrTable["ReportName"].ToString().ToUpper(), Color.Black, new RectangleF(101, 60, e.Graph.ClientPageSize.Width - 150, 30), BorderSide.None); // //tạo dữ liệu theo điều kiện // string tungay = ""; // string denngay = ""; // string condition = ""; // foreach (DataRow dr in _data.DsStruct.Tables[0].Rows) // { // if (dr["FieldName"].ToString().ToUpper() == "NGAYCT" && bool.Parse(dr["IsBetween"].ToString())) // tungay = "Từ ngày: " + DateTime.Parse((_data as DataReport).reConfig.GetValue("@" + dr["FieldName"].ToString() + "1").ToString()).ToString("dd/MM/yyyy") + " đến ngày: " + DateTime.Parse((_data as DataReport).reConfig.GetValue("@" + dr["FieldName"].ToString() + "2").ToString()).ToString("dd/MM/yyyy"); // else if ((_data as DataReport).reConfig.GetValue("@" + dr["FieldName"].ToString()).ToString() != "") // { // condition += "; " + dr["LabelName"].ToString() + ": " + (_data as DataReport).reConfig.GetValue("@" + dr["FieldName"].ToString()); // } // } // if (condition.Length > 1) condition = condition.Substring(1, condition.Length - 1); // e.Graph.StringFormat = new BrickStringFormat(StringAlignment.Center); // e.Graph.Font = new Font("Times New Roman", 10, FontStyle.Regular); // if (tungay != "") // { // e.Graph.DrawString(tungay + denngay, Color.Black, new RectangleF(101, 90, e.Graph.ClientPageSize.Width - 150, 30), BorderSide.None); // if (condition != "") e.Graph.DrawString(condition, Color.Black, new RectangleF(101, 110, e.Graph.ClientPageSize.Width - 150, 30), BorderSide.None); // } // else if (condition != "") e.Graph.DrawString(condition, Color.Black, new RectangleF(101, 90, e.Graph.ClientPageSize.Width - 150, 30), BorderSide.None); //} private void SetVariables(DevExpress.XtraReports.UI.XtraReport rptTmp) { foreach (DictionaryEntry de in Config.Variables) { string key = de.Key.ToString(); if (key.Contains("@")) { key = key.Remove(0, 1); } XRControl xrc = rptTmp.FindControl(key, true); if (xrc != null) { string value = de.Value.ToString(); DateTime r; if (DateTime.TryParse(value, out r)) { value = DateTime.Parse(value).ToString("dd/MM/yyyy");//.ToShortDateString(); } xrc.Text = value; xrc = null; } } foreach (DictionaryEntry de in (_data as DataReport).reConfig.Variables) { string key = de.Key.ToString(); if (key.Contains("@")) { key = key.Remove(0, 1); } XRControl xrc = rptTmp.FindControl(key, true); if (xrc != null) { string value = de.Value.ToString(); DateTime r; if (DateTime.TryParse(value, out r)) { value = DateTime.Parse(value).ToString("dd/MM/yyyy");//.ToShortDateString(); } xrc.Text = value; xrc = null; } } }
private void SetVariables(DevExpress.XtraReports.UI.XtraReport rptTmp, int lien) { string key = "Lien" + lien.ToString(); XRControl xrc = rptTmp.FindControl("lien", true); if (xrc != null) { try { string value = Config.GetValue(key).ToString(); xrc.Text = value; } catch { xrc.Text = ""; } } }
/// <param name="rptTmp">DevReport file.</param> /// <param name="_Script">Script get data for report.</param> /// <param name="index">Index Row which get data</param> /// <param name="isPrint">Print or Preview</param> /// <param name="j">Liên Parameter</param> private void PrintPreview(DevExpress.XtraReports.UI.XtraReport rptTmp, string _Script, int index, int isPrint, int j) { DataTable dtReport = new DataTable(); try { if (_Script == string.Empty) { dtReport = _data.GetDataForPrint(index); DataMasterDetail dta = (_data as DataMasterDetail); if (dta != null) { richTextBox1.Text = dta.PrintSQL; } } else { dtReport = _data.GetDataForPrint(index, _Script); DataMasterDetail dta = (_data as DataMasterDetail); if (dta != null) { richTextBox1.Text = dta.PrintSQL; } } } catch { } dtReport = AddRecordToData(dtReport); DevExpress.XtraReports.UI.XRControl xrcTitle = rptTmp.FindControl("title", true); if (xrcTitle != null) { xrcTitle.Text = textEditTitle.Text.ToUpper(); } DevExpress.XtraReports.UI.XRControl xrcSoCTGoc = rptTmp.FindControl("SoCTGoc", true); if (xrcSoCTGoc != null) { xrcSoCTGoc.Text = textEditSoCTGoc.Text; } //SetVariables(rptTmp); if (dtReport == null) { return; } rptTmp.DataSource = dtReport; rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; SetVariables(rptTmp); if (Config.GetValue("Language").ToString() == "1") { Translate(rptTmp); } SetVariables(rptTmp, j); rptTmp.ShowPrintMarginsWarning = false; if (isPrint == 0) { rptTmp.Print(); //Update LanIn } else if (isPrint == 1) { rptTmp.ShowPreview(); } else if (isPrint == 2) { SaveFileDialog fd = new SaveFileDialog(); fd.Filter = "(*.xls)|*.xls"; fd.AddExtension = true; fd.ShowDialog(); if (fd.FileName != string.Empty) { rptTmp.ExportToXls(fd.FileName); } } }
private void simpleButton1_Click(object sender, EventArgs e) { DateTime giovao; DateTime giora; if (checkEdit1.Checked) { labelControl1.Text = DateTime.Now.ToString(); labelControl2.Text = DateTime.Now.AddMinutes(70).ToString(); giovao = DateTime.Now; giora = DateTime.Now.AddMinutes(70); } else { labelControl1.Text = DateTime.Now.ToString(); labelControl2.Text = DateTime.Now.AddMinutes(45).ToString(); giovao = DateTime.Now; giora = DateTime.Now.AddMinutes(45); } DevExpress.XtraReports.UI.XtraReport rptTmp = null; string path = ""; if (Config.GetValue("DuongDanBaoCao") != null) { path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("Package").ToString() + "\\MassageTicket.repx"; } else { path = Application.StartupPath + "\\Reports\\" + Config.GetValue("Package").ToString() + "\\MassageTicket.repx"; } if (System.IO.File.Exists(path)) { rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true); //rptTmp.DataSource = gridViewReport.DataSource; XRControl xrcTitle = rptTmp.FindControl("title", true); XRControl xrc = rptTmp.FindControl("Giovao", true); if (xrc != null) { xrc.Text = this.labelControl1.Text; } XRControl xrc1 = rptTmp.FindControl("Giora", true); if (xrc1 != null) { xrc1.Text = this.labelControl2.Text; } XRControl xrc2 = rptTmp.FindControl("Gia", true); if (xrc2 != null) { xrc2.Text = int.Parse(this.textEdit1.Text).ToString("### ### ###"); } rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; rptTmp.PrintDialog(); Database db = Database.NewDataDatabase(); try { db.UpdateDatabyStore("MassageStore", new string[] { "Giovao", "Giora", "Gia" }, new object[] { giovao, giora, double.Parse(textEdit1.Text) }); } catch { } } }
private void PrintOrPreview(bool isPrint, int j) { DevExpress.XtraReports.UI.XtraReport rptTmp = null; string path; if (Config.GetValue("DuongDanBaoCao") != null) { path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("Package").ToString() + "\\" + _reportFile + ".repx"; } else { path = Application.StartupPath + "\\Reports\\" + Config.GetValue("Package").ToString() + "\\" + _reportFile + ".repx"; } if (System.IO.File.Exists(path)) { for (int i = 0; i < _arrIndex.Length; i++) { int index = _arrIndex[i]; DataTable dtReport = _data.GetDataForPrint(index); if (_data.mt.Columns.Contains("PrintIndex")) { _reportFile = tbMau.Rows[int.Parse(_data.mt.Rows[index]["PrintIndex"].ToString())]["RFile"].ToString(); } if (Config.GetValue("DuongDanBaoCao") != null) { path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("Package").ToString() + "\\" + _reportFile + ".repx"; } else { path = Application.StartupPath + "\\Reports\\" + Config.GetValue("Package").ToString() + "\\" + _reportFile + ".repx"; } rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true); DevExpress.XtraReports.UI.XRControl xrcTitle = rptTmp.FindControl("title", true); if (xrcTitle != null) { xrcTitle.Text = textEditTitle.Text.ToUpper(); } DevExpress.XtraReports.UI.XRControl xrcSoCTGoc = rptTmp.FindControl("SoCTGoc", true); if (xrcSoCTGoc != null) { xrcSoCTGoc.Text = textEditSoCTGoc.Text; } //SetVariables(rptTmp); if (dtReport == null) { continue; } rptTmp.DataSource = dtReport; rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; SetVariables(rptTmp); if (Config.GetValue("Language").ToString() == "1") { Translate(rptTmp); } SetVariables(rptTmp, j); if (isPrint) { rptTmp.Print(); } else { rptTmp.ShowPreview(); } } } else { XtraMessageBox.Show("Không tìm thấy file báo cáo " + _reportFile); } }
private void simpleButtonPreview_Click(object sender, EventArgs e) { // if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2) // gridViewReport.ActiveFilterString = "InBaoCao = 1"; DevExpress.XtraReports.UI.XtraReport rptTmp = null; string reportFile, title; DataRow dr = null; if (lcisysFormReport.Visibility == DevExpress.XtraLayout.Utils.LayoutVisibility.Always) { DataTable dtFormReport = lookUpEditsysFormReport.Properties.DataSource as DataTable; dr = dtFormReport.Rows[lookUpEditsysFormReport.ItemIndex]; reportFile = checkEditNgoaiTe.Checked ? dr["ReportFile2"].ToString() : dr["ReportFile"].ToString(); title = checkEditNgoaiTe.Checked ? dr["ReportName2"].ToString() : dr["ReportName"].ToString(); if (dr["FileName"] != DBNull.Value) { System.IO.MemoryStream ms = new System.IO.MemoryStream(dr["FileName"] as byte[]); rptTmp = XtraReport.FromStream(ms, true); } } else { reportFile = checkEditNgoaiTe.Checked ? _data.DrTable["ReportFile2"].ToString() : _data.DrTable["ReportFile"].ToString(); title = checkEditNgoaiTe.Checked ? _data.DrTable["ReportName2"].ToString() : _data.DrTable["ReportName"].ToString(); } string path = ""; if (Config.GetValue("DuongDanBaoCao") != null) { path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("Package").ToString() + "\\" + reportFile + ".repx"; } else { if (!System.IO.File.Exists(path)) { path = Application.StartupPath + "\\Reports\\" + Config.GetValue("Package").ToString() + "\\" + reportFile + ".repx"; } } if (rptTmp == null) { if (System.IO.File.Exists(path)) { rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true); //update vào fileName trên database if (dr != null) { System.IO.Stream stream = System.IO.File.OpenRead(path); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); long numBytes = new FileInfo(path).Length; dr["FileName"] = br.ReadBytes((int)numBytes); _data.UpdateReportFile(dr); } rptTmp.DataSource = gridViewReport.DataSource; if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2) { (rptTmp.DataSource as DataView).RowFilter = "InBaoCao = 1"; } XRControl xrcTitle = rptTmp.FindControl("title", true); if (xrcTitle != null) { xrcTitle.Text = title; } SetVariables(rptTmp); rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; rptTmp.ShowPreviewDialog(); } else { ShowDefaultReport(this.gridControlReport, false); } } else { rptTmp.DataSource = gridViewReport.DataSource; if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2) { (rptTmp.DataSource as DataView).RowFilter = "InBaoCao = 1"; } XRControl xrcTitle = rptTmp.FindControl("title", true); if (xrcTitle != null) { xrcTitle.Text = title; } SetVariables(rptTmp); rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; rptTmp.ShowPreviewDialog(); } //gridControlReport.ShowPrintPreview(); if (Int32.Parse(_data.DrTable["RpType"].ToString()) == 2) { gridViewReport.ActiveFilterString = ""; } }
/// <param name="rptTmp">DevReport file.</param> /// <param name="_Script">Script get data for report.</param> /// <param name="index">Index Row which get data</param> /// <param name="isPrint">Print or Preview</param> /// <param name="j">Liên Parameter</param> private void PrintPreview(DevExpress.XtraReports.UI.XtraReport rptTmp, string _Script, int index, bool isPrint, int j) { DataTable dtReport = new DataTable(); try { if (_Script == string.Empty) { dtReport = _data.GetDataForPrint(index); DataMasterDetail dta = (_data as DataMasterDetail); if (dta != null) { richTextBox1.Text = dta.PrintSQL; } } else { dtReport = _data.GetDataForPrint(index, _Script); DataMasterDetail dta = (_data as DataMasterDetail); if (dta != null) { richTextBox1.Text = dta.PrintSQL; } } } catch { } dtReport = AddRecordToData(dtReport); DevExpress.XtraReports.UI.XRControl xrcTitle = rptTmp.FindControl("title", true); if (xrcTitle != null) { xrcTitle.Text = textEditTitle.Text.ToUpper(); } DevExpress.XtraReports.UI.XRControl xrcSoCTGoc = rptTmp.FindControl("SoCTGoc", true); if (xrcSoCTGoc != null) { xrcSoCTGoc.Text = textEditSoCTGoc.Text; } //SetVariables(rptTmp); if (dtReport == null) { return; } rptTmp.DataSource = dtReport; rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; SetVariables(rptTmp); if (Config.GetValue("Language").ToString() == "1") { Translate(rptTmp); } SetVariables(rptTmp, j); if (isPrint) { rptTmp.Print(); } else { rptTmp.ShowPreview(); } }
private string Kyso(DataRow dr, string Cert) { try { XmlDataDocument document = new XmlDataDocument(); document.Load(DuongDanInvoice + "\\Hoadon.xml"); string fileName = Config.GetValue("MaSoThue").ToString() + "_" + dr["Soseri"].ToString().Replace("/", "") + "_" + dr["SoHoaDon"].ToString(); XmlNode MT32 = document.ChildNodes[1].ChildNodes[0]; MT32.Attributes["MT32ID"].Value = dr["MT32ID"].ToString(); MT32.Attributes["SoHoaDon"].Value = dr["SoHoaDon"].ToString(); MT32.Attributes["Soseri"].Value = dr["Soseri"].ToString(); MT32.Attributes["MaKH"].Value = dr["MaKH"].ToString(); MT32.Attributes["TenKH"].Value = dr["TenKH"].ToString(); MT32.Attributes["NguoiMua"].Value = dr["OngBa"].ToString(); MT32.Attributes["MST"].Value = dr["MST"].ToString(); MT32.Attributes["DiaChi"].Value = dr["DiaChi"].ToString(); MT32.Attributes["Email"].Value = dr["Email"].ToString(); MT32.Attributes["Diengiai"].Value = dr["Diengiai"].ToString(); MT32.Attributes["TTienH"].Value = dr["TTienH"].ToString(); MT32.Attributes["TThue"].Value = dr["TThue"].ToString(); MT32.Attributes["TTien"].Value = dr["TTien"].ToString(); DataRow[] ldrDt = Data.Tables[1].Select("MT32ID='" + dr["MT32ID"].ToString() + "'"); XmlNode OldDT = MT32.ChildNodes[0]; MT32.RemoveChild(OldDT); DataTable tb = Data.Tables[1].Clone(); foreach (DataRow drdt in ldrDt) { XmlNode Dt32 = OldDT.Clone(); Dt32.Attributes["MT32ID"].Value = drdt["MT32ID"].ToString(); Dt32.Attributes["DT32ID"].Value = drdt["DT32ID"].ToString(); Dt32.Attributes["MaVT"].Value = drdt["MaVT"].ToString(); Dt32.Attributes["TenVT"].Value = drdt["TenVT"].ToString(); Dt32.Attributes["TenDVT"].Value = drdt["TenDVT"].ToString(); Dt32.Attributes["Soluong"].Value = drdt["Soluong"].ToString(); Dt32.Attributes["Gia"].Value = drdt["Gia"].ToString(); Dt32.Attributes["PS"].Value = drdt["PS"].ToString(); Dt32.Attributes["Thuesuat"].Value = drdt["Thuesuat"].ToString(); Dt32.Attributes["Thue"].Value = drdt["Thue"].ToString(); MT32.AppendChild(Dt32); //Tạo table gán cho report DataRow drdt1 = tb.NewRow(); drdt1.ItemArray = drdt.ItemArray; tb.Rows.Add(drdt1); } XmlNode Signature = document.ChildNodes[1].ChildNodes[1]; Signature.InnerText = Cert; document.Save(DuongDanInvoice + "\\" + fileName + ".xml"); //Kết xuất file Mẫu hóa đơn string reportFile, title; if (int.Parse(drMauHD["SoDong"].ToString()) > 0) { for (int i = tb.Rows.Count; i < int.Parse(drMauHD["SoDong"].ToString()); i++) { DataRow drdt1 = tb.NewRow(); tb.Rows.Add(drdt1); } } reportFile = DuongDanInvoice + "\\HoaDonMau.repx"; title = "HÓA ĐƠN GIÁ TRỊ GIA TĂNG"; DateTime t = DateTime.Now; Stream rF = File.OpenRead(reportFile); TimeSpan ts = DateTime.Now - t; if (System.IO.File.Exists(reportFile)) { t = DateTime.Now; rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(reportFile, true); rptTmp.Landscape = bool.Parse(drMauHD["Landcap"].ToString()); if (drMauHD["KieuGiay"].ToString() == "A4") { rptTmp.PaperKind = PaperKind.A4; } else if (drMauHD["KieuGiay"].ToString() == "A5") { rptTmp.PaperKind = PaperKind.A5; } //rptTmp = DevExpress.XtraReports.UI.XtraReport.FromStream(rF, true); TimeSpan ts1 = DateTime.Now - t; rptTmp.DataSource = tb; XRControl xrcTitle = rptTmp.FindControl("title", true); if (xrcTitle != null) { xrcTitle.Text = title; } SetVariables(dr, rptTmp, Cert); rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; //MessageBox.Show(IntPtr.Size.ToString()); if (IntPtr.Size == 8) { rptTmp.PrintingSystem.StartPrint += new PrintDocumentEventHandler(PrintingSystem_StartPrint); } string path = DuongDanInvoice + "\\" + fileName + ".pdf"; rptTmp.ExportToPdf(path); //rptTmp.ShowPreview(); //rptTmp.PrintingSystem.PreviewFormEx.KeyUp += new KeyEventHandler(PreviewFormEx_KeyUp); //rptTmp.ShowPreviewDialog(); //Gưi mail cho khach hàng return(SendMail(path, dr)); } else { return("Không tìm thấy file mẫu báo cáo"); } //return string.Empty; } catch (Exception ex) { return(ex.Message); } }