| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 | using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using DevComponents.DotNetBar.Layout;using DevComponents.DotNetBar.Controls;namespace WCS_Client.UC{    public class WorkDataUtil    {        public static DataSet GetWorkParameter(List<LayoutControlItem> LCItemList)        {            try            {                List<WorkDataInfo> WorkDataList = new List<WorkDataInfo>();                foreach (LayoutControlItem LCItem in LCItemList)                {                    if (LCItem == null || LCItem.Control == null || LCItem.Tag == null)                    {                        continue;                    }                    List<WorkDataInfo> Tmplist = GetLCItemValue(LCItem);                    if (Tmplist != null)                    {                        WorkDataList.AddRange(Tmplist);                    }                }                List<string> WorkNameList = new List<string>();                foreach (WorkDataInfo witem in WorkDataList)                {                    if (!WorkNameList.Contains(witem.WorkName))                    {                        WorkNameList.Add(witem.WorkName);                    }                }                DataSet ds = new DataSet();                foreach (string wname in WorkNameList)                {                    DataTable dt = new DataTable(wname);                    List<WorkDataInfo> wdlist = WorkDataList.FindAll(a => a.WorkName == wname);                    foreach (WorkDataInfo w in wdlist)                    {                        dt.Columns.Add(w.ParameterName, typeof(string));                    }                    DataRow dr = dt.NewRow();                    foreach (WorkDataInfo w in wdlist)                    {                        dr[w.ParameterName] = w.ParameterData;                    }                    dt.Rows.Add(dr);                    ds.Tables.Add(dt);                }                return ds;            }            catch            {            }            return null;        }        public static List<WorkDataInfo> GetLCItemValue(LayoutControlItem LCItem)        {            try            {                if (LCItem == null || LCItem.Control == null || LCItem.Tag == null)                {                    throw new Exception();                }                List<WorkDataInfo> WorkDataList = new List<WorkDataInfo>();                if (LCItem.Tag is WorkDataInfo)                {                    WorkDataList.Add(LCItem.Tag as WorkDataInfo);                }                else if (LCItem.Tag is List<WorkDataInfo>)                {                    WorkDataList.AddRange(LCItem.Tag as List<WorkDataInfo>);                }                else                {                    throw new Exception();                }                string s = "";                if (LCItem.Control is ComboBoxEx)                {                    ComboBoxEx Citem = LCItem.Control as ComboBoxEx;                    s = Citem.SelectedValue == null ? "" : Citem.SelectedValue.ToString();                }                else if (LCItem.Control is TextBoxX)                {                    s = LCItem.Control.Text;                }                else if (LCItem.Control is LC_DropChkList)                {                    LC_DropChkList Item = LCItem.Control as LC_DropChkList;                    s = ListToString(Item.GetValue());                }                else if (LCItem.Control is DevComponents.Editors.IntegerInput)                {                    DevComponents.Editors.IntegerInput Item = LCItem.Control as DevComponents.Editors.IntegerInput;                    s = Item.Value.ToString();                }                else if (LCItem.Control is CheckBoxX)                {                    CheckBoxX Item = LCItem.Control as CheckBoxX;                    if (Item.Checked)                    {                        s = "1";                    }                    else                    {                        s = "0";                    }                }                else if (LCItem.Control is DevComponents.Editors.DateTimeAdv.DateTimeInput)                {                    DevComponents.Editors.DateTimeAdv.DateTimeInput Item = LCItem.Control as DevComponents.Editors.DateTimeAdv.DateTimeInput;                    s = Item.Value.ToString();                }                else                {                    throw new Exception();                }                foreach (WorkDataInfo witem in WorkDataList)                {                    witem.ParameterData = s;                }                return WorkDataList;            }            catch            {            }            return null;        }        public static String ListToString(List<string> list)        {            string s = "";            if (list != null)            {                int Count = list.Count;                for (int i = 0; i < Count; i++)                {                    if (i == 0)                    {                        s = list[i];                        continue;                    }                    s = s + "," + list[i];                }            }            return s;        }    }    public class WorkDataInfo    {        string _WorkName = "";        /// <summary>        ///  方法名        /// </summary>        public string WorkName        {            get            {                return _WorkName;            }            set            {                _WorkName = value;            }        }        string _ParameterName = "";        /// <summary>        /// 参数名        /// </summary>        public string ParameterName        {            get            {                return _ParameterName;            }            set            {                _ParameterName = value;            }        }        string _ParameterData = "";        /// <summary>        /// 参数数量        /// </summary>        public string ParameterData        {            get            {                return _ParameterData;            }            set            {                _ParameterData = value;            }        }    }}
 |