Exemplo n.º 1
0
 public void BindComboBox(object obj, List <HR_EmployeeResult> empList)
 {
     if (obj is Controls.UcComboBox)
     {
         Controls.UcComboBox c = obj as Controls.UcComboBox;
         c.ValueMember   = "EmpID";
         c.DisplayMember = "EmpName";
         c.DataSource    = empList;
     }
     else if (obj is DataGridViewComboBoxColumn)
     {
         DataGridViewComboBoxColumn c = obj as DataGridViewComboBoxColumn;
         c.ValueMember   = "EmpID";
         c.DisplayMember = "EmpName";
         c.DataSource    = empList;
     }
     else if (obj is DataGridViewComboBoxExColumn)
     {
         DataGridViewComboBoxExColumn c = obj as DataGridViewComboBoxExColumn;
         c.ValueMember   = "EmpID";
         c.DisplayMember = "EmpName";
         c.DataSource    = empList;
     }
     else if (obj is GridComboBoxExEditControl)
     {
         GridComboBoxExEditControl c = obj as GridComboBoxExEditControl;
         c.ValueMember   = "EmpID";
         c.DisplayMember = "EmpName";
         c.DataSource    = empList;
     }
 }
Exemplo n.º 2
0
 public void BindComboBox(Controls.UcComboBox c, HR_OrgParam param)
 {
     if (c != null && param != null)
     {
         List <HR_OrgResult> orgList = this.GetOrgTree(param);
         c.ValueMember   = "OrgID";
         c.DisplayMember = "OrgName";
         c.DataSource    = orgList;
     }
 }
Exemplo n.º 3
0
 public void BindComboBox(Controls.UcComboBox c, HR_DepartmentParam param)
 {
     if (c != null && param != null)
     {
         List <HR_DepartmentResult> deptList = this.GetDeptList(param);
         c.ValueMember   = "DeptID";
         c.DisplayMember = "DeptName";
         c.DataSource    = deptList;
     }
 }
Exemplo n.º 4
0
 public void BindComboBox(Controls.UcComboBox c, CRM_ZoneParam param)
 {
     if (c != null && param != null)
     {
         List <CRM_ZoneResult> zoneList = this.GetList(param);
         zoneList.Insert(0, new CRM_ZoneResult {
             Name_CN = ""
         });
         c.ValueMember   = "Name_CN";
         c.DisplayMember = "Name_CN";
         c.DataSource    = zoneList;
     }
 }
Exemplo n.º 5
0
 private void CascadingDropDown(Controls.UcComboBox c, Controls.UcComboBox pc, int ztype)
 {
     if (pc.Text.Trim() != "")
     {
         CRM_ZoneResult rst = zoneLogic.GetInfo(new CRM_ZoneParam {
             Name_CN = pc.Text
         });
         if (rst != null)
         {
             zoneLogic.BindComboBox(c, new CRM_ZoneParam {
                 ZType = ztype, PZID = rst.ZID
             });
         }
         else
         {
             c.DataSource = null;
         }
     }
     else
     {
         c.DataSource = null;
     }
 }
Exemplo n.º 6
0
        public void BindComboBox(object obj, string itemCode, List <SYS_DictItemLineResult> rst)
        {
            DataValueType valueType = DataValueType.String;

            if (obj is Controls.UcComboBox)
            {
                Controls.UcComboBox c = obj as Controls.UcComboBox;
                if (c != null && !string.IsNullOrEmpty(itemCode))
                {
                    List <KeyValuePair <string, object> > kvList = new List <KeyValuePair <string, object> >();
                    List <SYS_DictItemLineResult>         list   = rst.Where(a => a.ItemCode == itemCode).ToList();
                    if (list != null && list.Count > 0)
                    {
                        kvList    = list.Select(a => new KeyValuePair <string, object>(a.ItemValue, a.ItemValue2)).ToList();
                        valueType = list[0].ValueType;
                    }
                    kvList.Insert(0, new KeyValuePair <string, object>("", ""));
                    c.ValueMember   = "Value";
                    c.DisplayMember = "Key";
                    if (valueType == DataValueType.Int32)
                    {
                        c.DataSource = kvList.Select(a => new KeyValuePair <string, int?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (int?)a.Value.ToInt32()))).ToList();
                    }
                    else if (valueType == DataValueType.Decimal)
                    {
                        c.DataSource = kvList.Select(a => new KeyValuePair <string, decimal?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == ""?null:(decimal?)a.Value.ToDecimal()))).ToList();
                    }
                    else if (valueType == DataValueType.Boolean)
                    {
                        c.DataSource = kvList.Select(a => new KeyValuePair <string, bool?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == ""?null:(bool?)a.Value.ToBooleanHasNull()))).ToList();
                    }
                    else
                    {
                        c.DataSource = kvList;
                    }
                }
            }
            else if (obj is DataGridViewComboBoxColumn)
            {
                DataGridViewComboBoxColumn c = obj as DataGridViewComboBoxColumn;
                if (c != null && !string.IsNullOrEmpty(itemCode))
                {
                    List <KeyValuePair <string, object> > kvList = new List <KeyValuePair <string, object> >();
                    List <SYS_DictItemLineResult>         list   = rst.Where(a => a.ItemCode == itemCode).ToList();
                    if (list != null && list.Count > 0)
                    {
                        kvList    = list.Select(a => new KeyValuePair <string, object>(a.ItemValue, a.ItemValue2)).ToList();
                        valueType = list[0].ValueType;
                    }
                    kvList.Insert(0, new KeyValuePair <string, object>("", ""));
                    c.ValueMember   = "Value";
                    c.DisplayMember = "Key";
                    if (valueType == DataValueType.Int32)
                    {
                        c.DataSource = kvList.Select(a => new KeyValuePair <string, int?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (int?)a.Value.ToInt32()))).ToList();
                    }
                    else if (valueType == DataValueType.Decimal)
                    {
                        c.DataSource = kvList.Select(a => new KeyValuePair <string, decimal?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (decimal?)a.Value.ToDecimal()))).ToList();
                    }
                    else if (valueType == DataValueType.Boolean)
                    {
                        c.DataSource = kvList.Select(a => new KeyValuePair <string, bool?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (bool?)a.Value.ToBooleanHasNull()))).ToList();
                    }
                    else
                    {
                        c.DataSource = kvList;
                    }
                }
            }
            else if (obj is DataGridViewComboBoxExColumn)
            {
                DataGridViewComboBoxExColumn c = obj as DataGridViewComboBoxExColumn;
                if (c != null && !string.IsNullOrEmpty(itemCode))
                {
                    List <KeyValuePair <string, object> > kvList = new List <KeyValuePair <string, object> >();
                    List <SYS_DictItemLineResult>         list   = rst.Where(a => a.ItemCode == itemCode).ToList();
                    if (list != null && list.Count > 0)
                    {
                        kvList    = list.Select(a => new KeyValuePair <string, object>(a.ItemValue, a.ItemValue2)).ToList();
                        valueType = list[0].ValueType;
                    }
                    kvList.Insert(0, new KeyValuePair <string, object>("", ""));
                    c.ValueMember   = "Value";
                    c.DisplayMember = "Key";
                    if (valueType == DataValueType.Int32)
                    {
                        c.DataSource = kvList.Select(a => new KeyValuePair <string, int?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (int?)a.Value.ToInt32()))).ToList();
                    }
                    else if (valueType == DataValueType.Decimal)
                    {
                        c.DataSource = kvList.Select(a => new KeyValuePair <string, decimal?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (decimal?)a.Value.ToDecimal()))).ToList();
                    }
                    else if (valueType == DataValueType.Boolean)
                    {
                        c.DataSource = kvList.Select(a => new KeyValuePair <string, bool?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (bool?)a.Value.ToBooleanHasNull()))).ToList();
                    }
                    else
                    {
                        c.DataSource = kvList;
                    }
                }
            }
            else if (obj is GridComboBoxExEditControl)
            {
                GridComboBoxExEditControl c = obj as GridComboBoxExEditControl;
                if (c != null && !string.IsNullOrEmpty(itemCode))
                {
                    List <KeyValuePair <string, object> > kvList = new List <KeyValuePair <string, object> >();
                    List <SYS_DictItemLineResult>         list   = rst.Where(a => a.ItemCode == itemCode).ToList();
                    if (list != null && list.Count > 0)
                    {
                        kvList    = list.Select(a => new KeyValuePair <string, object>(a.ItemValue, a.ItemValue2)).ToList();
                        valueType = list[0].ValueType;
                    }
                    kvList.Insert(0, new KeyValuePair <string, object>("", ""));
                    c.ValueMember   = "Value";
                    c.DisplayMember = "Key";
                    if (valueType == DataValueType.Int32)
                    {
                        c.DataSource = kvList.Select(a => new KeyValuePair <string, int?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (int?)a.Value.ToInt32()))).ToList();
                    }
                    else if (valueType == DataValueType.Decimal)
                    {
                        c.DataSource = kvList.Select(a => new KeyValuePair <string, decimal?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (decimal?)a.Value.ToDecimal()))).ToList();
                    }
                    else if (valueType == DataValueType.Boolean)
                    {
                        c.DataSource = kvList.Select(a => new KeyValuePair <string, bool?>(a.Key, (a.Value == null || a.Value.ToStringHasNull() == "" ? null : (bool?)a.Value.ToBooleanHasNull()))).ToList();
                    }
                    else
                    {
                        c.DataSource = kvList;
                    }
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 设置下拉列表中的值
        /// </summary>
        /// <param name="findCombol">查找文本列表对象</param>
        /// <param name="findValue">查找值</param>
        /// <param name="isFindValue">是否比对值</param>
        public static void SetCombolSelectedIndex(object findCombol, object findValue, bool isFindValue)
        {
            int step = -1;

            if (findCombol is Controls.UcComboBox)
            {
                Controls.UcComboBox c = findCombol as Controls.UcComboBox;
                string bindValueField = c.ValueMember;
                string bindTextField  = c.DisplayMember;

                foreach (object info in c.Items)//KeyValuePair<object, object>
                {
                    step++;
                    #region 遍历值
                    if (isFindValue)
                    {
                        object val = info.GetType().GetProperty(bindValueField).GetValue(info, null);
                        if (val.GetType() == typeof(string))
                        {
                            if (val.ToStringHasNull() == findValue.ToStringHasNull())
                            {
                                break;
                            }
                        }
                        else if (val.GetType() == typeof(int))
                        {
                            if (val.ToInt32() == findValue.ToInt32())
                            {
                                break;
                            }
                        }
                        else if (val.GetType() == typeof(decimal))
                        {
                            if (val.ToDecimal() == findValue.ToDecimal())
                            {
                                break;
                            }
                        }
                    }
                    #endregion
                    #region 比对文本
                    else
                    {
                        object val = info.GetType().GetProperty(bindTextField).GetValue(info, null);
                        if (val.GetType() == typeof(string))
                        {
                            if (val.ToStringHasNull() == findValue.ToStringHasNull())
                            {
                                break;
                            }
                        }
                        else if (val.GetType() == typeof(int))
                        {
                            if (val.ToInt32() == findValue.ToInt32())
                            {
                                break;
                            }
                        }
                        else if (val.GetType() == typeof(decimal))
                        {
                            if (val.ToDecimal() == findValue.ToDecimal())
                            {
                                break;
                            }
                        }
                    }
                    #endregion
                }
                c.SelectedIndex = step;
            }
        }