Exemple #1
0
        private void Button_Click_AddBudget(object sender, RoutedEventArgs e)
        {
            try
            {
                Worker worker = new Worker();
                Budget budg = (Budget)ListViewBudgets.SelectedItem;
                Category ActiveCategory = (Category)CategoryCmbBx.SelectedItem;
                string[] results = new string[2];
                switch (BudgetTypeTxtbx.Text)
                {
                    case "Неделя":
                        results = worker.AddBudget(NameTxtBx.Text, double.Parse(LimitTxtBx.Text), ActiveCategory.ID, "week").Split(';');
                        break;
                    case "Месяц":
                        results = worker.AddBudget(NameTxtBx.Text, double.Parse(LimitTxtBx.Text), ActiveCategory.ID, "month").Split(';');
                        break;
                    case "Год":
                        results = worker.AddBudget(NameTxtBx.Text, double.Parse(LimitTxtBx.Text), ActiveCategory.ID, "year").Split(';');
                        break;
                }
                
                // string[] results = new string[2];

                if (results[0] == "1")
                {
                    StatusTxt.Foreground = new SolidColorBrush(Colors.Black);
                    StatusTxt.Text = "Добавлен новый бюджет";

                    switch (BudgetTypeTxtbx.Text)
                    {
                        case "Неделя":
                            OpenWeekBudget(null, null);
                            break;
                        case "Месяц":
                            OpenMonthBudget(null, null);
                            break;
                        case "Год":
                            OpenYearBudget(null, null);
                            break;
                    }
                }
                else
                {
                    StatusTxt.Foreground = new SolidColorBrush(Colors.Red);
                    StatusTxt.Text = "Возникла ошибка: " + results[1];
                }
            }
            catch
            { }
        }
Exemple #2
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            try
            {
                Worker worker = new Worker();
                Budget budg =  (Budget)ListViewBudgets.SelectedItem;
                Category ActiveCategory = (Category)CategoryCmbBx.SelectedItem;
                string[] results = new string[2];
                switch (BudgetTypeTxtbx.Text)
                {
                    case "Неделя":
                        results = worker.ChangeBudget(budg.Id, NameTxtBx.Text, double.Parse(LimitTxtBx.Text), "week", ActiveCategory.ID).Split(';');
                        break;
                    case "Месяц":
                        results = worker.ChangeBudget(budg.Id, NameTxtBx.Text, double.Parse(LimitTxtBx.Text), "month", ActiveCategory.ID).Split(';');
                        break;
                    case "Год":
                        results = worker.ChangeBudget(budg.Id, NameTxtBx.Text, double.Parse(LimitTxtBx.Text), "year", ActiveCategory.ID).Split(';');
                        break;
                }
               
               // string[] results = new string[2];

                if (results[0] == "1")
                {
                    StatusTxt.Foreground = new SolidColorBrush(Colors.Black);
                    StatusTxt.Text = "Изменения внесены";

                    switch (BudgetTypeTxtbx.Text)
                    {
                        case "Неделя":
                            OpenWeekBudget(null, null);
                            break;
                        case "Месяц":
                            OpenMonthBudget(null, null);
                            break;
                        case "Год":
                            OpenYearBudget(null, null);
                            break;
                    }
                }
                else
                {
                    StatusTxt.Foreground = new SolidColorBrush(Colors.Red);
                    StatusTxt.Text = "Возникла ошибка: " + results[1];
                }
            }
            catch (Exception ex)
            {
                int i = 0;
                i = i + 1;
            }
        }