Example #1
0
        private async void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckSelectDelete())
            {
                return;
            }
            var selectItem = _fileSearchAllData[DgdFile.SelectedIndex];

            if (!CanDelete(selectItem.Id))
            {
                return;
            }
            Utility.MyMessageBox("هشدار", "آیا از حذف اطمینان دارید؟ ", "Warning.png", false);
            if (!Utility.YesNo)
            {
                return;
            }
            try
            {
                if (selectItem.Id != null)
                {
                    var deleteFile = new DFile
                    {
                        DId = (int)selectItem.Id
                    };
                    await Task.Run(() => deleteFile.Delete());
                }
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در حذف اطلاعات\n" + exception.Message);
                return;
            }

            try
            {
                if (selectItem.Id != null)
                {
                    var deleteFilePerson = new DFilePerson
                    {
                        DFileId = (int)selectItem.Id
                    };
                    await Task.Run(() => deleteFilePerson.Delete());


                    var deleteFilePlaque = new DFilePlaque
                    {
                        DFileId = (int)selectItem.Id
                    };
                    await Task.Run(() => deleteFilePlaque.Delete());
                }
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در حذف اطلاعات\n" + exception.Message);
            }

            Window_Loaded(null, null);
            Utility.Message("پیام", "اطلاعات با موفقیت حذف گردید", "Correct.png");
        }
 private async Task <bool> CheckCanDelete(int plaqueId)
 {
     if (await DFilePlaque.CanDelete(plaqueId))
     {
         Utility.Message("اخطار", "به دلیل موجود بودن سوابق از این پلاک ثبتی، قادر به حذف نیستید", "Warning.png");
         return(false);
     }
     return(true);
 }
Example #3
0
        private async void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckSelectEdit() || !CheckEmpty())
            {
                return;
            }

            var selectItem = _fileSearchAllData[DgdFile.SelectedIndex];

            try
            {
                if (selectItem.Id != null)
                {
                    var editFile = new DFile
                    {
                        DId          = (int)selectItem.Id,
                        DMainId      = MainId,
                        DMarlik      = int.Parse(TxtMarlik.Text),
                        DFileTypeId  = CboFileType.SelectedIndex == -1 ? (byte?)null : ((tblFileType)CboFileType.SelectedItem).Id,
                        DViolationId = CboViolation.SelectedIndex == -1 ? (byte?)null : ((tblViolation)CboViolation.SelectedItem).Id,
                        DFileNum     = string.IsNullOrEmpty(TxtFileNum.Text) ? (int?)null : int.Parse(TxtFileNum.Text),
                        DFileYear    = string.IsNullOrEmpty(TxtFileYear.Text) ? (byte?)null : byte.Parse(TxtFileYear.Text),
                        DPermitNum   = string.IsNullOrEmpty(TxtPermitNum.Text) ? (int?)null : int.Parse(TxtPermitNum.Text),
                        DPermitYear  = string.IsNullOrEmpty(TxtPermitYear.Text) ? (byte?)null : byte.Parse(TxtPermitYear.Text),
                        DMantaghe    = string.IsNullOrEmpty(TxtMantaghe.Text) ? (int?)null : int.Parse(TxtMantaghe.Text),
                        DNahie       = string.IsNullOrEmpty(TxtNahie.Text) ? (int?)null : int.Parse(TxtNahie.Text),
                        DMahaleh     = string.IsNullOrEmpty(TxtMahaleh.Text) ? (int?)null : int.Parse(TxtMahaleh.Text),
                        DBlock       = string.IsNullOrEmpty(TxtBlock.Text) ? (int?)null : int.Parse(TxtBlock.Text),
                        DMelk        = string.IsNullOrEmpty(TxtMelk.Text) ? (int?)null : int.Parse(TxtMelk.Text),
                        DRadif       = string.IsNullOrEmpty(TxtRadif.Text) ? (int?)null : int.Parse(TxtRadif.Text),
                        DAddress     = string.IsNullOrEmpty(TxtAddress.Text) ? null : TxtAddress.Text,
                        DPostalCode  = string.IsNullOrEmpty(TxtPostalCode.Text) ? null : TxtPostalCode.Text,
                        DVoteNum     = string.IsNullOrEmpty(TxtVoteNum.Text) ? null : TxtVoteNum.Text,
                        DInArchives  = CheckBox.IsChecked,
                        DSeparation  = selectItem.Separation,
                        DAggregation = selectItem.Aggregation,
                        DDateInsert  = string.IsNullOrEmpty(TxtDate.Text) ? PersianDate.Today.ToString() : Utility.CurrectDate(TxtDate.Text),
                        DDescription = string.IsNullOrEmpty(TxtDescription.Text) ? null : TxtDescription.Text
                    };
                    await Task.Run(() => editFile.Edit());
                }
                _fileAllData = null;
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ویرایش اطلاعات پزشک\n" + exception.Message);
                return;
            }
            try
            {
                if (selectItem.Id != null)
                {
                    var deleteFilePerson = new DFilePerson
                    {
                        DFileId = (int)selectItem.Id
                    };
                    await Task.Run(() => deleteFilePerson.Delete());


                    var deleteFilePlaque = new DFilePlaque
                    {
                        DFileId = (int)selectItem.Id
                    };
                    await Task.Run(() => deleteFilePlaque.Delete());
                }
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در حذف اطلاعات\n" + exception.Message);
            }
            try
            {
                var addFilePerson = new DFilePerson();
                foreach (var variable in _createPersons)
                {
                    if (selectItem.Id != null)
                    {
                        addFilePerson.DFileId = (int)selectItem.Id;
                    }
                    addFilePerson.DPersonId = variable.Id;
                    await Task.Run(() => addFilePerson.Add());
                }
                var addFilePlaque = new DFilePlaque();
                foreach (var variable in _createPlaque)
                {
                    if (selectItem.Id != null)
                    {
                        addFilePlaque.DFileId = (int)selectItem.Id;
                    }
                    addFilePlaque.DPlaqueId = variable.Id;
                    await Task.Run(() => addFilePlaque.Add());
                }
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ثبت اطلاعات\n" + exception.Message);
            }

            Window_Loaded(null, null);
            Utility.Message("پیام", "اطلاعات با موفقیت ویرایش گردید", "Correct.png");
        }
Example #4
0
        private async void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (!CheckEmpty())
            {
                return;
            }
            var fileId = 0;

            #region AddFile

            try
            {
                var addFile = new DFile
                {
                    DMainId      = MainId,
                    DMarlik      = int.Parse(TxtMarlik.Text),
                    DFileTypeId  = CboFileType.SelectedIndex == -1 ? (byte?)null : ((tblFileType)CboFileType.SelectedItem).Id,
                    DViolationId = CboViolation.SelectedIndex == -1 ? (byte?)null : ((tblViolation)CboViolation.SelectedItem).Id,
                    DFileNum     = string.IsNullOrEmpty(TxtFileNum.Text) ? (int?)null : int.Parse(TxtFileNum.Text),
                    DFileYear    = string.IsNullOrEmpty(TxtFileYear.Text) ? (byte?)null : byte.Parse(TxtFileYear.Text),
                    DPermitNum   = string.IsNullOrEmpty(TxtPermitNum.Text) ? (int?)null : int.Parse(TxtPermitNum.Text),
                    DPermitYear  = string.IsNullOrEmpty(TxtPermitYear.Text) ? (byte?)null : byte.Parse(TxtPermitYear.Text),
                    DMantaghe    = string.IsNullOrEmpty(TxtMantaghe.Text) ? (int?)null : int.Parse(TxtMantaghe.Text),
                    DNahie       = string.IsNullOrEmpty(TxtNahie.Text) ? (int?)null : int.Parse(TxtNahie.Text),
                    DMahaleh     = string.IsNullOrEmpty(TxtMahaleh.Text) ? (int?)null : int.Parse(TxtMahaleh.Text),
                    DBlock       = string.IsNullOrEmpty(TxtBlock.Text) ? (int?)null : int.Parse(TxtBlock.Text),
                    DMelk        = string.IsNullOrEmpty(TxtMelk.Text) ? (int?)null : int.Parse(TxtMelk.Text),
                    DRadif       = string.IsNullOrEmpty(TxtRadif.Text) ? (int?)null : int.Parse(TxtRadif.Text),
                    DAddress     = string.IsNullOrEmpty(TxtAddress.Text) ? null : TxtAddress.Text,
                    DPostalCode  = string.IsNullOrEmpty(TxtPostalCode.Text) ? null : TxtPostalCode.Text,
                    DVoteNum     = string.IsNullOrEmpty(TxtVoteNum.Text) ? null : TxtVoteNum.Text,
                    DInArchives  = CheckBox.IsChecked,
                    DSeparation  = null,
                    DAggregation = null,
                    DDateInsert  = string.IsNullOrEmpty(TxtDate.Text) ? null : Utility.CurrectDate(TxtDate.Text),
                    DDescription = string.IsNullOrEmpty(TxtDescription.Text) ? null : TxtDescription.Text
                };
                fileId       = Convert.ToInt32(await addFile.Add());
                _fileAllData = null;
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ثبت اطلاعات\n" + exception.Message);
            }

            try
            {
                var addFilePerson = new DFilePerson();
                foreach (var variable in _createPersons)
                {
                    addFilePerson.DFileId   = fileId;
                    addFilePerson.DPersonId = variable.Id;
                    await Task.Run(() => addFilePerson.Add());
                }
                var addFilePlaque = new DFilePlaque();
                foreach (var variable in _createPlaque)
                {
                    addFilePlaque.DFileId   = fileId;
                    addFilePlaque.DPlaqueId = variable.Id;
                    await Task.Run(() => addFilePlaque.Add());
                }
            }
            catch (Exception exception)
            {
                Utility.MyMessageBox("خطا در بانک اطلاعاتی", "خطا در ثبت اطلاعات\n" + exception.Message);
            }


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

            #endregion
        }