/// <summary> /// DeleteDirect /// </summary> /// <param name="materialId">materialId</param> /// <param name="companyId">companyId</param> public void DeleteDirect(int materialId, int companyId) { // Delete notes MaterialsNotes materialsNotes = new MaterialsNotes(null); materialsNotes.DeleteAllDirect(materialId, companyId); // Delete costs MaterialsCostHistory materialsCostHistory = new MaterialsCostHistory(null); materialsCostHistory.DeleteAllDirect(materialId, companyId); // Delete materials Materials materials = new Materials(null); materials.DeleteDirect(materialId); }
/// <summary> /// Save all materials to database (direct) /// </summary> /// <param name="companyId">companyId</param> public void Save(int companyId) { MaterialsInformationTDS materialInformationChanges = (MaterialsInformationTDS)Data.GetChanges(); if (materialInformationChanges.NoteInformation.Rows.Count > 0) { MaterialsInformationNoteInformationGateway materialsInformationNoteInformationGateway = new MaterialsInformationNoteInformationGateway(materialInformationChanges); foreach (MaterialsInformationTDS.NoteInformationRow row in (MaterialsInformationTDS.NoteInformationDataTable)materialInformationChanges.NoteInformation) { // Insert new Notes if ((!row.Deleted) && (!row.InDatabase)) { MaterialsNotes materialsNotes = new MaterialsNotes(null); materialsNotes.InsertDirect(row.MaterialID, row.RefID, row.Subject, row.UserID, row.DateTime_, row.Note, row.Deleted, row.COMPANY_ID); } // Update Notes if ((!row.Deleted) && (row.InDatabase)) { int materialId = row.MaterialID; int refId = row.RefID; bool originalDeleted = row.Deleted; int originalCompanyId = companyId; // original values string originalSubject = materialsInformationNoteInformationGateway.GetSubjectOriginal(materialId, refId); int originalUserId = materialsInformationNoteInformationGateway.GetUserIdOriginal(materialId, refId); DateTime originalDateTime_ = materialsInformationNoteInformationGateway.GetDateTime_Original(materialId, refId); string originalNote = materialsInformationNoteInformationGateway.GetNoteOriginal(materialId, refId); // new values string newSubject = materialsInformationNoteInformationGateway.GetSubject(materialId, refId); string newNote = materialsInformationNoteInformationGateway.GetNote(materialId, refId); MaterialsNotes materialsNotes = new MaterialsNotes(null); materialsNotes.UpdateDirect(materialId, refId, originalSubject, originalUserId, originalDateTime_, originalNote, originalDeleted, originalCompanyId, materialId, refId, newSubject, originalUserId, originalDateTime_, newNote, originalDeleted, originalCompanyId); } // Deleted notes if ((row.Deleted) && (row.InDatabase)) { MaterialsNotes materialsNotes = new MaterialsNotes(null); materialsNotes.DeleteDirect(row.MaterialID, row.RefID, row.COMPANY_ID); } } } }