ShowCheckCtrl.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. namespace DW5S.App.PopupControl
  16. {
  17. public partial class ShowCheckCtrl : DevExpress.XtraEditors.XtraUserControl
  18. {
  19. PosRes posItem;
  20. List<CheckRes> list = new List<CheckRes>();
  21. public ShowCheckCtrl()
  22. {
  23. InitializeComponent();
  24. gridShowCheck.UseDefault(list);
  25. }
  26. public ShowCheckCtrl(PosRes posItem)
  27. : this()
  28. {
  29. this.posItem = posItem;
  30. }
  31. private async void ShowCxCtrl_Load(object sender, EventArgs e)
  32. {
  33. if (posItem.CheckResID == null)//没有检测结果
  34. return;
  35. using (RHDWPartContext db = RHDWPartContext.GetContext(posItem.SigTime))
  36. {
  37. if (db == null) return;
  38. var items = await db.CheckRes.Where(p => p.ID == posItem.CheckResID).ToListAsync();
  39. this.list.AddRange(items);
  40. }
  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. private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
  56. {
  57. if (e.Value == null)
  58. e.DisplayText = "--";
  59. }
  60. }
  61. }