// ////////////////////////////////////////////////////////////////////////
 // PUBLIC METHODS
 //
 /// <summary>
 /// LoadAllByEmployeeId
 /// </summary>
 /// <param name="employeeId">employeeId</param>              
 /// <param name="companyId">companyId</param>
 public void LoadAllByEmployeeId(int employeeId, int companyId)
 {
     EmployeeInformationNoteInformationGateway employeeInformationNoteInformationGateway = new EmployeeInformationNoteInformationGateway(Data);
     employeeInformationNoteInformationGateway.LoadAllByEmployeeId(employeeId, companyId);
 }
        /// <summary>
        /// Save all employee notes to database (direct)
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            EmployeeInformationTDS employeeInformationChanges = (EmployeeInformationTDS)Data.GetChanges();

            if (employeeInformationChanges.NoteInformation.Rows.Count > 0)
            {
                EmployeeInformationNoteInformationGateway employeeInformationNoteInformationGateway = new EmployeeInformationNoteInformationGateway(employeeInformationChanges);

                foreach (EmployeeInformationTDS.NoteInformationRow row in (EmployeeInformationTDS.NoteInformationDataTable)employeeInformationChanges.NoteInformation)
                {
                    // Insert new Notes
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        EmployeeNotes employeeNotes = new EmployeeNotes(null);
                        employeeNotes.InsertDirect(row.EmployeeID, row.RefID, row.Subject, row.UserID, row.DateTime_, row.Note, row.Deleted, row.COMPANY_ID);
                    }

                    // Update Notes
                    if ((!row.Deleted) && (row.InDatabase))
                    {
                        int employeeId = row.EmployeeID;
                        int refId = row.RefID;
                        bool originalDeleted = row.Deleted;
                        int originalCompanyId = companyId;

                        // original values
                        string originalSubject = employeeInformationNoteInformationGateway.GetSubjectOriginal(employeeId, refId);
                        int originalUserId = employeeInformationNoteInformationGateway.GetUserIdOriginal(employeeId, refId);
                        DateTime originalDateTime_ = employeeInformationNoteInformationGateway.GetDateTime_Original(employeeId, refId);
                        string originalNote = employeeInformationNoteInformationGateway.GetNoteOriginal(employeeId, refId);

                        // new values
                        string newSubject = employeeInformationNoteInformationGateway.GetSubject(employeeId, refId);
                        string newNote = employeeInformationNoteInformationGateway.GetNote(employeeId, refId);

                        EmployeeNotes employeeNote = new EmployeeNotes(null);
                        employeeNote.UpdateDirect(employeeId, refId, originalSubject, originalUserId, originalDateTime_, originalNote, originalDeleted, originalCompanyId, employeeId, refId, newSubject, originalUserId, originalDateTime_, newNote, originalDeleted, originalCompanyId);
                    }

                    // Deleted notes
                    if ((row.Deleted) && (row.InDatabase))
                    {
                        EmployeeNotes employeeNote = new EmployeeNotes(null);
                        employeeNote.DeleteDirect(row.EmployeeID, row.RefID, row.COMPANY_ID);
                    }
                }
            }
        }