Esempio n. 1
0
        private static void AddItemOKClicked(object sender, RoutedEventArgs e)
        {
            switch (WPFDbContext.Instance.AddItemType)
            {
            case ItemTypeEnum.Category:
                WPFCategoryDao.SaveTempSelectedIndex();
                CategoryDao.Insert(WPFDbContext.Instance.ItemName);
                WPFCategoryDao.GetCategories();
                WPFCategoryDao.GetCategoryFromTempSelectedIndex();
                break;

            case ItemTypeEnum.ParameterName:
                if (WPFDbContext.Instance.Description.Length == 0)
                {
                    MessageBox.Show("Please input description of parameter!");
                    return;
                }

                ParameterNameDao.Insert(WPFDbContext.Instance.ItemName, WPFDbContext.Instance.Description);
                WPFParameterNameDao.Update();
                break;

            case ItemTypeEnum.Task:
                WPFTaskDao.SaveTempSelectedIndex();
                TaskDao.Insert(WPFDbContext.Instance.ItemName);
                WPFTaskDao.GetTasks();
                WPFTaskDao.GetTaskFromTempSelectedIndex();
                break;
            }
            WPFDbContext.Instance.ItemName    = "";
            WPFDbContext.Instance.Description = "";
            WPFDbContext.Instance.AddItem.Hide();
        }
Esempio n. 2
0
        private static void RemoveItemClicked(object sender, RoutedEventArgs e)
        {
            WPFDbContext.Instance.RemoveItemType = (ItemTypeEnum)Enum.Parse(typeof(ItemTypeEnum), (string)(sender as DependencyObject).GetValue(RemoveItemClickedProperty));
            switch (WPFDbContext.Instance.RemoveItemType)
            {
            case ItemTypeEnum.Category:
                WPFCategoryDao.SaveTempSelectedIndex();
                CategoryDao.Remove(WPFDbContext.Instance.SelectedCategory.ID);
                WPFCategoryDao.GetCategories();
                WPFCategoryDao.GetCategoryFromTempSelectedIndex();
                break;

            case ItemTypeEnum.ParameterName:
                int id = (WPFDbContext.Instance.UnusedTaskVisibility == Visibility.Collapsed) ? WPFDbContext.Instance.SelectedUsedParameter.ID : WPFDbContext.Instance.SelectedUnusedParameter.ID;
                ParameterNameDao.Remove(id);
                WPFParameterNameDao.Update();
                break;

            case ItemTypeEnum.Task:
                WPFTaskDao.SaveTempSelectedIndex();
                TaskDao.Remove(WPFDbContext.Instance.SelectedUnusedTask.ID);
                WPFTaskDao.GetTasks();
                WPFParameterNameDao.Update();
                break;
            }
        }