Пример #1
0
        /// <summary>
        /// Usuwanie zaznaczonego elementu z tabeli "Users"
        /// </summary>
        private void DeleteRecordFromUsers()
        {
            using (var db = new BusinessCodingModelContex())
            {
                try
                {
                    db.Users.Attach(selectedUser);
                    db.Users.Remove(selectedUser);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Error!");
                    return;
                }
                try
                {
                    db.SaveChanges();
                }
                catch
                {
                    MessageBox.Show("Cannot delete a record to which reference is.");
                    return;
                }

                Thread newThread = new Thread(DisplayAllRecordsFromUsers);
                newThread.Start();
            }
        }
Пример #2
0
        /// <summary>
        /// Dodanie rekordu do tabeli Users.
        /// </summary>
        /// <param name="entryForm">okno z którego pobieramy dane</param>
        private void AddRecordToUsers(object entry)
        {
            Users newUser = (Users)entry;
            using (var db = new BusinessCodingModelContex())
            {
                try
                {
                    newUser.UserID = db.Users.Max(x => x.UserID) + 1;
                }
                catch
                {
                    newUser.UserID = 1;
                }

                db.Users.Add(newUser);

                db.SaveChanges();

                Thread newThread = new Thread(DisplayAllRecordsFromUsers);
                newThread.Start();
            }
        }
Пример #3
0
        /// <summary>
        /// Obsługa przycisku "Execute"
        /// </summary>
        private void buttonExecute_Click(object sender, RoutedEventArgs e)
        {
            int result;
            using (var db = new BusinessCodingModelContex())
            {
                string query = richTextBoxQuery();
                try
                {
                    result = db.Database.ExecuteSqlCommand(query);
                }
                catch
                {
                    MessageBox.Show("Wrong query");
                    return;
                }
                if (result < 0)
                {
                    result = 0;
                }
                MessageBox.Show(string.Format("Result: {0} row(s) affected", result));

                db.SaveChanges();
            }
        }
Пример #4
0
        /// <summary>
        /// Dodanie rekordu do tabeli Projects.
        /// </summary>
        /// <param name="entryForm">okno z którego pobieramy dane</param>
        private void AddRecordToProjects(object entry)
        {
            Projects newProject = (Projects)entry;
            using (var db = new BusinessCodingModelContex())
            {
                try
                {
                    newProject.ProjectID = db.Projects.Max(x => x.ProjectID) + 1;
                }
                catch
                {
                    newProject.ProjectID = 1;
                }

                db.Projects.Add(newProject);

                try
                {
                    db.SaveChanges();
                }
                catch
                {
                    MessageBox.Show("You have to add a good reference.");
                    return;
                }

                Thread newThread = new Thread(DisplayAllRecordsFromProjects);
                newThread.Start();
            }
        }
Пример #5
0
        /// <summary>
        /// Dodanie rekordu do tabeli TypesOfOffices.
        /// </summary>
        /// <param name="entryForm">okno z którego pobieramy dane</param>
        private void AddRecordToTypesOfOffices(object entry)
        {
            TypesOfOffices too = (TypesOfOffices)entry;
            using (var db = new BusinessCodingModelContex())
            {
                try
                {
                    too.TOOfficeID = db.TypesOfOffices.Max(x => x.TOOfficeID) + 1;
                }
                catch
                {
                    too.TOOfficeID = 1;
                }

                db.TypesOfOffices.Add(too);

                db.SaveChanges();

                Thread newThread = new Thread(DisplayAllRecordsFromTypesOfOffices);
                newThread.Start();
            }
        }
Пример #6
0
        /// <summary>
        /// Dodanie rekordu do tabeli Descriptions.
        /// </summary>
        /// <param name="entryForm">okno z którego pobieramy dane</param>
        private void AddRecordToDescriptions(object entry)
        {
            Descriptions newDescription = (Descriptions)entry;
            using (var db = new BusinessCodingModelContex())
            {
                try
                {
                    newDescription.DescriptionID = db.Descriptions.Max(x => x.DescriptionID) + 1;
                }
                catch
                {
                    newDescription.DescriptionID = 1;
                }

                db.Descriptions.Add(newDescription);

                try
                {
                    db.SaveChanges();
                }
                catch
                {
                    MessageBox.Show("You have to add a good reference.");
                    return;
                }

                Thread newThread = new Thread(DisplayAllRecordsFromDescriptions);
                newThread.Start();
            }
        }
Пример #7
0
        /// <summary>
        /// Dodanie rekordu do tabeli Employees.
        /// </summary>
        /// <param name="entryForm">okno z którego pobieramy dane</param>
        private void AddRecordToEmployees(object entry)
        {
            Empolyees newEmployee = (Empolyees)entry;
            using (var db = new BusinessCodingModelContex())
            {

                try
                {
                    newEmployee.EmployeeID = db.Empolyees.Max(x => x.EmployeeID) + 1;
                }
                catch
                {
                    newEmployee.EmployeeID = 1;
                }
                db.Empolyees.Add(newEmployee);

                try
                {
                    db.SaveChanges();
                }
                catch
                {
                    MessageBox.Show("You have to add a good reference.");
                    return;
                }

                Thread newThread = new Thread(DisplayAllRecordsFromEmployees);
                newThread.Start();
            }
        }
Пример #8
0
        private void ModyfingUsersInNewThread()
        {
            using (var db = new BusinessCodingModelContex())
            {
                db.Users.Attach(selectedUser);
                var entry = db.Entry(selectedUser);

                entry.Property(x => x.ActivationDate).IsModified = true;
                entry.Property(x => x.Email).IsModified = true;
                entry.Property(x => x.LastLogin).IsModified = true;
                entry.Property(x => x.Login).IsModified = true;
                entry.Property(x => x.Password).IsModified = true;

                db.SaveChanges();
            }
            Thread newThread = new Thread(DisplayAllRecordsFromUsers);
            newThread.Start();
        }
Пример #9
0
        /// <summary>
        /// Dodanie rekordu do tabeli Companies.
        /// </summary>
        /// <param name="entryForm">okno z którego pobieramy dane</param>
        private void AddRecordToCompanies(object entry)
        {
            Companies newCompany = (Companies)entry;
            using (var db = new BusinessCodingModelContex())
            {

                try
                {
                    newCompany.CompanyID = db.Companies.Max(x => x.CompanyID) + 1;
                }
                catch
                {
                    newCompany.CompanyID = 1;
                }
                db.Companies.Add(newCompany);

                try
                {
                    db.SaveChanges();
                }
                catch
                {
                    MessageBox.Show("You have to add a good reference.");
                    return;
                }

                Thread newThread = new Thread(DisplayAllRecordsFromCompanies);
                newThread.Start();
            }
        }
Пример #10
0
        private void ModyfingProjectsInNewThread()
        {
            using (var db = new BusinessCodingModelContex())
            {
                db.Projects.Attach(selectedProject);
                var entry = db.Entry(selectedProject);

                entry.Property(x => x.CompaniesCompanyID).IsModified = true;
                entry.Property(x => x.Complexity).IsModified = true;
                entry.Property(x => x.Gratification).IsModified = true;
                entry.Property(x => x.MinCodity).IsModified = true;
                entry.Property(x => x.MinRespect).IsModified = true;
                entry.Property(x => x.Name).IsModified = true;
                entry.Property(x => x.TimeRounds).IsModified = true;
                entry.Property(x => x.TimeToEnd).IsModified = true;
                try
                {
                    db.SaveChanges();
                }
                catch
                {
                    MessageBox.Show("You have to give a reference to existing record.");
                }
            }
            Thread newThread = new Thread(DisplayAllRecordsFromProjects);
            newThread.Start();
        }
Пример #11
0
        private void ModifyingTypesOfEmployeesInNewThread()
        {
            using (var db = new BusinessCodingModelContex())
            {
                db.TypesOfEmployees.Attach(selectedTypesOfEmployee);
                var entry = db.Entry(selectedTypesOfEmployee);

                entry.Property(x => x.Codity).IsModified = true;
                entry.Property(x => x.Name).IsModified = true;
                entry.Property(x => x.Salary).IsModified = true;

                try
                {
                    db.SaveChanges();
                }
                catch
                {
                    MessageBox.Show("You have to give a reference to existing record.");
                }
            }
            Thread newThread = new Thread(DisplayAllRecordsFromTypesOfEmployees);
            newThread.Start();
        }
Пример #12
0
        private void ModifyingTypeOfOfficesInNewThread()
        {
            using (var db = new BusinessCodingModelContex())
            {
                db.TypesOfOffices.Attach(selectedTypesOfOffice);
                var entry = db.Entry(selectedTypesOfOffice);

                entry.Property(x => x.Capacity).IsModified = true;
                entry.Property(x => x.CostOfHiring).IsModified = true;
                entry.Property(x => x.Name).IsModified = true;

                db.SaveChanges();
            }
            Thread newThread = new Thread(DisplayAllRecordsFromTypesOfOffices);
            newThread.Start();
        }
Пример #13
0
        private void ModifyingDescriptionsInNewThread()
        {
            using (var db = new BusinessCodingModelContex())
            {
                db.Descriptions.Attach(selectedDesciption);
                var entry = db.Entry(selectedDesciption);

                entry.Property(x => x.ProjectsProjectID).IsModified = true;
                entry.Property(x => x.String).IsModified = true;
                try
                {
                    db.SaveChanges();
                }
                catch
                {
                    MessageBox.Show("You have to give a reference to existing record.");
                }
            }
            Thread newThread = new Thread(DisplayAllRecordsFromDescriptions);
            newThread.Start();
        }
Пример #14
0
        private void ModifyingCompaniesInNewThread()
        {
            using (var db = new BusinessCodingModelContex())
            {
                db.Companies.Attach(selectedCompany);
                var entry = db.Entry(selectedCompany);

                entry.Property(x => x.CostOfLiving).IsModified = true;
                entry.Property(x => x.Money).IsModified = true;
                entry.Property(x => x.Name).IsModified = true;
                entry.Property(x => x.Respect).IsModified = true;
                entry.Property(x => x.TypesOfOfficesTOOfficeID).IsModified = true;
                entry.Property(x => x.UsersUserID).IsModified = true;
                try
                {
                    db.SaveChanges();
                }
                catch
                {
                    MessageBox.Show("You have to give a reference to existing record.");
                }
            }
            Thread newThread = new Thread(DisplayAllRecordsFromCompanies);
            newThread.Start();
        }