/// <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);
        }
Пример #2
0
        /// <summary>
        /// Save
        /// </summary>
        public void Save()
        {
            MaterialsAddTDS materialsAddChanges = (MaterialsAddTDS)Data.GetChanges();

            if (materialsAddChanges != null)
            {
                if (materialsAddChanges.MaterialAdd.Rows.Count > 0)
                {
                    MaterialsAddGateway materialsNavigatorGateway = new MaterialsAddGateway(materialsAddChanges);

                    // Update materials
                    foreach (MaterialsAddTDS.MaterialAddRow row in (MaterialsAddTDS.MaterialAddDataTable)materialsAddChanges.MaterialAdd)
                    {
                        // Insert new materials
                        if ((!row.Deleted) && (!row.InDatabase))
                        {
                            Materials material = new Materials(null);
                            int materialId = row.MaterialID;
                            string description = row.Description;
                            string size = ""; if(!row.IsSizeNull()) size = row.Size;
                            string length = ""; if (!row.IsLengthNull()) length = row.Length;
                            string thickness = ""; if (!row.IsThicknessNull()) thickness = row.Thickness;
                            string type = row.Type;
                            string state = row.State;
                            bool deleted = row.Deleted;
                            int companyId = row.COMPANY_ID;

                            material.InsertDirect(materialId, description, size, length, thickness, type, state, deleted, companyId);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            MaterialsInformationTDS materialsInformationChanges = (MaterialsInformationTDS)Data.GetChanges();

            if (materialsInformationChanges.BasicInformation.Rows.Count > 0)
            {
                MaterialsInformationBasicInformationGateway materialsInformationBasicInformationGateway = new MaterialsInformationBasicInformationGateway(materialsInformationChanges);

                // Update services
                foreach (MaterialsInformationTDS.BasicInformationRow basicInformationRow in (MaterialsInformationTDS.BasicInformationDataTable)materialsInformationChanges.BasicInformation)
                {
                    // Unchanged values
                    int materialId = basicInformationRow.MaterialID;
                    bool deleted = basicInformationRow.Deleted;

                    // Original values
                    string originalDescription = materialsInformationBasicInformationGateway.GetDescriptionOriginal(materialId);
                    string originalSize = materialsInformationBasicInformationGateway.GetSizeOriginal(materialId);
                    string originalLength = materialsInformationBasicInformationGateway.GetLengthOriginal(materialId);
                    string originalThickness = materialsInformationBasicInformationGateway.GetThicknessOriginal(materialId);
                    string originalType = materialsInformationBasicInformationGateway.GetTypeOriginal(materialId);
                    string originalState = materialsInformationBasicInformationGateway.GetStateOriginal(materialId);

                    // New variables
                    string newDescription = materialsInformationBasicInformationGateway.GetDescription(materialId);
                    string newSize = materialsInformationBasicInformationGateway.GetSize(materialId);
                    string newLength = materialsInformationBasicInformationGateway.GetLength(materialId);
                    string newThickness = materialsInformationBasicInformationGateway.GetThickness(materialId);
                    string newType = materialsInformationBasicInformationGateway.GetType(materialId);
                    string newState = materialsInformationBasicInformationGateway.GetState(materialId);

                    // ... Update
                    Materials materials = new Materials(null);
                    materials.UpdateDirect(materialId, originalDescription, originalSize, originalLength, originalThickness, originalType, originalState, deleted, companyId, materialId, newDescription, newSize, newLength, newThickness, newType, newState, deleted, companyId);
                }
            }
        }