private void btnDeleteContact_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new DatabaseContext())
            {
                var selectedContact = dcContactsList.SelectedItem as ContactView;

                if (selectedContact != null)
                {
                    var contact = context.Contacts.FirstOrDefault(c => c.ContactID == selectedContact.ContactId);

                    if (contact != null)
                    {
                        var window = new MessageBoxWindow("Are you sure you want to delete this contact person?");
                        window.Height = 0;
                        window.Top = screenTopEdge + 8;
                        window.Left = (screenWidth / 2) - (window.Width / 2);
                        if (screenLeftEdge > 0 || screenLeftEdge < -8) { window.Left += screenLeftEdge; }
                        window.ShowDialog();

                        if (Variables.yesClicked == true)
                        {
                            var activity = context.LeadActivities.Where(c => ((c.ActivityDate == null || c.ActivityDate == "")
                                || (c.ActivityTime == null || c.ActivityTime == "")) && (c.IsFinalized == false)).FirstOrDefault(c => c.LeadID == contact.LeadId);

                            if (activity != null)
                            {
                                var windows = new NoticeWindow();
                                NoticeWindow.message = "Contact person still has an unaccomplished activity.";
                                windows.Height = 0;
                                windows.Top = screenTopEdge + 8;
                                windows.Left = (screenWidth / 2) - (windows.Width / 2);
                                if (screenLeftEdge > 0 || screenLeftEdge < -8) { windows.Left += screenLeftEdge; }
                                windows.ShowDialog();

                                var log = new Log();
                                log.Date = DateTime.Now.ToString("MM/dd/yyyy");
                                log.Description = contact.ContactPersonName
                                    + " is not deleted due to unaccomplished activity(ies).";
                                log.Time = DateTime.Now.ToString("hh:mm:ss tt");
                                context.Logs.Add(log);
                                context.SaveChanges();
                            }
                            else
                            {
                                busyIndicator.IsBusy = true;
                                context.Contacts.Remove(contact);

                                var lead = context.Leads.FirstOrDefault(c => c.LeadID == contact.LeadId);
                                var log = new Log();
                                log.Date = DateTime.Now.ToString("MM/dd/yyyy");
                                log.Description = NotificationWindow.username + " deleted " 
                                    + contact.ContactPersonName + " from " + lead.CompanyName 
                                    + " contacts.";
                                log.Time = DateTime.Now.ToString("hh:mm:ss tt");
                                context.Logs.Add(log);

                                var windows = new NoticeWindow();
                                NoticeWindow.message = "Contact person successfully deleted";
                                windows.Height = 0;
                                windows.Top = screenTopEdge + 8;
                                windows.Left = (screenWidth / 2) - (windows.Width / 2);
                                if (screenLeftEdge > 0 || screenLeftEdge < -8) { windows.Left += screenLeftEdge; }
                                windows.ShowDialog();

                                context.SaveChanges();
                            }
                        }
                    }
                }
                else
                {
                    busyIndicator.IsBusy = true;
                    NullMessage();
                }
                LoadLeads();
                busyIndicator.IsBusy = false;
            }
        }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            using (var context= new DatabaseContext())
            {
                var selectedAccount = dcCustomerAccountsList.SelectedItem as CustomerAccountsView;

                if (selectedAccount != null)
                {
                    var account = context.CustomerAccounts.FirstOrDefault(c => c.AccountNumber == selectedAccount.AccountNumber);

                    if (account != null)
                    {
                        var window = new MessageBoxWindow("Are you sure you want to delete this record?");
                        window.Height = 0;
                        window.Top = screenTopEdge + 8;
                        window.Left = (screenWidth / 2) - (window.Width / 2);
                        if (screenLeftEdge > 0 || screenLeftEdge < -8) { window.Left += screenLeftEdge; }
                        window.ShowDialog();

                        if (Variables.yesClicked == true)
                        {
                            var log = new Log();
                            log.Date = DateTime.Now.ToString("MM/dd//yyyy");
                            log.Time = DateTime.Now.ToString("HH:mm");
                            log.Description = NotificationWindow.username + " deleted "
                                + selectedAccount.Customer + "'s customer account.";
                            context.Logs.Add(log);

                            context.CustomerAccounts.Remove(account);
                            var windows = new Shared.Windows.NoticeWindow();
                            Shared.Windows.NoticeWindow.message = "Customer account successfully deleted";
                            windows.Height = 0;
                            windows.Top = screenTopEdge + 8;
                            windows.Left = (screenWidth / 2) - (windows.Width / 2);
                            if (screenLeftEdge > 0 || screenLeftEdge < -8) { windows.Left += screenLeftEdge; }
                            windows.ShowDialog();

                            context.SaveChanges();
                        }
                    }
                    else
                    {
                        NullMessage();
                    }
                }
                LoadCustomerAccounts();
            }
        }
Exemple #3
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new DatabaseContext())
            {
                var selectedUser = dcUsersList.SelectedItem as UsersLists;

                if (selectedUser != null)
                {
                    var user = context.UserAccounts.FirstOrDefault
                        (c => c.UserAccountId.ToLower() == selectedUser.UserAccountId.ToLower());
                    
                    if (user != null)
                    {
                        var window = new MessageBoxWindow("Are you sure you want to permanently delete this record?");
                        window.Height = 0;
                        window.Top = screenTopEdge + 8;
                        window.Left = (screenWidth / 2) - (window.Width / 2);
                        if (screenLeftEdge > 0 || screenLeftEdge < -8) { window.Left += screenLeftEdge; }
                        window.ShowDialog();

                        if (Variables.yesClicked == true)
                        {
                            context.UserAccounts.Remove(user);

                            var windows = new NoticeWindow();
                            NoticeWindow.message = "Lead succesfully deleted";
                            windows.Height = 0;
                            windows.Top = screenTopEdge + 8;
                            windows.Left = (screenWidth / 2) - (windows.Width / 2);
                            if (screenLeftEdge > 0 || screenLeftEdge < -8) { windows.Left += screenLeftEdge; }
                            windows.ShowDialog();

                            context.SaveChanges();
                        }
                    }
                    else
                    {
                        NullMessage();
                    }
                }
                LoadUsers();
            }
        }
         private void btnDelete_Click(object sender, RoutedEventArgs e)
         {
             using (var context= new DatabaseContext())
             {
                 var selectedSalestage = dcSalesStagesList.SelectedItem as SalesStagesView;

                 if (selectedSalestage != null)
                 {
                     var salestage = context.SalesStages.First(c => c.SalesStageID == selectedSalestage.SalesStageID);

                     if (salestage != null)
                     {
                         var window = new MessageBoxWindow("Are you sure you want to delete this record?");
                         window.Height = 0;
                         window.Top = screenTopEdge + 8;
                         window.Left = (screenWidth / 2) - (window.Width / 2);
                         if (screenLeftEdge > 0 || screenLeftEdge < -8) { window.Left += screenLeftEdge; }
                         window.ShowDialog();

                         if (Variables.yesClicked == true)
                         {
                             context.SalesStages.Remove(salestage);

                             var log = new Log();
                             log.Date = DateTime.Now.ToString("MM/dd/yyyy");
                             log.Description = NotificationWindow.username + " deleted "
                                 + salestage.SalesStageName + " sales stage status.";
                             log.Time = DateTime.Now.ToString("hh:mm:ss tt");
                             context.Logs.Add(log);

                             var windows = new NoticeWindow();
                             NoticeWindow.message = "Sales stage successfully deleted";
                             windows.Height = 0;
                             windows.Top = screenTopEdge + 8;
                             windows.Left = (screenWidth / 2) - (windows.Width / 2);
                             if (screenLeftEdge > 0 || screenLeftEdge < -8) { windows.Left += screenLeftEdge; }
                             windows.ShowDialog();

                             context.SaveChanges();
                         }
                     }
                     else
                     {
                         NullMessage();
                     }
                 }
                 LoadActivity();
             }
         }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new DatabaseContext())
            {
                var selectedterritories = dcTerritoryList.SelectedItem as TerritoryView;

                if (selectedterritories != null)
                {
                    var terri = context.Territories.FirstOrDefault(c => c.TerritoryID == selectedterritories.TerritoryID);

                    if (terri != null)
                    {
                        var window = new MessageBoxWindow("Are you sure you want to delete this record?");
                        window.Height = 0;
                        window.Top = screenTopEdge + 8;
                        window.Left = (screenWidth / 2) - (window.Width / 2);
                        if (screenLeftEdge > 0 || screenLeftEdge < -8) { window.Left += screenLeftEdge; }
                        window.ShowDialog();

                        if (Variables.yesClicked == true)
                        {
                            context.Territories.Remove(terri);

                            var log = new Log();
                            log.Date = DateTime.Now.ToString("MM/dd/yyyy");
                            log.Time = DateTime.Now.ToString("hh:mm:ss tt");
                            log.Description = NotificationWindow.username + " deleted "
                                + selectedterritories.TerritoryName + " territory.";
                            context.Logs.Add(log);

                            var windows = new Shared.Windows.NoticeWindow();
                            Shared.Windows.NoticeWindow.message = "Territory successfully deleted";
                            windows.Height = 0;
                            windows.Top = screenTopEdge + 8;
                            windows.Left = (screenWidth / 2) - (windows.Width / 2);
                            if (screenLeftEdge > 0 || screenLeftEdge < -8) { windows.Left += screenLeftEdge; }
                            windows.ShowDialog();

                            context.SaveChanges();
                            LoadMethod(txtSearch.Text);
                        }
                    }
                }
            }
        }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            using (var context = new DatabaseContext())
            {
                var selectedEmployee = dcEmployeesList.SelectedItem as EmployeeView;

                if (selectedEmployee != null)
                {
                    var employee = context.Employees.FirstOrDefault(c => c.EmployeeId == selectedEmployee.EmployeeId);

                    if (employee != null)
                    {
                        var window = new MessageBoxWindow("Are you sure you want to delete this record?");
                        window.Height = 0;
                        window.Top = screenTopEdge + 8;
                        window.Left = (screenWidth / 2) - (window.Width / 2);
                        if (screenLeftEdge > 0 || screenLeftEdge < -8) { window.Left += screenLeftEdge; }
                        window.ShowDialog();

                        if (Variables.yesClicked == true)
                        {
                            context.Employees.Remove(employee);

                            var windows = new Shared.Windows.NoticeWindow();
                            Shared.Windows.NoticeWindow.message = "LEAD SUCCESSFULLY DELETED";
                            windows.Height = 0;
                            windows.Top = screenTopEdge + 8;
                            windows.Left = (screenWidth / 2) - (windows.Width / 2);
                            if (screenLeftEdge > 0 || screenLeftEdge < -8) { windows.Left += screenLeftEdge; }
                            windows.ShowDialog();

                            context.SaveChanges();
                        }
                        else
                        {
                            var windows = new Shared.Windows.NoticeWindow();
                            Shared.Windows.NoticeWindow.message = "DELETION CANCELLED";
                            windows.Height = 0;
                            windows.Top = screenTopEdge + 8;
                            windows.Left = (screenWidth / 2) - (windows.Width / 2);
                            if (screenLeftEdge > 0 || screenLeftEdge < -8) { windows.Left += screenLeftEdge; }
                            windows.ShowDialog();
                        }
                    }
                }
                LoadEmployees();
            }
        }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            using (var context= new DatabaseContext())
            {
                var selectedCustomer = dcCustomersList.SelectedItem as CustomersView;

                if (selectedCustomer != null)
                {
                    var customer = context.Customers.FirstOrDefault(c => c.CustomerID == selectedCustomer.CustomerID);

                    if (customer != null)
                    {
                        var window = new MessageBoxWindow("Are you sure you want to delete this record?");
                        window.Height = 0;
                        window.Top = screenTopEdge + 8;
                        window.Left = (screenWidth / 2) - (window.Width / 2);
                        if (screenLeftEdge > 0 || screenLeftEdge < -8) { window.Left += screenLeftEdge; }
                        window.ShowDialog();

                        if (Variables.yesClicked == true)
                        {
                            context.Customers.Remove(customer);
                            var windows = new Shared.Windows.NoticeWindow();
                            Shared.Windows.NoticeWindow.message = "Customer successfully deleted";
                            windows.Height = 0;
                            windows.Top = screenTopEdge + 8;
                            windows.Left = (screenWidth / 2) - (windows.Width / 2);
                            if (screenLeftEdge > 0 || screenLeftEdge < -8) { windows.Left += screenLeftEdge; }
                            windows.ShowDialog();

                            context.SaveChanges();
                        }
                    }
                    else
                    {
                        NullMessage();
                    }
                }
                LoadCustomers();
            }
        }
Exemple #8
0
        private void btnExit_Click(object sender, RoutedEventArgs e)
        {
            FoldStackPanelUpwardButton(stackUserContent);

            var window = new MessageBoxWindow("Are you sure you want to exit?");
            double screenWidth = Application.Current.MainWindow.Width;
            window.Height = 0;
            window.Top = Application.Current.MainWindow.Top + 8;
            window.Left = (screenWidth / 2) - (window.Width / 2);
            if (screenLeftEdge > 0 || screenLeftEdge < -8)
            {
                window.Left += screenLeftEdge;
            }
            window.ShowDialog();
            if (Variables.yesClicked == true)
            {
                using (var context = new DatabaseContext())
                {
                    var log = new Log();
                    log.Date = DateTime.Now.ToString("MM/dd/yyyy");
                    log.Time = DateTime.Now.ToString("hh:mm:ss tt");
                    log.Description = NotificationWindow.username + " logs out on "
                        + DateTime.Now.ToString("MMMM d, yyyy") + " at " + DateTime.Now.ToString("HH:mm") + ".";
                    context.Logs.Add(log);
                    context.SaveChanges();
                }

                Variables.yesClicked = false;
                Application.Current.MainWindow.Close();
            }
        }