Beispiel #1
0
 public static void BindControl(this ListControl bindControl, DataTable dataTable, string textField, string valueField, HeaderType headerType = 0)
 {
     bindControl.Items.Clear();
     if (headerType != HeaderType.None)
     {
         bindControl.Items.Add(new ListItem(headerType.GetEnumDescription(), ""));
     }
     foreach (DataRow row in dataTable.Rows)
     {
         bindControl.Items.Add(new ListItem(row[textField].ToString(), row[valueField].ToString()));
     }
 }
Beispiel #2
0
 public static void BindEnumControl(this ListControl bindControl, Type enumType, ShowEnumType text, ShowEnumType value, HeaderType headerType = 0)
 {
     bindControl.Items.Clear();
     if (headerType != HeaderType.None)
     {
         bindControl.Items.Add(new ListItem(headerType.GetEnumDescription(), ""));
     }
     foreach (EnumParameter parameter in from s in enumType.GetEnumMembers()
              orderby s.Value
              select s)
     {
         bindControl.Items.Add(new ListItem(GetShowText(parameter, text), GetShowText(parameter, value)));
     }
 }
Beispiel #3
0
    public static void FieldNodeBind(this  ListControl bindControl, XmlNode objXmlNode, string condition, HeaderType headerType = HeaderType.None)
    {
        string ConnectionKey = objXmlNode.ReadAttribute("ConnectionKey");
        string TableName     = objXmlNode.ReadAttribute("TableName");
        string TextField     = objXmlNode.ReadAttribute("TextField");
        string ValueField    = objXmlNode.ReadAttribute("ValueField");
        string NodeCondition = objXmlNode.ReadAttribute("Condition");
        string Sort          = objXmlNode.ReadAttribute("Sort");

        if (!string.IsNullOrWhiteSpace(condition))
        {
            if (string.IsNullOrWhiteSpace(NodeCondition))
            {
                NodeCondition = condition;
            }
            else
            {
                NodeCondition += " and " + condition;
            }
        }

        if (ConnectionKey.IsNoNullOrWhiteSpace() && TableName.IsNoNullOrWhiteSpace() && TextField.IsNoNullOrWhiteSpace() && ValueField.IsNoNullOrWhiteSpace())
        {
            bindControl.BindControl(ConnectionKey, TableName, NodeCondition, Sort, TextField, ValueField, headerType);
        }
        else
        {
            string ListValue = objXmlNode.InnerText.Replace("\r\n", "").Trim();
            if (ListValue.IsNoNullOrWhiteSpace())
            {
                bindControl.Items.Clear();
                if (headerType != HeaderType.None)
                {
                    bindControl.Items.Add(new ListItem(headerType.GetEnumDescription(), ""));
                }
                foreach (string item in ListValue.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    string itemValue = item.Replace("\r\n", "").Trim();
                    bindControl.Items.Add(new ListItem(itemValue.Split(':', ':')[0], itemValue.Split(':', ':')[1]));
                }
            }
        }
    }
Beispiel #4
0
        public static void BindControl(this ListControl bindControl, string connectionKeyOrConnectionString, string tableName, string condition, string sort, string textField, string valueField, HeaderType headerType = 0)
        {
            string commandText = string.Format("SELECT DISTINCT {0},{1} FROM {2}", textField, valueField, tableName);

            if (!string.IsNullOrWhiteSpace(condition))
            {
                commandText = commandText + "  where " + condition;
            }
            if (!string.IsNullOrWhiteSpace(sort))
            {
                commandText = commandText + "  order by  " + sort;
            }
            DataTable table = WTF.Framework.MySqlHelper.ExecuteDataTable(connectionKeyOrConnectionString, commandText, new MySqlParameter[0]);

            bindControl.Items.Clear();
            if (headerType != HeaderType.None)
            {
                bindControl.Items.Add(new ListItem(headerType.GetEnumDescription(), ""));
            }
            foreach (DataRow row in table.Rows)
            {
                bindControl.Items.Add(new ListItem(row[textField].ToString(), row[valueField].ToString()));
            }
        }