| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Infragistics.Win.UltraWinGrid;
- using System.Windows.Forms;
- using System.Data;
- using System.Collections;
- using Infragistics.Win.UltraWinEditors;
- namespace Pur.Balance
- {
- public class ValueListItem
- {
- public ValueListItem(string sID, string sName)
- {
- ID = sID;
- Name = sName;
- }
- public string ID { get; set; }
- public string Name { get; set; }
- // public override string ToString();
- }
-
- class BalanceClassCommon
- {
- //激活输入当前值行数据
- /// <summary>
- /// 激活输入当前值行数据
- /// </summary>
- /// <param name="ug">ultragrid</param>
- /// <param name="strColumn">列名</param>
- /// <param name="strKey">列值</param>
- public static string doActiveSelRow(UltraGrid ug, string strColumn, string strKey)
- {
- try
- {
- if (strKey != "")
- {
- foreach (UltraGridRow row in ug.Rows)
- {
- if (row.Cells[strColumn].Text.ToString() == strKey)
- {
- row.Activated = true;
- if (row.ChildBands != null)
- row.Expanded = true;
- }
- }
- }
- return "";
- }
- catch (Exception ex)
- {
- return ex.ToString();
- }
- }
- /// <summary>
- /// 设置grid单元格不可编辑
- /// </summary>
- /// <param name="band">grid表格</param>
- /// <param name="strs">可编辑的列头名称数组</param>
- public static void setGridActivation(UltraGridBand band, params string[] strs)
- {
- foreach (UltraGridColumn column in band.Columns)
- {
- if (!strs.Contains(column.Key))
- {
- column.CellActivation = Activation.ActivateOnly;
- }
- else
- {
- column.CellActivation = Activation.AllowEdit;
- }
- }
- }
- /// <summary>
- /// 绑定combobox
- /// </summary>
- /// <param name="cmbx">控件名</param>
- /// <param name="dset">数据源ds</param>
- /// <param name="strVal">值</param>
- /// <param name="strName">显示名</param>
- /// <param name="filCondition">筛选条件</param>
- public static void FilCombobox(UltraComboEditor cmbx, DataSet dset, string strVal, string strName, string filCondition)
- {
- if (dset.Tables.Count > 0 && dset.Tables[0].Columns.Count > 1)
- {
- DataView dvw = dset.Tables[0].DefaultView;
- dvw.RowFilter = filCondition;
- ArrayList aryTmp = new ArrayList();
- for (int i = 0; i < dvw.Count; i++)
- {
- aryTmp.Add(new ValueListItem(dvw[i][strVal].ToString(), dvw[i][strName].ToString()));
- }
- cmbx.DisplayMember = "Name";
- cmbx.ValueMember = "ID";
- cmbx.DataSource = aryTmp;
- }
- }
- /// <summary>
- /// 绑定combobox
- /// </summary>
- /// <param name="cmbx">控件名</param>
- /// <param name="dset">数据源ds</param>
- /// <param name="strVal">值</param>
- /// <param name="strName">显示名</param>
- /// <param name="filCondition">筛选条件</param>
- public static void FilComboboxbyList(UltraComboEditor cmbx, ArrayList list)
- {
- cmbx.DisplayMember = "Name";
- cmbx.ValueMember = "ID";
- cmbx.DataSource = list;
- }
- }
- }
|