private void butPdf_Click(object sender, EventArgs e) { string tenfile = ReportFile.ToLower().Replace(".rpt", ""); tenfile = ExportPath + tenfile + ".pdf"; crDiskFileDestinationOptions = new DiskFileDestinationOptions(); crExportOptions = oRpt.ExportOptions; crDiskFileDestinationOptions.DiskFileName = tenfile; crExportOptions.DestinationOptions = crDiskFileDestinationOptions; crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; oRpt.Export(); try { string filerun = "AcroRd32.exe", arg = tenfile; if (System.IO.File.Exists(arg)) { backup f = new backup(filerun, arg, true); f.Launch(); } } catch { MessageBox.Show(lan.Change_language_MessageText("Tập tin :") + " " + tenfile); } }
private void butOk_Click(object sender, System.EventArgs e) { if (i_loai == 0) { s_dir = this.thumuc.Text; d.close(); this.Close(); } else { d.upd_thongso(i_nhom, 3, "Sao lưu số liệu", thumuc.Text.ToString().Trim()); backup f; string ip, post, owner, user, database, file, arg, path, tenfile, ngay = DateTime.Now.Day.ToString().PadLeft(2, '0') + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Year.ToString().PadLeft(4, '0') + DateTime.Now.Hour.ToString().PadLeft(2, '0') + DateTime.Now.Minute.ToString().PadLeft(2, '0'); path = thumuc.Text + "\\" + ngay + "\\"; file = @"pg_dump.exe"; user = d.user; ip = d.Maincode("Ip"); post = d.Maincode("Post"); owner = d.Maincode("UserID"); if (owner == "") { owner = "medisoft"; } database = d.Maincode("Database"); if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } tenfile = user; arg = " -i -h " + ip + " -p " + post + " -U " + owner + " -F c -o -v -f " + path + tenfile + ".backup -n " + tenfile + " " + database; f = new backup(file, arg, true); f.Launch(); foreach (DataRow r in d.get_data("select * from " + user + ".table where bak=0").Tables[0].Rows) { tenfile = user + r["mmyy"].ToString(); arg = " -i -h " + ip + " -p " + post + " -U " + owner + " -F c -o -v -f " + path + tenfile + ".backup -n " + tenfile + " " + database; f = new backup(file, arg, true); f.Launch(); } zip.AddFiles(thumuc.Text + "\\" + ngay + ".zip", path); zip.DeleteFiles(path); zip.DeleteDirectory(path); } }