第一个兼职,开发一个小小的网站,感觉三层架构的代码量实在是太大,得赶紧学代码生成才行,另外,这个项目拖的太久,不行。。。
将期间碰到的一些问题的解决办法列出如下,以备不时之需:
1、网页中用iframe嵌入网页的用法:http://www.360doc.com/content/06/0913/17/11344_206519.shtml
2、TreeView1.CollapseAll();//使树的节点不全部展开
3、第一次用梅花雨日历控件,蛮好用的。
4、张老师教的树的写法很实用,但自己写还是蛮有难度的。
public class BllTree { /// <summary> /// 私有内部类 /// </summary> private class Comparer:IComparer<Model.ShiCheng> { #region IComparer<ShiCheng> 成员 public int Compare(Model.ShiCheng x, Model.ShiCheng y) { return x.Code.CompareTo(y.Code); } #endregion } private TreeView tree = null; BLL.ShiFu biz = new ShiFu(); public BllTree(TreeView targetTree) { this.tree = targetTree; this.BuildTop(); } /// <summary> /// 创建顶级节点 /// </summary> private void BuildTop() { IList<Model.ShiCheng> dirList = new List<Model.ShiCheng>(); List<Model.ShiCheng> tops = new List<Model.ShiCheng>(); BLL.ShiCheng bll = new ShiCheng(); dirList = bll.GetAll(); foreach(Model.ShiCheng obj in dirList) { if (obj.ParentShiFuId == Guid.Empty.ToString()) { tops.Add(obj); } } tops.Sort(new Comparer());//排序 //处理另外一张表ShiFu,根据上边找到的tops节点查出其名称 Model.ShiFu shiFuInfo = new Model.ShiFu(); foreach (Model.ShiCheng item in tops) { shiFuInfo = biz.GetShiFuByShiFuId(item.ShiFuId); TreeNode node = new TreeNode((item.Code+shiFuInfo.Name), shiFuInfo.ShiFuId); this.BuildNode(node);//创建子节点 this.tree.Nodes.Add(node); } } /// <summary> /// 递归调用创建子节点 /// </summary> /// <param name="currentNode"></param> private void BuildNode(TreeNode currentNode) { List<Model.ShiCheng> childs = new BLL.ShiCheng().GetTuDiByShiFuId(currentNode.Value); childs.Sort(new Comparer()); //处理另外一张表ShiFu,根据上边找到的childs节点查出其名称 Model.ShiFu tuDiInfo = new Model.ShiFu(); foreach (Model.ShiCheng item in childs) { tuDiInfo = biz.GetShiFuByShiFuId(item.ShiFuId); TreeNode node = new TreeNode((item.Code+tuDiInfo.Name), tuDiInfo.ShiFuId); this.BuildNode(node);//递归调用 currentNode.ChildNodes.Add(node);//加子节点的写法 } } }