Example #1
0
        private void btnAddPlace_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode != null)
            {
                string parentID = treeView1.SelectedNode.Name;
                int    level    = treeView1.SelectedNode.Level;

                if (treeView1.SelectedNode.Level == 3)
                {
                    MsgBox.Show("階層已達上限,無法再往下新增所屬位置!");
                }
                else
                {
                    frmPlace form = new frmPlace(FormMode.Add, null, parentID, null, level);
                    form.Text        = string.Format("{0}位置", EnumDescription.Get(typeof(FormMode), FormMode.Add.ToString()));
                    form.FormClosed += delegate
                    {
                        if (form.DialogResult == DialogResult.Yes)
                        {
                            ReloadTreeView();
                        }
                    };
                    form.ShowDialog();
                }
            }
        }
Example #2
0
        private void btnUpdatePlace_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode != null && treeView1.SelectedNode.Name != "")
            {
                string placeID   = treeView1.SelectedNode.Name;
                string parentID  = "" + treeView1.SelectedNode.Parent.Name;
                int    level     = treeView1.SelectedNode.Level;
                string placeName = treeView1.SelectedNode.Text;

                frmPlace form = new frmPlace(FormMode.Update, placeName, parentID, placeID, level);
                form.Text        = string.Format("{0}位置", EnumDescription.Get(typeof(FormMode), FormMode.Update.ToString()));
                form.FormClosed += delegate
                {
                    if (form.DialogResult == DialogResult.Yes)
                    {
                        ReloadTreeView();
                    }
                };
                form.ShowDialog();
            }
        }