MTLFCtrl.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. using Uninpho.Tools.components;
  12. using Uninpho.DBOperation.Model;
  13. using Uninpho.DBOperation.Operation;
  14. using DevExpress.XtraEditors;
  15. using DevExpress.XtraGrid.Views.Grid;
  16. using DevExpress.XtraGrid;
  17. namespace Uninpho.Tools.components.MTLFF
  18. {
  19. public partial class MTLFCtrl : DevExpress.XtraEditors.XtraUserControl
  20. {
  21. public MTLFCtrl()
  22. {
  23. InitializeComponent();
  24. }
  25. private void MTLFCtrl_Load(object sender, EventArgs e)
  26. {
  27. if (UserInform.isconnect)
  28. {
  29. dataSource = DataAnalysisToPG.getfilemtlf();
  30. gridControl1.DataSource = dataSource;
  31. }
  32. ExcelTools.gridControl01 = gridControl1;
  33. ExcelTools.gridView01 = gridView1;
  34. }
  35. List<T_mitielifeng_filelist> dataSource = null;
  36. int i = 1;
  37. /// <summary>
  38. /// 查看文件
  39. /// </summary>
  40. private void repositoryItemHyperLinkEdit2_Click(object sender, EventArgs e)
  41. {
  42. string url = Application.StartupPath + "\\mtlf_temp\\templook"+i.ToString()+".xlsx";
  43. int[] rowhandles = gridView1.GetSelectedRows();
  44. int rowhandle = gridView1.FocusedRowHandle;
  45. string btyearr = gridView1.GetRowCellValue(rowhandle, "Excelbytearr").ToString();
  46. ExcelTools.writeFile(btyearr, url);
  47. //System.Diagnostics.Process.Start(url);
  48. LookDataFromMTLF ldf = new LookDataFromMTLF(url, gridView1,rowhandle);
  49. ldf.StartPosition = FormStartPosition.CenterParent;
  50. ldf.ShowDialog();
  51. i++;
  52. }
  53. /// <summary>
  54. /// 新建
  55. /// </summary>
  56. private void newCreateBtn_Click(object sender, EventArgs e)
  57. {
  58. CreateNewTableMTLF frm = new CreateNewTableMTLF();
  59. frm.StartPosition = FormStartPosition.CenterParent;
  60. if (frm.ShowDialog(this) == DialogResult.OK)
  61. {
  62. }
  63. }
  64. /// <summary>
  65. /// 删除
  66. /// </summary>
  67. private void delPGBtn_Click(object sender, EventArgs e)
  68. {
  69. if (UserInform.userinf.Pow == 0)
  70. {
  71. XtraMessageBox.Show("您无权删除数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  72. }
  73. else
  74. {
  75. var row = gridView1.GetSelectedRows();
  76. if (row.Length == 0)
  77. {
  78. XtraMessageBox.Show("请选中删除的行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
  79. }
  80. else
  81. {
  82. if (XtraMessageBox.Show("是否删除所选?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
  83. {
  84. for (int i = row.Length - 1; i >= 0; i--)
  85. {
  86. var va1 = gridView1.GetRowCellValue(row[i], "Id").ToString();
  87. DataAnalysisToPG.DelToPGMTLF(new T_mitielifeng_filelist()
  88. {
  89. Id = va1,
  90. });
  91. gridView1.DeleteRow(row[i]);
  92. }
  93. XtraMessageBox.Show("删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  94. }
  95. }
  96. }
  97. }
  98. private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  99. {
  100. DataAnalysis.DACommon.addXuHao(e);
  101. }
  102. private void btn_dm_query_Click(object sender, EventArgs e)
  103. {
  104. FilterDate(this.dateEdit1.DateTime, this.dateEdit2.DateTime);
  105. }
  106. public void FilterDate(DateTime start, DateTime end)
  107. {
  108. List<T_mitielifeng_filelist> filterDS = new List<T_mitielifeng_filelist>();
  109. foreach (var item in dataSource)
  110. {
  111. DateTime riqi = DateTime.Parse(item.Riqi);
  112. if ((start <= riqi) && (riqi <= end))
  113. {
  114. filterDS.Add(item);
  115. }
  116. }
  117. this.gridControl1.DataSource = filterDS;
  118. this.gridView1.BestFitColumns();
  119. }
  120. /// <summary>
  121. /// 重置
  122. /// </summary>
  123. private void simpleButton4_Click(object sender, EventArgs e)
  124. {
  125. this.dateEdit1.EditValue = null;
  126. this.dateEdit2.EditValue = null;
  127. this.gridControl1.DataSource = dataSource;
  128. this.gridView1.BestFitColumns();
  129. }
  130. }
  131. }