コード例 #1
0
        private void ButtonDeleteBakhshName_Click(object sender, RoutedEventArgs e)
        {
            Bakhshha selectedBakhsh = (Bakhshha)ComboBoxBakhshName.SelectedItem;

            if (selectedBakhsh == null)
            {
                return;
            }

            DialogBoxConfrimDelete dialogBoxConfrimDelete = new DialogBoxConfrimDelete();

            dialogBoxConfrimDelete.Message =
                "آیا از حذف این بخش اطمینان دارید؟در صورت حذف بخش دستگاه های آن بخش نیز حذف خواهند شد";
            dialogBoxConfrimDelete.ShowDialog();

            if (dialogBoxConfrimDelete.DialogResult == true)
            {
                var dastgahtQuery = from dastgah in Entities.Dastgahhas
                                    where dastgah.BakhshGUID == selectedBakhsh.BakhshGUID
                                    select dastgah;

                if (dastgahtQuery.Any())
                {
                    DialogBoxOk dialogBoxOk = new DialogBoxOk();
                    dialogBoxOk.Message = "این بخش شامل دستگاه هایی می باشد و قابل حذف نیست";
                    dialogBoxOk.ShowDialog();
                    return;
                }


                var dastgahQuery = from d in Entities.Dastgahhas
                                   where d.BakhshGUID == selectedBakhsh.BakhshGUID
                                   select d;

                foreach (var dd in dastgahQuery)
                {
                    Entities.Dastgahhas.DeleteObject(dd);
                }

                var bakhshQuery = from b in Entities.Bakhshhas
                                  where b.BakhshGUID == selectedBakhsh.BakhshGUID
                                  select b;
                Entities.Bakhshhas.DeleteObject(bakhshQuery.FirstOrDefault());

                Entities.SaveChanges();

                LoadComboBoxBakhshName();

                Darkhast.DialogBoxOk dialogBoxOk2 = new DialogBoxOk();
                dialogBoxOk2.Message = "بخش انتخاب شده حذف شد";
                dialogBoxOk2.ShowDialog();
            }
        }
コード例 #2
0
        private void RibbonButtonDelete_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            DialogBoxConfrimDelete dialogBoxConfrimDelete = new DialogBoxConfrimDelete();

            dialogBoxConfrimDelete.Message = "آیا از حذف این درخواست اطمینان دارید؟";
            dialogBoxConfrimDelete.ShowDialog();

            if (dialogBoxConfrimDelete.DialogResult == false)
            {
                return;
            }

            Darkhastha2 selectedItem = (Darkhastha2)GridViewDarkhastha.SelectedItem;

            if (selectedItem == null)
            {
                return;
            }

            if (Global.CurrentUserRole == (int)UserRole.Admin)
            {
                MoveToTrash(selectedItem.DarkhastGuid);
                LoadGridViewDarkhastha();
                ShowNumberOfTrashesOnRibbonTabTrash();
            }
            else if (Global.CurrentUserRole == (int)UserRole.Mamoli)
            {
                if (selectedItem.Vaziat == (int)VaziatDarkhast.DarHaleBarresi)
                {
                    MoveOutOfTrash(selectedItem.DarkhastGuid);
                    LoadGridViewDarkhastha();
                }
                else
                {
                    MoveToTrash(selectedItem.DarkhastGuid);
                    LoadGridViewDarkhastha();
                }
            }
        }
コード例 #3
0
        private void ButtonDeleteDastgahName_Click(object sender, RoutedEventArgs e)
        {
            DialogBoxConfrimDelete dialogBoxConfrimDelete = new DialogBoxConfrimDelete();

            dialogBoxConfrimDelete.Message = "آیا از حذف این دستگاه اطمینان دارید؟";
            dialogBoxConfrimDelete.ShowDialog();

            if (dialogBoxConfrimDelete.DialogResult == true)
            {
                Bakhshha  bakhsh  = (Bakhshha)ComboBoxBakhshName2.SelectedItem;
                Dastgahha dastgah = (Dastgahha)ComboBoxDastgahName.SelectedItem;

                var darkhastQuery = from darkhast in Entities.Darkhasthas
                                    where darkhast.DastgahGUID == dastgah.DastgahGUID
                                    select darkhast;

                if (darkhastQuery.Any())
                {
                    DialogBoxOk dialogBoxOk2 = new DialogBoxOk();
                    dialogBoxOk2.Message = "این دستگاه قبلا در درخواست ها استفاده شده است و نمی توانید آن را حذف کنید.فقط می توانید آن را ویرایش کنید";
                    dialogBoxOk2.ShowDialog();
                    return;
                }

                var deleteQuery = from d in Entities.Dastgahhas
                                  where d.BakhshGUID == bakhsh.BakhshGUID && d.DastgahGUID == dastgah.DastgahGUID
                                  select d;

                Entities.Dastgahhas.DeleteObject(((Dastgahha)deleteQuery.FirstOrDefault()));
                Entities.SaveChanges();

                LoadComboBoxDastgahName();
                DialogBoxOk dialogBoxOk = new DialogBoxOk();
                dialogBoxOk.Message = "دستگاه حذف شد";
                dialogBoxOk.ShowDialog();
            }
        }