ucHmpDevInfo.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using System.Collections;
  5. using Core.LgMes.Client.Comm;
  6. namespace Core.LgMes.Client.LgJobMgt
  7. {
  8. public partial class ucHmpDevInfo : UserControl
  9. {
  10. public Image m_imageDefault = null;
  11. public ucHmpDevInfo()
  12. {
  13. InitializeComponent();
  14. CStaticMethod.SetUltraGridStyle(ultraGrid1, 2); //设置样式
  15. }
  16. private void ucHmpDevInfo_Load(object sender, EventArgs e)
  17. {
  18. ultraDataSource1.Rows.Add(new object[] { "", "", "", "", "", "", "", "", "" });
  19. }
  20. public void ResetData()
  21. {
  22. try
  23. {
  24. for (int i = 0; i < this.ultraDataSource1.Band.Columns.Count; i++)
  25. {
  26. if (this.ultraDataSource1.Band.Columns[i].DataType == typeof(System.DateTime))
  27. this.ultraDataSource1.Rows[0][i] = null;
  28. else if(this.ultraDataSource1.Band.Columns[i].DataType == typeof(System.Drawing.Bitmap))
  29. ultraDataSource1.Rows[0]["TP"] = m_imageDefault;
  30. else
  31. this.ultraDataSource1.Rows[0][i] = "";
  32. }
  33. }
  34. catch { }
  35. }
  36. public void SetData(Hashtable ar)
  37. {
  38. if (ar == null || ar.Count == 0)
  39. return;
  40. int count = this.ultraDataSource1.Band.Columns.Count;
  41. string strKey = "";
  42. for (int i = 0; i < count; i++)
  43. {
  44. try
  45. {
  46. strKey = this.ultraDataSource1.Band.Columns[i].Key;
  47. if (ar.Contains(strKey) && !string.IsNullOrEmpty(ar[strKey].ToString()))
  48. this.ultraDataSource1.Rows[0][i] = ar[strKey];
  49. else
  50. {
  51. if (this.ultraDataSource1.Band.Columns[i].DataType == typeof(System.DateTime))
  52. this.ultraDataSource1.Rows[0][i] = null;
  53. else
  54. this.ultraDataSource1.Rows[0][i] = "";
  55. }
  56. }
  57. catch { }
  58. }
  59. }
  60. }
  61. }