CkClassCommon.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using Infragistics.Win;
  8. using Infragistics.Win.UltraWinEditors;
  9. using Infragistics.Win.UltraWinGrid;
  10. namespace Pur.ck
  11. {
  12. class CkClassCommon
  13. {
  14. //激活输入当前值行数据
  15. /// <summary>
  16. /// 激活输入当前值行数据
  17. /// </summary>
  18. /// <param name="ug">ultragrid</param>
  19. /// <param name="strColumn">列名</param>
  20. /// <param name="strKey">列值</param>
  21. public static string doActiveSelRow(UltraGrid ug, string strColumn, string strKey)
  22. {
  23. try
  24. {
  25. if (strKey != "")
  26. {
  27. foreach (UltraGridRow row in ug.Rows)
  28. {
  29. if (row.Cells[strColumn].Text.ToString() == strKey)
  30. {
  31. row.Activated = true;
  32. if (row.ChildBands != null)
  33. row.Expanded = true;
  34. }
  35. }
  36. }
  37. return "";
  38. }
  39. catch (Exception ex)
  40. {
  41. return ex.ToString();
  42. }
  43. }
  44. public static string getYearMouth()
  45. {
  46. string NowYearMouth = DateTime.Now.ToString("yyyyMM");
  47. return NowYearMouth;
  48. }
  49. /// <summary>
  50. /// 绑定combobox
  51. /// </summary>
  52. /// <param name="cmbx">控件名</param>
  53. /// <param name="dset">数据源ds</param>
  54. /// <param name="strVal">值</param>
  55. /// <param name="strName">显示名</param>
  56. /// <param name="filCondition">筛选条件</param>
  57. /// <param name="tips">是否新增</param>
  58. /// <param name="addItem">新增itemName</param>
  59. public static void FilComboboxAdd(UltraComboEditor cmbx, DataTable dt, string strVal, string strName, string filCondition, Boolean tips, String addItemName, String addItemValue)
  60. {
  61. if (dt.Columns.Count > 1)
  62. {
  63. DataView dvw = dt.DefaultView;
  64. dvw.RowFilter = filCondition;
  65. ArrayList aryTmp = new ArrayList();
  66. if (tips == true)
  67. {
  68. aryTmp.Add(new ValueListItem(addItemValue, addItemName));
  69. }
  70. for (int i = 0; i < dvw.Count; i++)
  71. {
  72. aryTmp.Add(new ValueListItem(dvw[i][strVal].ToString(), dvw[i][strName].ToString()));
  73. }
  74. cmbx.DataSource = aryTmp;
  75. cmbx.DisplayMember = "DisplayText";
  76. cmbx.ValueMember = "DataValue";
  77. }
  78. }
  79. }
  80. }