コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            messageLabel.Text = "";
            if ("".Equals(categoryName.Text))
            {
                messageLabel.Text = "类型名不能为空";
                return;
            }
            MessageLocal msg = categoryDao.saveCategory(categoryName.Text, (Category)categoryNode.Tag, table);

            if (!msg.IsSucess)
            {
                MessageBox.Show(msg.Message + " 系统将刷新所有类型!");
                categoryFrm.refreshTreeView();
                this.Close();
                return;
            }

            // 再读一次的原因是,为了取得新创建的category的ID, 偷懒没有在saveCategory读取
            Category cop = categoryDao.getCategoryByName(categoryName.Text, table);

            if (null != cop)
            {
                TreeNode newNode = new TreeNode(categoryName.Text);
                newNode.Tag = cop;
                categoryNode.Nodes.Add(newNode);
                categoryFrm.refreshListView(categoryNode);
            }
            else
            {
                MessageBox.Show("该类型【" + categoryName.Text + "】被删除,系统将刷新所有类型!");
                categoryFrm.refreshTreeView();
            }
            this.Close();
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            messageLabel.Text = "";
            if ("".Equals(categoryName.Text))
            {
                messageLabel.Text = "类型名不能为空";
                return;
            }

            MessageLocal msg = categoryDao.updateCategoryByName(categoryName.Text, (Category)categoryNode.Tag, table);

            if (!msg.IsSucess)
            {
                MessageBox.Show(msg.Message + " 系统将刷新所有类型!");
                categoryFrm.refreshTreeView();
                this.Close();
                return;
            }

            categoryNode.Text = categoryName.Text;
            this.Close();
        }