Ejemplo n.º 1
0
        private void RibbonToggleButtonDaryaftShod_Click(object sender, RoutedEventArgs e)
        {
            Darkhastha2 selectedItem = (Darkhastha2)GridViewDarkhastha.SelectedItem;

            if (selectedItem == null)
            {
                DialogBoxOk dialogBoxOk = new DialogBoxOk();
                dialogBoxOk.Message = "ابتدا یک درخواست را انتخاب کنید";
                dialogBoxOk.ShowDialog();
                return;
            }

            var darkhastQuery = from d in Entities.Darkhasthas
                                where d.DarkhastGUID == selectedItem.DarkhastGuid
                                select d;
            Darkhastha darkhast = darkhastQuery.FirstOrDefault();

            if (RibbonToggleButtonDaryaftShod.IsChecked == true)
            {
                darkhast.TarikhDaryaftKala = DateTime.Now;
            }
            else
            {
                darkhast.TarikhDaryaftKala = null;
            }

            Darkhastha_Log2.InsertLog(darkhast, RevisionOperation.Update);
            Entities.SaveChanges();
            LoadGridViewDarkhastha();
        }
Ejemplo n.º 2
0
        private void RibbonButtonRestore_Click(object sender, RoutedEventArgs e)
        {
            Darkhastha2 selectedItem = (Darkhastha2)GridViewDarkhastha.SelectedItem;

            RestoreFromTrash(selectedItem.DarkhastGuid);

            LoadGridViewDarkhastha();
            ShowNumberOfTrashesOnRibbonTabTrash();
        }
Ejemplo n.º 3
0
        private void RibbonButtonEdit_Click(object sender, RoutedEventArgs e)
        {
            Darkhastha2 selectedItem = (Darkhastha2)GridViewDarkhastha.SelectedItem;
            var         editQuery    = from d in Entities.Darkhasthas
                                       where d.DarkhastGUID == selectedItem.DarkhastGuid
                                       select d;
            Darkhastha currentItem = editQuery.FirstOrDefault();

            WindowEdit windowEdit = new WindowEdit();

            windowEdit.Darkhast        = currentItem;
            windowEdit.DarkhastEdited += new EventHandler(windowEdit_DarkhastEdited);
            windowEdit.Show();
        }
Ejemplo n.º 4
0
        private void MenuItemCopyTedadDarkhast_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            Darkhastha2 currentRow = (Darkhastha2)GridViewDarkhastha.SelectedItem;

            if (currentRow != null)
            {
                Clipboard.SetText(currentRow.TedadDarkhast.ToString(), TextDataFormat.UnicodeText);
            }
            else
            {
                DialogBoxOk dialogBoxOk = new DialogBoxOk();
                dialogBoxOk.Message = "ابتدا یک درخواست را انتخاب کنید";
                dialogBoxOk.ShowDialog();
            }
        }
Ejemplo n.º 5
0
        private void RibbonButtonMoveOutOfTrash_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Darkhastha2 selectedItem = (Darkhastha2)GridViewDarkhastha.SelectedItem;

                MoveOutOfTrash(selectedItem.DarkhastGuid);

                LoadGridViewDarkhastha();
                ShowNumberOfTrashesOnRibbonTabTrash();
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 6
0
        private void RibbonButtonShomareDarkhastTadbir_Click(object sender, RoutedEventArgs e)
        {
            Darkhastha2 darkhast = (Darkhastha2)GridViewDarkhastha.SelectedItem;

            if (darkhast == null)
            {
                return;
            }

            WindowShomareDarkhastTadbir windowShomareDarkhastTadbir = new WindowShomareDarkhastTadbir();

            windowShomareDarkhastTadbir.DarkhastGuid          = darkhast.DarkhastGuid;
            windowShomareDarkhastTadbir.ShomareDarkhastSaved += new EventHandler(windowShomareDarkhastTadbir_ShomareDarkhastSaved);
            windowShomareDarkhastTadbir.Show();
        }
Ejemplo n.º 7
0
        private void MenuItemCopyKalaNameArabi_Click(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            Darkhastha2 currentRow = (Darkhastha2)GridViewDarkhastha.SelectedItem;

            if (currentRow != null)
            {
                Clipboard.SetText(currentRow.DarkhastName.Replace("ی", "ي").Replace("ک", "ك"), TextDataFormat.UnicodeText);
            }
            else
            {
                DialogBoxOk dialogBoxOk = new DialogBoxOk();
                dialogBoxOk.Message = "ابتدا یک درخواست را انتخاب کنید";
                dialogBoxOk.ShowDialog();
            }
        }
Ejemplo n.º 8
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();
                }
            }
        }
Ejemplo n.º 9
0
        private void GridViewDarkhastha_SelectionChanged(object sender, SelectionChangeEventArgs e)
        {
            Darkhastha2 selectedItem = (Darkhastha2)GridViewDarkhastha.SelectedItem;

            if (selectedItem == null)
            {
                return;
            }

            RibbonToggleButtonDaryaftShod.IsEnabled = false;

            if (Global.CurrentUserRole == (int)UserRole.Admin)
            {
                if (selectedItem.IsTrash == (int)Trash.InTrash)
                {
                    RibbonButtonEdit.IsEnabled   = false;
                    RibbonButtonDelete.IsEnabled = false;
                }
                else if (selectedItem.IsTrash == (int)Trash.NotATrash)
                {
                    RibbonButtonEdit.IsEnabled   = true;
                    RibbonButtonDelete.IsEnabled = true;
                }

                RibbonToggleButtonDaryaftShod.IsEnabled = true;

                if (selectedItem.TarikhDaryaftKala == null)
                {
                    RibbonToggleButtonDaryaftShod.IsChecked = false;
                }
                else
                {
                    RibbonToggleButtonDaryaftShod.IsChecked = true;
                }
            }
            else if (Global.CurrentUserRole == (int)UserRole.Mamoli)
            {
                if (selectedItem.Vaziat == (int)VaziatDarkhast.DarHaleBarresi &&
                    selectedItem.BarghkarGuid == Global.CurrentUserGuid && selectedItem.IsTrash == (int)Trash.NotATrash)
                {
                    RibbonButtonEdit.IsEnabled   = true;
                    RibbonButtonDelete.IsEnabled = true;
                }
                else if (selectedItem.Vaziat != (int)VaziatDarkhast.DarHaleBarresi &&
                         (selectedItem.BarghkarGuid != Global.CurrentUserGuid || selectedItem.IsTrash == (int)Trash.InTrash))
                {
                    RibbonButtonEdit.IsEnabled   = false;
                    RibbonButtonDelete.IsEnabled = false;
                }
                else if (selectedItem.Vaziat != (int)VaziatDarkhast.DarHaleBarresi && selectedItem.BarghkarGuid == Global.CurrentUserGuid &&
                         selectedItem.IsTrash == (int)Trash.NotATrash)
                {
                    RibbonButtonEdit.IsEnabled   = false;
                    RibbonButtonDelete.IsEnabled = true;
                }

                if (selectedItem.BarghkarGuid == Global.CurrentUserGuid)
                {
                    RibbonToggleButtonDaryaftShod.IsEnabled = true;

                    if (selectedItem.TarikhDaryaftKala == null)
                    {
                        RibbonToggleButtonDaryaftShod.IsChecked = false;
                    }
                    else
                    {
                        RibbonToggleButtonDaryaftShod.IsChecked = true;
                    }
                }
            }

            if (selectedItem.Vaziat == (int)VaziatDarkhast.DarHaleBarresi)
            {
                RibbonButtonTaeed.IsEnabled     = true;
                RibbonButtonAdamTaeed.IsEnabled = true;
            }
            else if (selectedItem.Vaziat == (int)VaziatDarkhast.TaeedNashode)
            {
                RibbonButtonTaeed.IsEnabled     = true;
                RibbonButtonAdamTaeed.IsEnabled = false;
            }
            else if (selectedItem.Vaziat == (int)VaziatDarkhast.TaeedShode)
            {
                RibbonButtonTaeed.IsEnabled     = false;
                RibbonButtonAdamTaeed.IsEnabled = true;
            }

            if (selectedItem.DarkhastGuid.ToString().Length > 0)
            {
                RibbonButtonShomareDarkhastTadbir.IsEnabled = true;
            }
            else
            {
                RibbonButtonShomareDarkhastTadbir.IsEnabled = false;
            }
        }
Ejemplo n.º 10
0
        public void LoadGridViewDarkhastha()
        {
            selectedItem = (Darkhastha2)GridViewDarkhastha.SelectedItem;

            if (ShowTrash == true)
            {
                darkhasthaQuery2 = from d in Entities.Darkhasthas
                                   where d.IsTrash == (int)Trash.InTrash
                                   orderby d.Tarikh descending
                                   select d;
            }
            else
            {
                darkhasthaQuery2 = from d in Entities.Darkhasthas
                                   where d.IsTrash != (int)Trash.OutOfTrash
                                   orderby d.Tarikh descending
                                   select d;
            }

            darkhasthaQuery2 = darkhasthaQuery2.Where(x => x.Tarikh >= StartDate && x.Tarikh <= EndDate);

            if (SearchDarkhastName.Length > 0)
            {
                if (Properties.Settings.Default.SearchDarkhastNameSearchType == (int)SearchType.Contains)
                {
                    darkhasthaQuery2 = darkhasthaQuery2.Where(x => x.IsTrash != (int)Trash.OutOfTrash &&
                                                              x.DarkhastName.ToLower().Contains(SearchDarkhastName.ToLower()));
                }
                else if (Properties.Settings.Default.SearchDarkhastNameSearchType == (int)SearchType.StarstWith)
                {
                    darkhasthaQuery2 = darkhasthaQuery2.Where(x => x.IsTrash != (int)Trash.OutOfTrash &&
                                                              x.DarkhastName.ToLower().StartsWith(SearchDarkhastName.ToLower()));
                }
                else if (Properties.Settings.Default.SearchDarkhastNameSearchType == (int)SearchType.EndsWith)
                {
                    darkhasthaQuery2 = darkhasthaQuery2.Where(x => x.IsTrash != (int)Trash.OutOfTrash &&
                                                              x.DarkhastName.ToLower().EndsWith(SearchDarkhastName.ToLower()));
                }
                else if (Properties.Settings.Default.SearchDarkhastNameSearchType == (int)SearchType.MatchCase)
                {
                    darkhasthaQuery2 = darkhasthaQuery2.Where(x => x.IsTrash != (int)Trash.OutOfTrash &&
                                                              x.DarkhastName.ToLower().Equals(SearchDarkhastName.ToLower()));
                }
            }


            if (SearchShomareFani.Length > 0)
            {
                if (Properties.Settings.Default.SearchShomareFaniSearchType == (int)SearchType.Contains)
                {
                    darkhasthaQuery2 = darkhasthaQuery2.Where(x => x.IsTrash != (int)Trash.OutOfTrash &&
                                                              x.ShomareFani.ToLower().Contains(SearchShomareFani.ToLower()));
                }
                else if (Properties.Settings.Default.SearchShomareFaniSearchType == (int)SearchType.StarstWith)
                {
                    darkhasthaQuery2 = darkhasthaQuery2.Where(x => x.IsTrash != (int)Trash.OutOfTrash &&
                                                              x.ShomareFani.ToLower().StartsWith(SearchShomareFani.ToLower()));
                }
                else if (Properties.Settings.Default.SearchShomareFaniSearchType == (int)SearchType.EndsWith)
                {
                    darkhasthaQuery2 = darkhasthaQuery2.Where(x => x.IsTrash != (int)Trash.OutOfTrash &&
                                                              x.ShomareFani.ToLower().EndsWith(SearchShomareFani.ToLower()));
                }
                else if (Properties.Settings.Default.SearchShomareFaniSearchType == (int)SearchType.MatchCase)
                {
                    darkhasthaQuery2 = darkhasthaQuery2.Where(x => x.IsTrash != (int)Trash.OutOfTrash
                                                              &&
                                                              x.ShomareFani.ToLower().Equals(
                                                                  SearchShomareFani.ToLower()));
                }
            }


            if (SearchTozihat.Length > 0)
            {
                if (Properties.Settings.Default.SearchTozihatSearchType == (int)SearchType.Contains)
                {
                    darkhasthaQuery2 = darkhasthaQuery2.Where(x => x.IsTrash != (int)Trash.OutOfTrash &&
                                                              x.Tozihat.ToLower().Contains(SearchTozihat.ToLower()));
                }
                else if (Properties.Settings.Default.SearchTozihatSearchType == (int)SearchType.StarstWith)
                {
                    darkhasthaQuery2 = darkhasthaQuery2.Where(x => x.IsTrash != (int)Trash.OutOfTrash &&
                                                              x.Tozihat.ToLower().StartsWith(SearchTozihat.ToLower()));
                }
                else if (Properties.Settings.Default.SearchTozihatSearchType == (int)SearchType.EndsWith)
                {
                    darkhasthaQuery2 = darkhasthaQuery2.Where(x => x.IsTrash != (int)Trash.OutOfTrash &&
                                                              x.Tozihat.ToLower().EndsWith(SearchTozihat.ToLower()));
                }
                else if (Properties.Settings.Default.SearchTozihatSearchType == (int)SearchType.MatchCase)
                {
                    darkhasthaQuery2 = darkhasthaQuery2.Where(x => x.IsTrash != (int)Trash.OutOfTrash
                                                              &&
                                                              x.Tozihat.ToLower().Equals(
                                                                  SearchTozihat.ToLower()));
                }
            }

            var itemSource = new Darkhastha2Collecttion(darkhasthaQuery2);

            GridViewDarkhastha.ItemsSource = itemSource;
        }