Exemple #1
0
        private void ButtonEditBakhshName_Click(object sender, RoutedEventArgs e)
        {
            Bakhshha bakhsh = (Bakhshha)ComboBoxBakhshName.SelectedItem;

            WindowEditBakhshName windowEditBakhshName = new WindowEditBakhshName();

            windowEditBakhshName.BakhshGuid        = bakhsh.BakhshGUID;
            windowEditBakhshName.BakhshNameEdited += new EventHandler(windowEditBakhshName_BakhshNameEdited);
            windowEditBakhshName.Show();
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var bakhshQuery = from b in Entities.Bakhshhas
                              where b.BakhshGUID == this.BakhshGuid
                              select b;

            Bakhshha bakhsh = bakhshQuery.FirstOrDefault();

            TextBoxBakhshName.Text = bakhsh.BakhshName;
        }
Exemple #3
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();
            }
        }
        private void ButtonAddBakhshName_Click(object sender, RoutedEventArgs e)
        {
            StatusBar1.Items.Clear();

            if (TextBoxBakhshName.Text.Equals(""))
            {
                StatusBar1.Items.Add("نام بخش نمی تواند خالی باشد");
                return;
            }

            Bakhshha bakhsh = new Bakhshha();

            bakhsh.BakhshGUID = Guid.NewGuid();
            bakhsh.BakhshName = TextBoxBakhshName.Text;
            Entities.Bakhshhas.AddObject(bakhsh);

            Entities.SaveChanges();

            StatusBar1.Items.Add("بخش جدید با موفقیت ثبت شد");
            TextBoxBakhshName.Text = "";
            OnBakhshNameAdded(new EventArgs());
        }
Exemple #5
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();
            }
        }
        private void ButtonEditBakhshName_Click(object sender, RoutedEventArgs e)
        {
            StatusBar1.Items.Clear();

            if (TextBoxBakhshName.Text.Equals(""))
            {
                StatusBar1.Items.Add("نام بخش نمی تواند خالی باشد");
                return;
            }

            var bakhshQuery = from b in Entities.Bakhshhas
                              where b.BakhshGUID == this.BakhshGuid
                              select b;

            Bakhshha bakhsh = bakhshQuery.FirstOrDefault();

            bakhsh.BakhshName = TextBoxBakhshName.Text;

            Entities.SaveChanges();

            StatusBar1.Items.Add("نام بخش با موفقیت ویرایش شد");
            TextBoxBakhshName.Text = "";
            OnBakhshNameEdited(new EventArgs());
        }