/// <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 costs to database (direct)
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            MaterialsInformationTDS costHistoryInformationChanges = (MaterialsInformationTDS)Data.GetChanges();

            if (costHistoryInformationChanges.CostHistoryInformation.Rows.Count > 0)
            {
                MaterialsInformationCostHistoryInformationGateway materialsInformationCostHistoryInformationGateway = new MaterialsInformationCostHistoryInformationGateway(costHistoryInformationChanges);

                foreach (MaterialsInformationTDS.CostHistoryInformationRow row in (MaterialsInformationTDS.CostHistoryInformationDataTable)costHistoryInformationChanges.CostHistoryInformation)
                {
                    // Insert new costs
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        MaterialsCostHistory materialsCostHistory = new MaterialsCostHistory(null);
                        materialsCostHistory.InsertDirect(row.CostID, row.MaterialID, row.Date, row.UnitOfMeasurement, row.CostCad, row.CostUsd, row.Deleted, row.COMPANY_ID);
                    }

                    // Update costs
                    if ((!row.Deleted) && (row.InDatabase))
                    {
                        int costId = row.CostID;
                        int materialId = row.MaterialID;
                        bool originalDeleted = row.Deleted;
                        int originalCompanyId = companyId;

                        // original values
                        DateTime originalDate = materialsInformationCostHistoryInformationGateway.GetDateOriginal(costId, materialId);
                        string originalUnitOfMeasurement = materialsInformationCostHistoryInformationGateway.GetUnitOfMeasurementOriginal(costId, materialId);
                        decimal originalCostCad = materialsInformationCostHistoryInformationGateway.GetCostCadOriginal(costId, materialId);
                        decimal originalCostUsd = materialsInformationCostHistoryInformationGateway.GetCostUsdOriginal(costId, materialId);

                        // new values
                        DateTime newDate = materialsInformationCostHistoryInformationGateway.GetDate(costId, materialId);
                        string newUnitOfMeasurement = materialsInformationCostHistoryInformationGateway.GetUnitOfMeasurement(costId, materialId);
                        decimal newCostCad = materialsInformationCostHistoryInformationGateway.GetCostCad(costId, materialId);
                        decimal newCostUsd = materialsInformationCostHistoryInformationGateway.GetCostUsd(costId, materialId);

                        MaterialsCostHistory materialsCostHistory = new MaterialsCostHistory(null);
                        materialsCostHistory.UpdateDirect(costId, materialId, originalDate, originalUnitOfMeasurement, originalCostCad, originalCostUsd, originalDeleted, originalCompanyId, costId, materialId, newDate, newUnitOfMeasurement, newCostCad, newCostUsd, originalDeleted, originalCompanyId);
                    }

                    // Deleted costs
                    if ((row.Deleted) && (row.InDatabase))
                    {
                        MaterialsCostHistory materialsCostHistory = new MaterialsCostHistory(null);
                        materialsCostHistory.DeleteDirect(row.CostID, row.MaterialID, row.COMPANY_ID);
                    }
                }
            }
        }