ShowCheckCtrl.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 Serilog;
  16. using DW5S.Service;
  17. namespace DW5S.App.PopupControl
  18. {
  19. public partial class ShowCheckCtrl : DevExpress.XtraEditors.XtraUserControl
  20. {
  21. PosRes posItem;
  22. List<CheckRes> list = new List<CheckRes>();
  23. public ShowCheckCtrl()
  24. {
  25. InitializeComponent();
  26. gridShowCheck.UseDefault(list);
  27. }
  28. public ShowCheckCtrl(PosRes posItem)
  29. : this()
  30. {
  31. this.posItem = posItem;
  32. }
  33. private async void ShowCxCtrl_Load(object sender, EventArgs e)
  34. {
  35. if (posItem.CheckResID == null)//没有检测结果
  36. return;
  37. var unitOfWork = IocContainer.UnitOfWork;
  38. var repsCheck = unitOfWork.Of<CheckRes>();
  39. var items = await repsCheck.FindAsync(p => p.Id == posItem.CheckResID);
  40. this.list.AddRange(items);
  41. gridView1.RefreshData();
  42. }
  43. private void gridView1_CustomDrawEmptyForeground(object sender, DevExpress.XtraGrid.Views.Base.CustomDrawEventArgs e)
  44. {
  45. if (gridView1.RowCount == 0)
  46. {
  47. string txt = "没有检测结果信息";
  48. var s = e.Appearance.CalcTextSize(e.Cache, txt, e.Bounds.Width).ToSize();
  49. var x = (e.Bounds.Width - s.Width) / 2;
  50. var y = (e.Bounds.Height - s.Height) / 2;
  51. e.Appearance.ForeColor = Color.Gray;
  52. e.Appearance.DrawString(e.Cache, txt, new Rectangle(x, y, s.Width, s.Height));
  53. }
  54. }
  55. }
  56. }