Example #1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            CategoryDao cd = new CategoryDao();

            if (txtSearch.Text == "")
            {
                load();
            }
            else
            {
                lsvCategory.Items.Clear();
                List <Category> l = cd.GetCategoryByName(txtSearch.Text);
                for (int i = 0; i < l.Count; i++)
                {
                    ListViewItem lvi = lsvCategory.Items.Add("" + l[i].CategoryID);
                    lvi.SubItems.Add(l[i].CategoryName);
                }
            }
        }
Example #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            operate = "delete";
            if (treeView.SelectedNode == null)
            {
                return;
            }

            if (((TreeNodeTag)treeView.SelectedNode.Tag).NodeType == TreeNodeType.Type)
            {
                typesDao.DeleteByCellType(treeView.SelectedNode.Text);
            }
            else if (((TreeNodeTag)treeView.SelectedNode.Tag).NodeType == TreeNodeType.Category)
            {
                if (Dialogs.Confirm("确认并删除所有子项?"))
                {
                    Category cate = cateDao.GetCategoryByName(treeView.SelectedNode.Text);
                    typesDao.DeleteByCateId(cate.CateId);
                    cateDao.Delete(cate.CateId);
                }
            }

            btnRefresh_Click(sender, e);
        }