Beispiel #1
0
        private void addFolder_OnClick(object sender, System.EventArgs e)
        {
            if (this.trvFolder.SelectedNode == null)
            {
                MessageBox.Show("请选中商品分类");
                return;
            }
            using (FolderSettingForm frm = new FolderSettingForm(null))
            {
                if (DialogResult.OK == frm.ShowDialog(this))
                {
                    int id = 0;
                    int parentId = (int)this.trvFolder.SelectedNode.Tag;
                    if (false == Utility.DBProvider.AddFolder(Utility.DBProvider.DBName, parentId, frm.FolderName, out id))
                    {
                        MessageBox.Show(Utility.LastErrorMessage);
                    }
                    else
                    {
                        MessageBox.Show(Settings.Default.FolderSettingAddSuccess);
                        Folder folder = new Folder{Name = frm.FolderName, Childs = new HashSet<int>(), ID = id, ParentID = parentId};
                        LoginUser.CurrentUser.FolderList.Add(id, folder);
                        LoginUser.CurrentUser.FolderList[parentId].Childs.Add(id);

                        this.trvFolder.SelectedNode.Nodes.Add(id.ToString(), frm.FolderName);
                        this.trvFolder.SelectedNode.Nodes[id.ToString()].Tag = id;
                    }
                }
                frm.Dispose();
            }
        }
Beispiel #2
0
 private void propertyFolder_OnClick(object sender, System.EventArgs e)
 {
     if (this.trvFolder.SelectedNode == null)
     {
         MessageBox.Show("请选中商品分类");
         return;
     }
     using (FolderSettingForm frm = new FolderSettingForm(trvFolder.SelectedNode.Text))
     {
         if (DialogResult.OK == frm.ShowDialog(this))
         {
             int id = (int)this.trvFolder.SelectedNode.Tag;
             if (false == Utility.DBProvider.ModifyFolder(Utility.DBProvider.DBName, id, frm.FolderName))
             {
                 MessageBox.Show(Utility.LastErrorMessage);
             }
             else
             {
                 MessageBox.Show(Settings.Default.FolderSettingModifySuccess);
                 LoginUser.CurrentUser.FolderList[id].Name = frm.FolderName;
                 this.trvFolder.SelectedNode.Text = frm.FolderName;
             }
         }
         frm.Dispose();
     }
 }