Пример #1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            DataPanel.Controls.Clear();
            InitAddButton(DataPanel);
            entryComponents.Clear();

            string search = textBox1.Text;

            if (search == "")
            {
                return;     //should later add some message
            }
            switch (search) //super secret dev commands hehe
            {
            case "!wipecats":
                var cats = DatabaseClass.GetCategoriesList();
                for (int j = 3; j < cats.Count; j++)
                {
                    var entries = DatabaseClass.GetDataByCategory(cats[j], "");
                    if (entries != null)
                    {
                        foreach (Entry entry in entries)
                        {
                            DatabaseClass.RemoveEntry(category, entry.name);
                        }
                    }
                    DatabaseClass.RemoveCategory(cats[j]);
                }
                var pp = Parent.Parent as Form1;
                pp.RedrawCats();
                break;

            case "!wipeentries":
                var entriess = DatabaseClass.GetDataByCategory(category, "");
                foreach (Entry entry in entriess)
                {
                    DatabaseClass.RemoveEntry(category, entry.name);
                }
                break;

            case "!wipeall":
                DatabaseClass.RemoveAllEntries();
                DatabaseClass.RemoveNonMandatoryCategories();
                var ppp = Parent.Parent as Form1;
                ppp.RedrawCats();
                break;
            }
            var list = DatabaseClass.GetCategoryEntry(DatabaseClass.FindCategoryId(category), search);

            int i = 0;

            foreach (Entry ent in list)
            {
                EntryComponent entr = new EntryComponent(i, ent, category);
                DataPanel.Controls.Add(entr.mainPanel);
                entryComponents.Add(entr);
            }
        }
Пример #2
0
 private void btnDeleteEntry_Click(object sender, EventArgs e)
 {
     if (delete)
     {
         DatabaseClass.RemoveEntry(category, entry.name);
         this.Close();
     }
     else
     {
         lblAnyText.Text = "Are you sure you want to delete this entry? It will be lost forever. To confirm click that button again.";
         delete          = true;
     }
 }