LoggingForm.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 DevExpress.XtraGrid.Views.BandedGrid;
  12. using System.IO;
  13. namespace Uninpho.Tools.components
  14. {
  15. public partial class LoggingForm : DevExpress.XtraEditors.XtraForm
  16. {
  17. private string path;
  18. private bool isxxxw = false;
  19. //private BandedGridView BV;
  20. private List<DBOperation.Model.T_xxxw_csvdata> data;
  21. private List<StaticLogClass> slclist = new List<StaticLogClass>();
  22. public LoggingForm(string path)
  23. {
  24. InitializeComponent();
  25. this.path = path;
  26. }
  27. public LoggingForm(string path,bool isxxxw, List<DBOperation.Model.T_xxxw_csvdata> data)
  28. {
  29. InitializeComponent();
  30. this.path = path;
  31. this.isxxxw = true;
  32. this.data = data;
  33. }
  34. private void LoggingForm_Load(object sender, EventArgs e)
  35. {
  36. if (File.Exists(path))
  37. {
  38. StreamReader sr = new StreamReader(path);
  39. while (!sr.EndOfStream)
  40. {
  41. StaticLogClass slc = new StaticLogClass();
  42. string[] ss = sr.ReadLine().Split('\t');
  43. string[] rowclo = ss[2].Split('_');
  44. slc.Date = ss[0];
  45. slc.Username = ss[1];
  46. slc.Oldvalue = ss[3];
  47. slc.Newvalue = ss[4];
  48. if (isxxxw)
  49. {
  50. for (int i = 0; i < data.Count; i++)
  51. {
  52. if (data[i].Id == rowclo[0])
  53. {
  54. slc.Row = (i + 1).ToString();
  55. break;
  56. }
  57. }
  58. slc.Column = rowclo[1];
  59. }
  60. else
  61. {
  62. slc.Row = (int.Parse(rowclo[0]) + 1).ToString();
  63. slc.Column = GetColumnChar(int.Parse(rowclo[1].Trim()));
  64. }
  65. slclist.Add(slc);
  66. }
  67. List<StaticLogClass> datascource = slclist.OrderByDescending(o => Convert.ToDateTime(o.Date)).ToList();
  68. gridControl1.DataSource = datascource;
  69. }
  70. }
  71. private static string GetColumnChar(int col)
  72. {
  73. var a = col / 26;
  74. var b = col % 26;
  75. if (a > 0) return GetColumnChar(a - 1) + (char)(b + 65);
  76. return ((char)(b + 65)).ToString();
  77. }
  78. private void gridView1_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  79. {
  80. DataAnalysis.DACommon.addXuHao(e);
  81. }
  82. }
  83. }