MTLFFListFrom.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.Linq;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using DevExpress.XtraEditors;
  11. using System.IO;
  12. using Uninpho.DBOperation.Operation;
  13. namespace Uninpho.Tools.components.MTLFF
  14. {
  15. public partial class MTLFFListFrom : DevExpress.XtraEditors.XtraForm
  16. {
  17. bool isall = true;
  18. public MTLFFListFrom()
  19. {
  20. InitializeComponent();
  21. }
  22. /// <summary>
  23. /// 保存至本地
  24. /// </summary>
  25. private void simpleButton2_Click(object sender, EventArgs e)
  26. {
  27. SaveFileDialog sfd = new SaveFileDialog();
  28. sfd.Filter = "xlsx files(*.xlsx)|*.xlsx|All files(*.*)|*.*";
  29. sfd.FileName = "道岔全面检查记录表";
  30. if (sfd.ShowDialog() == DialogResult.OK)
  31. {
  32. sheetControl01.SaveDocument(sfd.FileName);
  33. XtraMessageBox.Show("保存完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  34. this.Close();
  35. }
  36. }
  37. /// <summary>
  38. /// 保存至数据库
  39. /// </summary>
  40. private void simpleButton1_Click(object sender, EventArgs e)
  41. {
  42. sheetControl01.SaveDocument(ExcelTools.filenameall);
  43. var uid = MTLFCommon.SaveExcel2PG();
  44. //MTLFCommon.saveExcelData2PG();
  45. if (isall)
  46. {
  47. var nowdata = DataAnalysisToPG.getfilemtlf();
  48. ExcelTools.gridControl01.DataSource = nowdata;
  49. for (int i = 0; i < nowdata.Count; i++)
  50. {
  51. if (ExcelTools.gridView01.GetRowCellValue(i, "Id").ToString() == uid)
  52. {
  53. ExcelTools.gridView01.SelectRow(i);
  54. }
  55. }
  56. XtraMessageBox.Show("保存完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  57. this.Close();
  58. }
  59. }
  60. /// <summary>
  61. /// 保存至数据库和本地
  62. /// </summary>
  63. private void simpleButton4_Click(object sender, EventArgs e)
  64. {
  65. try
  66. {
  67. isall = false;
  68. simpleButton1_Click(sender, e);
  69. simpleButton2_Click(sender, e);
  70. isall = true;
  71. }
  72. catch (Exception)
  73. {
  74. throw;
  75. }
  76. }
  77. private void simpleButton3_Click(object sender, EventArgs e)
  78. {
  79. File.Delete(ExcelTools.filenameall);
  80. this.Close();
  81. }
  82. private void MTLFFListFrom_Load(object sender, EventArgs e)
  83. {
  84. DataAnalysis.DACommon.DirectoryInit(Application.StartupPath + "\\mtlf_temp");
  85. DataAnalysis.DACommon.FileCopy(Application.StartupPath + "\\mtlfdemo.xlsx", ExcelTools.filenameall);
  86. ExcelTools.initNewTableExcel();
  87. sheetControl01.LoadDocument(ExcelTools.filenameall);
  88. ExcelTools.sheetControldemo = sheetControl01;
  89. //sheetControl01.LoadDocument(new byte[],);
  90. }
  91. private void MTLFFListFrom_FormClosed(object sender, FormClosedEventArgs e)
  92. {
  93. }
  94. }
  95. }