/// <summary> /// �ݹ�XML�ڵ㵽ָ������ /// </summary> /// <param name="list">ָ������</param> /// <param name="pNode">���ڵ�</param> /// <param name="depth">�ڵ����</param> private static void LoopNodes(ArrayList list,XmlNode pNode,ushort depth) { DictionaryItem item; foreach (XmlNode node in pNode.SelectNodes("Item")) { item = new DictionaryItem(node.Attributes["key"].Value, node.Attributes["value"].Value, depth); list.Add(item); if (node.HasChildNodes) { depth++; LoopNodes(item.Children, node, depth); depth--; } } }
private static DictionaryItem LoopSeekItem(string parentId,DictionaryItem item) { if (item.Key.ToLower().Trim() == parentId.ToLower().Trim()) { return item; } foreach (DictionaryItem subItem in item.Children) { if (subItem.Key.ToLower().Trim() == parentId.ToLower().Trim()) { return subItem; } LoopSeekItem(parentId, subItem); } return null; }
private string GetDictionaryItems(DictionaryItem[] items) { string ret = ""; foreach (DictionaryItem item in items) { ret += "<li>" + item.Value + "</li>"; } return ret; }
private void LoopItems(DictionaryItem item, XhtmlTextWriter writer) { switch (htmlTagName.ToLower().Trim()) { case "select": writer.WriteBeginTag("option"); writer.WriteAttribute("value", item.Key); if (IsSelected(item.Key)) { writer.WriteAttribute("selected", "selected"); } writer.Write(HtmlTextWriter.TagRightChar); int d = item.Depth; if (!String.IsNullOrEmpty(parentId)) { d -= parentId.Length / (provider == "category" ? Categories.Category.CATEGORY_LEVEL_LENGTH : DictionaryItem.KEY_LEVEL_LENGTH); } string text = BrandQQ.LeadLib.Utils.Util.RepeatString(identChar, (ushort)d); if (d > 0) { text += prefixChar; } writer.Write(text + item.Value); writer.WriteEndTag("option"); break; case "ul": writer.WriteBeginTag("li"); writer.WriteAttribute("id", "LI_" + this.ClientID + "_" + item.Key); writer.Write(HtmlTextWriter.TagRightChar); if (!String.IsNullOrEmpty(checkBoxOrRadio))//����ѡ�� { writer.WriteBeginTag("input"); writer.WriteAttribute("type", checkBoxOrRadio); writer.WriteAttribute("id", this.ClientID + "_" + item.Key); if (String.IsNullOrEmpty(htmlControlName)) { writer.WriteAttribute("name", this.ClientID); } else { writer.WriteAttribute("name", htmlControlName); } writer.WriteAttribute("value", item.Key); if (IsSelected(item.Key)) { writer.WriteAttribute("checked", "checked"); } writer.Write(HtmlTextWriter.SelfClosingTagEnd); writer.WriteBeginTag("label"); writer.WriteAttribute("for", this.ClientID + "_" + item.Key); writer.Write(HtmlTextWriter.TagRightChar); writer.Write(item.Value); writer.WriteEndTag("label"); } else { if (!String.IsNullOrEmpty(linkFormat)) { writer.Write(String.Format(linkFormat, item.Key, item.Value)); } else { writer.Write(item.Value); } } writer.WriteEndTag("li"); break; } if (item.Children.Count > 0 && htmlTagName.ToLower().Trim() == "ul") { writer.WriteFullBeginTag("ul"); } foreach (DictionaryItem subItem in item.Children) { LoopItems(subItem, writer); } if (item.Children.Count > 0 && htmlTagName.ToLower().Trim() == "ul") { writer.WriteEndTag("ul"); } }
/// <summary> /// ���´ʵ��ļ� /// </summary> /// <param name="type"></param> /// <param name="parentKey"></param> /// <param name="item"></param> public static void UpdateDictionaryFile(DictionaryType type,string parentKey,DictionaryItem item) { }
/// <summary> /// �����ݿ��ȡ�ֵ��б� /// </summary> /// <param name="type">�ֵ�����</param> /// <returns>ArrayList</returns> public static ArrayList List(DictionaryType type) { /* DictList @type char(1) */ ArrayList list = new ArrayList(); SqlDataReader reader = null; try { DictionaryItem dicItem; reader = Database.ExecuteReader(CommandType.StoredProcedure, "DictList", new SqlParameter[] { Database.MakeInParam("@type", SqlDbType.Char, 1, type.ToString()) }); while (reader.Read()) { /*Type, [Key], [Value]*/ dicItem = new DictionaryItem(type); dicItem.Key = reader.GetString(1); dicItem.Value = reader.GetString(2); list.Add(dicItem); } reader.Close(); } catch { // } finally { if (reader != null) { reader.Close(); } } return list; }
/// <summary> /// �����ݿ��ȡһ���ֵ��� /// </summary> /// <param name="type">�ֵ�����</param> /// <param name="key">����</param> /// <returns></returns> public static DictionaryItem GetItem(DictionaryType type, string key) { /* DictGet @type char(1), @key varchar(50) */ DictionaryItem dic = null; SqlDataReader reader = null; try { /*Type, [Key], [Value]*/ reader = Database.ExecuteReader(CommandType.StoredProcedure, "DictGet", new SqlParameter[] { Database.MakeInParam("@type",SqlDbType.Char,1,type.ToString()), Database.MakeInParam("@key",SqlDbType.VarChar,50,key) }); if (reader.Read()) { dic = new DictionaryItem(type); dic.Key = reader.GetString(1); dic.Value = reader.GetString(2); } reader.Close(); } catch { // } finally { if (reader != null) { reader.Close(); } } return dic; }
public static DictionaryItem AddItem(DictionaryType type, string key, string value) { DictionaryItem item = new DictionaryItem(type, key, value); if (item.Save()) { return item; } return null; }
private void PublishSupplierCatelogyByArea(string temp, DictionaryItem area) { PublishSupplierCatelogyByArea(temp, area.Key, area.Value); }