FormLogPrint.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. namespace FPER
  9. {
  10. public partial class FormLogPrint : Form
  11. {
  12. public FormLogPrint()
  13. {
  14. InitializeComponent();
  15. this.ControlPosition();
  16. }
  17. void ControlPosition()
  18. { // form size funtion
  19. this.viewer2.Location = new Point(0, 0);
  20. this.viewer2.Width = this.Width;
  21. this.viewer2.Height = this.Height - 80;
  22. this.button1.Location = new Point(this.button1.Location.X, this.Height - 80);
  23. this.button2.Location = new Point(this.button2.Location.X, this.Height - 80);
  24. this.button3.Location = new Point(this.button3.Location.X, this.Height - 80);
  25. }
  26. public DataDynamics.ActiveReports.Document.Document Document
  27. { //set active report class
  28. set
  29. {
  30. this.viewer2.Document = value;
  31. }
  32. }
  33. private void button2_Click(object sender, EventArgs e)
  34. { // print button click
  35. this.viewer2.Document.Print();
  36. }
  37. private void button3_Click(object sender, EventArgs e)
  38. { // save file button click
  39. this.saveFileDialog1.Filter = "(*.PDF)|*.PDF|(*.XLS)|*.XLS";
  40. if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
  41. {
  42. bool write = true;
  43. if (this.saveFileDialog1.CheckFileExists)
  44. {
  45. if (MessageBox.Show("파일이 존재합니다. 덮어쓰겠습니까?", "", MessageBoxButtons.OKCancel) == DialogResult.OK)
  46. {
  47. write = true;
  48. }
  49. else
  50. {
  51. write = false;
  52. }
  53. }
  54. if (write)
  55. {
  56. if (this.saveFileDialog1.FileName.Substring(this.saveFileDialog1.FileName.Length - 3, 3).ToUpper() == "PDF")
  57. {
  58. this.pdfExport1.Export(this.viewer2.Document, this.saveFileDialog1.FileName);
  59. }
  60. else if (this.saveFileDialog1.FileName.Substring(this.saveFileDialog1.FileName.Length - 3, 3).ToUpper() == "XLS")
  61. {
  62. this.xlsExport1.Export(this.viewer2.Document, this.saveFileDialog1.FileName);
  63. }
  64. }
  65. }
  66. }
  67. private void button1_Click(object sender, EventArgs e)
  68. { // close preview
  69. this.Close();
  70. }
  71. private void FormLogPrint_Resize(object sender, EventArgs e)
  72. { // resize event function
  73. this.ControlPosition();
  74. }
  75. }
  76. }