Example #1
0
        private async void Btn_delete_Click(object sender, RoutedEventArgs e)
        {//delete
            try
            {
                if (sender != null)
                {
                    SectionData.StartAwait(grid_main);
                }

                if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "delete") || SectionData.isAdminPermision())
                {
                    if (sysEmail.emailId != 0)
                    {
                        if ((!sysEmail.canDelete) && (sysEmail.isActive == 0))
                        {
                            #region
                            Window.GetWindow(this).Opacity = 0.2;
                            wd_acceptCancelPopup w = new wd_acceptCancelPopup();
                            w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxActivate");
                            w.ShowDialog();
                            Window.GetWindow(this).Opacity = 1;
                            #endregion

                            if (w.isOk)
                            {
                                await activate();
                            }
                        }
                        else
                        {
                            #region
                            Window.GetWindow(this).Opacity = 0.2;
                            wd_acceptCancelPopup w = new wd_acceptCancelPopup();
                            if (sysEmail.canDelete)
                            {
                                w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDelete");
                            }
                            if (!sysEmail.canDelete)
                            {
                                w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDeactivate");
                            }
                            w.ShowDialog();
                            Window.GetWindow(this).Opacity = 1;
                            #endregion

                            if (w.isOk)
                            {
                                string popupContent = "";
                                if (sysEmail.canDelete)
                                {
                                    popupContent = MainWindow.resourcemanager.GetString("trPopDelete");
                                }
                                if ((!sysEmail.canDelete) && (sysEmail.isActive == 1))
                                {
                                    popupContent = MainWindow.resourcemanager.GetString("trPopInActive");
                                }

                                int b = await sysEmail.Delete(sysEmail.emailId, MainWindow.userID.Value, sysEmail.canDelete);

                                if (!b.Equals(0))
                                {
                                    sysEmail.emailId = 0;
                                    Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopDelete"), animation: ToasterAnimation.FadeIn);
                                }
                                else
                                {
                                    Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                                }
                            }
                        }

                        await RefreshSysEmailList();

                        Tb_search_TextChanged(null, null);

                        //clear textBoxs
                        Btn_clear_Click(null, null);
                    }
                }
                else
                {
                    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
                }
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
            }
            catch (Exception ex)
            {
                if (sender != null)
                {
                    SectionData.EndAwait(grid_main);
                }
                SectionData.ExceptionMessage(ex, this);
            }
        }
        private async void Btn_delete_Click(object sender, RoutedEventArgs e)
        {
            try
            {//delete
             //if (MainWindow.groupObject.HasPermissionAction(basicsPermission, MainWindow.groupObjects, "delete"))
             //{
                HelpClass.StartAwait(grid_main);
                if (sysEmail.emailId != 0)
                {
                    if ((!sysEmail.canDelete) && (sysEmail.isActive == 0))
                    {
                        #region
                        Window.GetWindow(this).Opacity = 0.2;
                        wd_acceptCancelPopup w = new wd_acceptCancelPopup();
                        w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxActivate");
                        w.ShowDialog();
                        Window.GetWindow(this).Opacity = 1;
                        #endregion
                        if (w.isOk)
                        {
                            await activate();
                        }
                    }
                    else
                    {
                        #region
                        Window.GetWindow(this).Opacity = 0.2;
                        wd_acceptCancelPopup w = new wd_acceptCancelPopup();
                        if (sysEmail.canDelete)
                        {
                            w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDelete");
                        }
                        if (!sysEmail.canDelete)
                        {
                            w.contentText = MainWindow.resourcemanager.GetString("trMessageBoxDeactivate");
                        }
                        w.ShowDialog();
                        Window.GetWindow(this).Opacity = 1;
                        #endregion
                        if (w.isOk)
                        {
                            string popupContent = "";
                            if (sysEmail.canDelete)
                            {
                                popupContent = MainWindow.resourcemanager.GetString("trPopDelete");
                            }
                            if ((!sysEmail.canDelete) && (sysEmail.isActive == 1))
                            {
                                popupContent = MainWindow.resourcemanager.GetString("trPopInActive");
                            }

                            int s = await sysEmail.Delete(sysEmail.emailId, MainWindow.userLogin.userId, sysEmail.canDelete);

                            if (s < 0)
                            {
                                Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopError"), animation: ToasterAnimation.FadeIn);
                            }
                            else
                            {
                                sysEmail.emailId = 0;
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trPopDelete"), animation: ToasterAnimation.FadeIn);

                                await RefreshUsersList();
                                await Search();

                                Clear();
                            }
                        }
                    }
                }
                HelpClass.EndAwait(grid_main);
                //}
                //else
                //    Toaster.ShowInfo(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trdontHavePermission"), animation: ToasterAnimation.FadeIn);
            }
            catch (Exception ex)
            {
                HelpClass.EndAwait(grid_main);
                HelpClass.ExceptionMessage(ex, this);
            }
        }