private async void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckEmpty())
            {
                return;
            }

            #region AddPlaque

            try
            {
                var addPlaque = new DPlaque
                {
                    DMain        = string.IsNullOrEmpty(TxtMain.Text) ? (int?)null : int.Parse(TxtMain.Text),
                    DSecondary   = string.IsNullOrEmpty(TxtSecondary.Text) ? (int?)null : int.Parse(TxtSecondary.Text),
                    DPart        = string.IsNullOrEmpty(TxtPart.Text) ? (int?)null : int.Parse(TxtPart.Text),
                    DDescription = string.IsNullOrEmpty(TxtDescription.Text) ? null : TxtDescription.Text
                };
                await Task.Run(() => addPlaque.Add());
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ثبت اطلاعات\n" + exception.Message);
            }
            Window_Loaded(null, null);
            Utility.Message("پیام", "اطلاعات با موفقیت ثبت گردید", "Correct.png");

            #endregion
        }
        private async void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckSelectDelete())
            {
                return;
            }
            var selectItem = _plaqueSearchData[DgdData.SelectedIndex];

            if (!await CheckCanDelete(selectItem.Id))
            {
                return;
            }
            Utility.MyMessageBox("هشدار", "آیا از حذف اطمینان دارید؟ ", "Warning.png", false);
            if (!Utility.YesNo)
            {
                return;
            }
            try
            {
                var deletePlaque = new DPlaque
                {
                    DId = selectItem.Id
                };
                await Task.Run(() => deletePlaque.Delete());
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در حذف اطلاعات\n" + exception.Message);
                return;
            }
            Window_Loaded(null, null);
            Utility.Message("پیام", "اطلاعات با موفقیت حذف گردید", "Correct.png");
        }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                _plaqueData = await DPlaque.GetData();
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message);
                Close();
                return;
            }
            _plaqueSearchData = _plaqueData;
            if (string.IsNullOrEmpty(TxtSearch.Text.Trim()) || _add)
            {
                DgdData.ItemsSource = _plaqueSearchData;
                TxtSearch.Text      = string.Empty;
            }
            else
            {
                TxtSearch_TextChanged(null, null);
            }
            DgdData.ItemsSource = _plaqueSearchData;

            BtnNew_Click(null, null);
        }
        private async void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckSelectEdit() || !CheckEmpty())
            {
                return;
            }
            var selectItem = _plaqueSearchData[DgdData.SelectedIndex];

            try
            {
                var editPlaque = new DPlaque
                {
                    DId          = selectItem.Id,
                    DMain        = string.IsNullOrEmpty(TxtMain.Text) ? (int?)null : int.Parse(TxtMain.Text),
                    DSecondary   = string.IsNullOrEmpty(TxtSecondary.Text) ? (int?)null : int.Parse(TxtSecondary.Text),
                    DPart        = string.IsNullOrEmpty(TxtPart.Text) ? (int?)null : int.Parse(TxtPart.Text),
                    DDescription = string.IsNullOrEmpty(TxtDescription.Text) ? null : TxtDescription.Text
                };
                await Task.Run(() => editPlaque.Edit());
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ویرایش اطلاعات\n" + exception.Message);
                return;
            }
            Window_Loaded(null, null);
            Utility.Message("پیام", "اطلاعات با موفقیت ویرایش گردید", "Correct.png");
        }
示例#5
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                //_fileData = await DFile.GetData();
                _fileAllData = await DFile.GetAllData();

                _fileTypeData = await DFileType.GetData();

                _violationData = await DViolation.GetData();

                _creatPersonData = await DPerson.GetCreate();

                _creatPlaqueData = await DPlaque.GetCreate();
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message);
                Close();
                return;
            }
            //_fileSearchData = _fileData;
            _fileSearchAllData       = _fileAllData;
            CboFileType.ItemsSource  = _fileTypeData;
            CboViolation.ItemsSource = _violationData;
            DgdFile.ItemsSource      = _fileSearchAllData;
            BtnNew_Click(null, null);
        }
示例#6
0
 private async void Window_Loaded(object sender, RoutedEventArgs e)
 {
     try
     {
         _plaqueData = await DPlaque.GetData();
     }
     catch (Exception exception)
     {
         Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message);
         Close();
         return;
     }
     _plaqueSearchData     = _plaqueData;
     DgdPlaque.ItemsSource = _plaqueSearchData;
 }
示例#7
0
        private async void BtnNew_Click(object sender, RoutedEventArgs e)
        {
            var winPlaque = new WinPlaque();

            winPlaque.ShowDialog();
            try
            {
                _plaqueData = await DPlaque.GetData();
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message);
                Close();
                return;
            }
            _plaqueSearchData     = _plaqueData;
            DgdPlaque.ItemsSource = _plaqueSearchData;
        }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                _fileAllData = await DFile.GetAllData();

                _creatPersonData = await DPerson.GetCreate();

                _creatPlaqueData = await DPlaque.GetCreate();
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در دریافت اطلاعات\n" + exception.Message);
                Close();
                return;
            }
            _fileSearchAllData  = _fileAllData;
            DgdFile.ItemsSource = _fileSearchAllData;
            FileId = 0;
            New();
        }