/// <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(); } }
/// <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(); } }
/// <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(); } }
/// <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(); } }
/// <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(); } }
/// <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(); } }
/// <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(); } }
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(); }
/// <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(); } }
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(); }
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(); }
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(); }
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(); }
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(); }