Exemplo n.º 1
0
        private async void DgdCategoryGroup_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (DgdCategoryGroup.SelectedIndex == -1)
            {
                LblGroup.Content = string.Empty;
                return;
            }

            var selectItem = _incomeCategoryGroup[DgdCategoryGroup.SelectedIndex];

            try
            {
                _incomeCategory = await DIncomeCategory.GetData(selectItem.Id);
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message);
                return;
            }
            LblGroup.Content          = selectItem.CategoryGroup;
            DgdCategory.ItemsSource   = _incomeCategory;
            DgdCategory.SelectedIndex = -1;

            LblCategory.Content = TxtCategory.Text = string.Empty;

            BtnAdd.IsEnabled = true;
        }
Exemplo n.º 2
0
        private async void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckSelectGroup())
            {
                return;
            }

            var selectGroup = _incomeCategoryGroup[DgdCategoryGroup.SelectedIndex];

            if (!CheckSelectCategory() || !CheckEmpty())
            {
                return;
            }

            var selectCategory = _incomeCategory[DgdCategory.SelectedIndex];

            try
            {
                var editIncomeCategory = new DIncomeCategory
                {
                    DId = selectCategory.Id,
                    DCategoryGroupId = selectGroup.Id,
                    DCategory        = TxtCategory.Text
                };
                await Task.Run(() => editIncomeCategory.Edit());
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ویرایش اطلاعات\n" + exception.Message);
                return;
            }

            Window_Loaded(null, null);
            Utility.Message("پیام", "اطلاعات با موفقیت ثبت گردید", "Correct.png");
        }
Exemplo n.º 3
0
        private async void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckSelectGroup() || !CheckSelectCategory())
            {
                return;
            }

            var selectCategory = _incomeCategory[DgdCategory.SelectedIndex];

            try
            {
                _incomeData = await DIncome.GetIncomeCategoryData(selectCategory.Id);
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message);
                return;
            }
            if (!CheckCanDelete())
            {
                return;
            }

            Utility.MyMessageBox("هشدار", "آیا از حذف این دسته بندی اطمینان دارید؟", "Warning.png", false);

            if (!Utility.YesNo)
            {
                return;
            }
            try
            {
                var deleteIncomeCategory = new DIncomeCategory
                {
                    DId = selectCategory.Id
                };
                await Task.Run(() => deleteIncomeCategory.Delete());
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در حذف اطلاعات\n" + exception.Message);
            }

            Utility.Message("پیام", "اطلاعات مورد نظر با موفقیت حذف گردید", "Correct.png");
            Window_Loaded(null, null);
        }