ShowCheckCtrl.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using DevExpress.XtraEditors;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Documents;
  11. using System.Windows.Forms;
  12. using DW5S.App.Model;
  13. using DW5S.Entity;
  14. using DW5S.Repostory;
  15. using Microsoft.Extensions.Logging;
  16. namespace DW5S.App.PopupControl
  17. {
  18. public partial class ShowCheckCtrl : DevExpress.XtraEditors.XtraUserControl
  19. {
  20. [Autowired]
  21. private readonly ILogger logger;
  22. [Autowired]
  23. private readonly UnitOfWork unitOfWork;
  24. PosRes posItem;
  25. List<CheckRes> list = new List<CheckRes>();
  26. public ShowCheckCtrl()
  27. {
  28. InitializeComponent();
  29. gridShowCheck.UseDefault(list);
  30. }
  31. public ShowCheckCtrl(PosRes posItem)
  32. : this()
  33. {
  34. this.posItem = posItem;
  35. }
  36. private async void ShowCxCtrl_Load(object sender, EventArgs e)
  37. {
  38. if (posItem.CheckResID == null)//没有检测结果
  39. return;
  40. var repsCheck = unitOfWork.Of<CheckRes>();
  41. var items = await repsCheck.FindAsync(p => p.Id == posItem.CheckResID);
  42. this.list.AddRange(items);
  43. gridView1.RefreshData();
  44. }
  45. private void gridView1_CustomDrawEmptyForeground(object sender, DevExpress.XtraGrid.Views.Base.CustomDrawEventArgs e)
  46. {
  47. if (gridView1.RowCount == 0)
  48. {
  49. string txt = "没有检测结果信息";
  50. var s = e.Appearance.CalcTextSize(e.Cache, txt, e.Bounds.Width).ToSize();
  51. var x = (e.Bounds.Width - s.Width) / 2;
  52. var y = (e.Bounds.Height - s.Height) / 2;
  53. e.Appearance.ForeColor = Color.Gray;
  54. e.Appearance.DrawString(e.Cache, txt, new Rectangle(x, y, s.Width, s.Height));
  55. }
  56. }
  57. }
  58. }