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.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 (MySqlContext db=new MySqlContext())
  37. {
  38. if (db == null) return;
  39. var items = await db.CheckRes.Where(p => p.ID == posItem.CheckResID).ToListAsync();
  40. this.list.AddRange(items);
  41. }
  42. gridView1.RefreshData();
  43. }
  44. private void gridView1_CustomDrawEmptyForeground(object sender, DevExpress.XtraGrid.Views.Base.CustomDrawEventArgs e)
  45. {
  46. if (gridView1.RowCount == 0)
  47. {
  48. string txt = "没有检测结果信息";
  49. var s = e.Appearance.CalcTextSize(e.Cache, txt, e.Bounds.Width).ToSize();
  50. var x = (e.Bounds.Width - s.Width) / 2;
  51. var y = (e.Bounds.Height - s.Height) / 2;
  52. e.Appearance.ForeColor = Color.Gray;
  53. e.Appearance.DrawString(e.Cache, txt, new Rectangle(x, y, s.Width, s.Height));
  54. }
  55. }
  56. private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
  57. {
  58. if (e.Value == null)
  59. e.DisplayText = "--";
  60. }
  61. }
  62. }