ShowCheckCtrl.cs 2.2 KB

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