示例#1
0
        /// <summary>
        /// Creates overView of given <see cref="Karafa.ConstructionHierarchy.ConstructionObject"/>>.
        /// </summary>
        /// <param name="obj"><see cref="Karafa.ConstructionHierarchy.ConstructionObject"/> with Etaps list</param>
        /// <param name="construction"><see cref="Karafa.ConstructionHierarchy.Construction"/> with header data</param>
        /// <param name="save">True to save PDF document, false not to.</param>
        public void CreateEtapOverView(
            ConstructionObject obj,
            Construction construction,
            bool save = true)
        {
            this.obj = obj;
            this.construction = construction;

            // Create PDF page
            PdfPage page = NewPage();

            try
            {
                // Draw initial header
                int yCoordinate = DrawHeader(page, 0, 0, page.Width.Value);

                // Draw every subsection name ane its prices
                yCoordinate = DrawEtapsGraph(page, 0, yCoordinate, page.Width.Value, page.Height.Value);

                // Add New page
                page = NewPage();

                yCoordinate = DrawItemsOfEtaps(page, 0, 20);

                // Save etap and show it
                if (save)
                    SaveDocument(obj.Name, true);
            }
            catch (Exception ex)
            {
                Karafa.Errors.KarafaLogger.LogError(ex);

                // Report error only when this document should be shown
                if (save)
                    KarafaMainWindow.Instance.ReportProcess(
                        Properties.Resources.MESSAGE_ERROR_ETAP_OVERVIEW_FAILED
                    );
            }
        }
示例#2
0
        /// <summary>
        /// Browses all imported items in all subsections of all CostsCalculations 
        /// in given constructionObject. Moves imported items to proper etap if needed.
        /// If Etap with toEtap doesn't exist in etaplist, default etap is taken.
        /// </summary>
        /// <param name="constructionObject">Construction object which items needs to be moved</param>
        /// <param name="fromEtapId">EtapID of etap which items are moved from</param>
        /// <param name="toEtapId">EtapID of etap which items are moved to</param>
        public void MoveSubsections(
            ConstructionObject constructionObject,
            int fromEtapId,
            int toEtapId)
        {
            if (constructionObject == null)
                return;

            // Get etaps and costCalculation list from constructiono object
            List<Etap> etapList = constructionObject.Etaps;
            List<CostsCalculation> costCalculationList = constructionObject.CalculationList;

            if (etapList == null || costCalculationList == null)
                return;

            // If etapList doesn't contain Etap with toEtapId, defautl etap is returned
            Etap toEtap = GetEtapById(etapList, toEtapId);
            toEtapId = toEtap.ID;

            // Browse all given cost calculations
            foreach (CostsCalculation calculation in costCalculationList)
            {
                // Browse all its subsections
                foreach (SubSection subsection in calculation.SubSections)
                {
                    // Browse all its imported main items
                    foreach (Import.MainItem mainItem in subsection.MainItemsList)
                    {
                        // If main item should be moved, move it
                        if (mainItem.EtapID == fromEtapId)
                            mainItem.EtapID = toEtapId;
                    }
                }
            }
        }
示例#3
0
        /// <summary>
        /// Loads data for selected construction object
        /// </summary>
        /// <param name="obj">Selected Object</param>
        private void OnObjectSelected(ConstructionObject obj)
        {
            LoadData();

            SetButtonsEnability();
        }
 /// <summary>
 /// Reaction on selected object fired from selection user fontrol
 /// </summary>
 /// <param name="obj">Selected object</param>
 private void OnObjectSelected(ConstructionObject obj)
 {
     // No calculation selected, no functionality is enabled
     SetImportedItemsControlsEnability(false);
 }
        /// <summary>
        /// Objects conatins list of selected items. This list has to be updated.
        /// </summary>
        /// <param name="obj"></param>
        private void UpdateBilledItems(ConstructionObject obj)
        {
            if (obj == null)
                return;

            // Browse all calculations ...
            foreach (CostsCalculation calculation in obj.CalculationList)
            {
                // ... its SubSections
                foreach (SubSection subSection in calculation.SubSections)
                {
                    // Find all items checked to bill
                    this.SelectedItems.AddRange(
                        subSection.MainItemsList.FindAll(mainItem => mainItem.IsBeingBilled)
                    );
                }
            }

            // Update data grid
            RefreshDatagrid(
                this.dg_BillingItems,
                this.SelectedItems
            );
        }
        private void OnObjectSelected(ConstructionObject obj)
        {
            DisableDataGrids();

            UpdateBilledItems(obj);
        }