public ProjProdAssign_View(Form parentView, int projectID)
 {
     this.parentView = parentView;
     ProjectId = projectID;
     this.projProdCont = new ProjectProductController();
     InitializeComponent();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectExporter"/> class.
        /// </summary>
        /// <param name="projectIdToExport">The project identifier to export.</param>
        /// <param name="exportDirectoryPath">The export file path.</param>
        /// Erstellt von Joshua Frey, am 13.01.2016
        public ProjectExporter(int projectIdToExport, string exportDirectoryPath)
        {
            // initialize db controller
            ExportProjectController = new ProjectController();
            ExportCriterionController = new CriterionController();
            ExportProductController = new ProductController();
            ExportProjectCriterionController = new ProjectCriterionController();
            ExportProjectProductController = new ProjectProductController();
            ExportFulfillmentController = new FulfillmentController();

            this.ExportFilePaths = new List<string>();

            ProjectId = projectIdToExport;
            ProjectName = ExportProjectController.GetProjectById(projectIdToExport).Name;
            Timestamp = CommonMethods.GetTimestamp();

            ExportFilePath = exportDirectoryPath;

            FileBaseName = String.Format(@"{0}\{1}_Project_{2}", ExportFilePath, Timestamp, ProjectName);

            string logFilePath = this.FileBaseName + ".log";
            this.ExportFilePaths.Add(logFilePath);

            // Create Logfile
            this.ArchiveLogWriter = new LogWriter(logFilePath, "Archivierungslog");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectImporter"/> class.
        /// </summary>
        /// <param name="archiveFilePath">The archive file path.</param>
        /// Erstellt von Joshua Frey, am 13.01.2016
        public ProjectImporter(string archiveFilePath)
        {
            // initialize db controller
            ImportProjectController = new ProjectController();
            ImportCriterionController = new CriterionController();
            ImportProductController = new ProductController();
            ImportProjectCriterionController = new ProjectCriterionController();
            ImportProjectProductController = new ProjectProductController();
            ImportFulfillmentController = new FulfillmentController();
            this.ZipArchiveFilePath = archiveFilePath;

            this.ImportFilesDirectory = CreateImportDirectory();

            // Create Logfile
            string logFilePath = this.ImportFilesDirectory + @"\Import.log";
            this.ImportLogWriter = new LogWriter(logFilePath, "Import Log");
        }
        /// <summary>
        /// Allocates the criterion.
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// <param name="projCrit">The proj crit.</param>
        /// <returns>
        /// bool if insertions in projectCriterion table and fulfillment table were successful
        /// </returns>
        /// Erstellt von Joshua Frey, am 04.01.2016
        /// <exception cref="NWATException"></exception>
        private bool AllocateCriterion(int projectId, ProjectCriterion projCrit)
        {
            bool insertionProjectCritionSuccessful = true;
            bool insertionFulfillmentSuccessful    = true;

            int projCritId = projCrit.Criterion_Id;

            if (projCritId != 0 && projCrit.Project_Id != 0)
            {
                insertionProjectCritionSuccessful = InsertProjectCriterionIntoDb(projCrit);

                // get all project products for insertion to fulfillment table
                List <ProjectProduct> allProjectProducts;
                using (ProjectProductController projProdCont = new ProjectProductController())
                {
                    allProjectProducts = projProdCont.GetAllProjectProductsForOneProject(projectId);
                }

                // insert criterions into fulfillment table for each product
                using (FulfillmentController fulfillContr = new FulfillmentController())
                {
                    foreach (ProjectProduct projProd in allProjectProducts)
                    {
                        int productId = projProd.Product_Id;

                        // new fulfillment which will be inserted into fulfillment table.
                        // default values for Fulfilled and Comment (false and null)
                        Fulfillment newFulfillment = new Fulfillment()
                        {
                            Project_Id   = projectId,
                            Product_Id   = productId,
                            Criterion_Id = projCritId,
                            Fulfilled    = false,
                            Comment      = null
                        };

                        if (!fulfillContr.InsertFullfillmentInDb(newFulfillment))
                        {
                            insertionFulfillmentSuccessful = false;
                            throw (new NWATException(CommonMethods.MessageInsertionToFulFillmentTableFailed(productId, projCritId)));
                        }
                    }
                }
            }
            return(insertionFulfillmentSuccessful && insertionProjectCritionSuccessful);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectImporter"/> class.
        /// </summary>
        /// <param name="archiveFilePath">The archive file path.</param>
        /// Erstellt von Joshua Frey, am 13.01.2016
        public ProjectImporter(string archiveFilePath)
        {
            // initialize db controller
            ImportProjectController          = new ProjectController();
            ImportCriterionController        = new CriterionController();
            ImportProductController          = new ProductController();
            ImportProjectCriterionController = new ProjectCriterionController();
            ImportProjectProductController   = new ProjectProductController();
            ImportFulfillmentController      = new FulfillmentController();
            this.ZipArchiveFilePath          = archiveFilePath;

            this.ImportFilesDirectory = CreateImportDirectory();

            // Create Logfile
            string logFilePath = this.ImportFilesDirectory + @"\Import.log";

            this.ImportLogWriter = new LogWriter(logFilePath, "Import Log");
        }
        /// <summary>
        /// Allocates the criterion.
        /// </summary>
        /// <param name="projectId">The project identifier.</param>
        /// <param name="projCrit">The proj crit.</param>
        /// <returns>
        /// bool if insertions in projectCriterion table and fulfillment table were successful
        /// </returns>
        /// Erstellt von Joshua Frey, am 04.01.2016
        /// <exception cref="NWATException"></exception>
        private bool AllocateCriterion(int projectId, ProjectCriterion projCrit)
        {
            bool insertionProjectCritionSuccessful = true;
            bool insertionFulfillmentSuccessful = true;

            int projCritId = projCrit.Criterion_Id;
            if (projCritId != 0 && projCrit.Project_Id != 0)
            {
                insertionProjectCritionSuccessful = InsertProjectCriterionIntoDb(projCrit);

                // get all project products for insertion to fulfillment table
                List<ProjectProduct> allProjectProducts;
                using (ProjectProductController projProdCont = new ProjectProductController())
                {
                    allProjectProducts = projProdCont.GetAllProjectProductsForOneProject(projectId);
                }

                // insert criterions into fulfillment table for each product
                using (FulfillmentController fulfillContr = new FulfillmentController())
                {
                    foreach (ProjectProduct projProd in allProjectProducts)
                    {
                        int productId = projProd.Product_Id;

                        // new fulfillment which will be inserted into fulfillment table.
                        // default values for Fulfilled and Comment (false and null)
                        Fulfillment newFulfillment = new Fulfillment()
                        {
                            Project_Id = projectId,
                            Product_Id = productId,
                            Criterion_Id = projCritId,
                            Fulfilled = false,
                            Comment = null
                        };

                        if (!fulfillContr.InsertFullfillmentInDb(newFulfillment))
                        {
                            insertionFulfillmentSuccessful = false;
                            throw (new NWATException(CommonMethods.MessageInsertionToFulFillmentTableFailed(productId, projCritId)));
                        }
                    }
                }
            }
            return insertionFulfillmentSuccessful && insertionProjectCritionSuccessful;
        }
Exemplo n.º 7
0
        //Methode um das Grundgerüst der Tabellen zu erstellen
        private PdfPTable GetNewProductTable(List<AnalysedProduct> productsForThisTable, int firstProdId, int tableNumber)
        {
            ProjectProductController projprodContr = new ProjectProductController();
            int numberOfallProductsForThisProject = projprodContr.GetAllProjectProductsForOneProject(this.Project.Project_Id).Count;

            int numOfProdsInThisTable = productsForThisTable.Count;

            //Überschrift und nötige Formatierung setzen (Schriftart, Fett Druck, Schriftgröße)
            Font arialBold = FontFactory.GetFont("Arial_BOLD", 10, Font.BOLD);
            Font products = FontFactory.GetFont("Arial_BOLD", 7, Font.NORMAL);
            //Erstellen einer Pdf Tabelle in der die Daten aus der Datenbank ausgegeben werden

            //Erstellen der PdfTable
            PdfPTable CritTable = new PdfPTable(numOfProdsInThisTable + 4);

            //int der die Anzahl der festen Spalten und die variable Anzahl der Produkte enthält
            int numberOfCells = numOfProdsInThisTable + 4;

            // Je nach Anzahl der Produkte in der Datenbank wir die relative Spaltenbreite gesetzt
            if (numberOfCells == 3) { float[] widths = { 20f, 2f, 2f, }; CritTable.SetWidths(widths); ;}
            if (numberOfCells == 4) { float[] widths = { 20f, 2f, 1f, 3f, }; CritTable.SetWidths(widths); ;}
            if (numberOfCells == 5) { float[] widths = { 20, 2f, 2f, 3f, 3f }; CritTable.SetWidths(widths); ;}
            if (numberOfCells == 6) { float[] widths = { 20, 2f, 2f, 3f, 3f, 3f }; CritTable.SetWidths(widths); ;}
            if (numberOfCells == 7) { float[] widths = { 20f, 2f, 2f, 3f, 3f, 3f, 3f }; CritTable.SetWidths(widths); ;}
            if (numberOfCells == 8) { float[] widths = { 20f, 2f, 2f, 3f, 3f, 3f, 3f, 3f }; CritTable.SetWidths(widths); ;}
            if (numberOfCells == 9) { float[] widths = { 20f, 2f, 2f, 3f, 3f, 3f, 3f, 3f, 3f }; CritTable.SetWidths(widths); ;}

            // Die Grenzen der Tabelle unsichtbar machen
            CritTable.DefaultCell.Border = 1;
            //Anzeigen der ersten Zeilen als Überschrift auf jeder Seite des Dokuments
            CritTable.HeaderRows = 1;
            //Platz zwischen Produktlegende und der Tabelle
            CritTable.SpacingBefore = 20f;

            //if-Abfrage für die, je nach Anzahl der Produkte, korrekte "Überschrift der Tabelle"
            if (numberOfallProductsForThisProject > 5)
            {
                CritTable.AddCell(new Paragraph(String.Format("Nutzwert - Analyse   [{0}. Teil]", tableNumber), arialBold));
            }
            else
            {
                CritTable.AddCell(new Paragraph("Nutzwert - Analyse", arialBold));
            }

            CritTable.AddCell(new Paragraph(" "));                   //Leere Zelle sorgt für Abstand zwischen Header und Erfüllungen
            CritTable.AddCell(new Paragraph("Gew.", products));      //Spaltenüberschriften
            CritTable.AddCell(new Paragraph("Proz.", products));

            foreach (AnalysedProduct analysedProd in productsForThisTable)
            {
                string prodHeader = "Prd." + firstProdId.ToString();
                CritTable.AddCell(new Paragraph(prodHeader, products));
                firstProdId++;
            }

            CritTable.HorizontalAlignment = 0;
            //Totale Breite der "Tabelle"
            CritTable.TotalWidth = 700f;
            CritTable.LockedWidth = true;

            return CritTable;
        }
        /// <summary>
        /// Handles the Load event of the ProjCritProdFulfilment_Form control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        /// Erstellt von Veit Berg, am 27.01.16
        private void ProjCritProdFulfilment_Form_Load(object sender, EventArgs e)
        {
            try{
            formloaded = 1;
            using (ProjectProductController Projverw = new ProjectProductController())
            {
                ProjectProduct projprod = (ProjectProduct)comboBox_ProjCritProdFulf.SelectedItem;
                List<ProjectProduct> ProdList = Projverw.GetAllProjectProductsForOneProject(Project.Project_Id);
                List<Product> productsList = new List<Product>();
                foreach (ProjectProduct projProd in ProdList)
                {
                    productsList.Add(projProd.Product);
                }
                comboBox_ProjCritProdFulf.DataSource = productsList;

                comboBox_ProjCritProdFulf.DisplayMember = "Name";
                comboBox_ProjCritProdFulf.SelectedIndex = -1;
            }
                    using (ProjectCriterionController proCriCont = new ProjectCriterionController())
                     {
                         ProjCrits = proCriCont.GetSortedCriterionStructure(Project.Project_Id);
                         using (CriterionController critCon = new CriterionController())
                         {
                             foreach (ProjectCriterion projCrit in ProjCrits)
                             {
                                 var singleCritId = critCon.GetCriterionById(projCrit.Criterion_Id);
                                 projCrit.Name = singleCritId.Name.ToString();
                             }
                         }
                         var CritBindingList = new BindingList<ProjectCriterion>(ProjCrits);
                         var CritSource = new BindingSource(CritBindingList, null);
                         dataGridView_ProjCritProdFulf.DataSource = ProjCrits;
                         dataGridView_ProjCritProdFulf.Columns.Remove("Project_Id");
                         dataGridView_ProjCritProdFulf.Columns.Remove("Weighting_Cardinal");
                         dataGridView_ProjCritProdFulf.Columns.Remove("Weighting_Percentage_Layer");
                         dataGridView_ProjCritProdFulf.Columns.Remove("Weighting_Percentage_Project");
                         dataGridView_ProjCritProdFulf.Columns.Remove("Criterion");
                         dataGridView_ProjCritProdFulf.Columns.Remove("ParentCriterion");
                         dataGridView_ProjCritProdFulf.Columns.Remove("Project");
                         DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();
                         dataGridView_ProjCritProdFulf.Columns.Add(chk);
                         chk.Name = "Erfüllung";
                         DataGridViewTextBoxColumn bem = new DataGridViewTextBoxColumn();
                         bem.Name = "Bemerkung";
                         dataGridView_ProjCritProdFulf.Columns.Add(bem);
                         dataGridView_ProjCritProdFulf.Columns[4].DisplayIndex = 0;
                         dataGridView_ProjCritProdFulf.Columns[3].DisplayIndex = 1;
                         dataGridView_ProjCritProdFulf.Columns[5].DisplayIndex = 2;
                         dataGridView_ProjCritProdFulf.Columns[1].DisplayIndex = 3;
                         dataGridView_ProjCritProdFulf.Columns[0].DisplayIndex = 4;
                         dataGridView_ProjCritProdFulf.Columns[2].DisplayIndex = 5;
                         dataGridView_ProjCritProdFulf.Columns[0].HeaderText = "C-ID";
                         dataGridView_ProjCritProdFulf.Columns[1].HeaderText = "Layer";
                         dataGridView_ProjCritProdFulf.Columns[2].HeaderText = "P-ID";
                         dataGridView_ProjCritProdFulf.Columns[3].HeaderText = "Name";
                         dataGridView_ProjCritProdFulf.Columns[4].Name = "Erfüllung";
                         dataGridView_ProjCritProdFulf.Columns["Name"].ReadOnly = true;
                         dataGridView_ProjCritProdFulf.Columns["Layer_Depth"].ReadOnly = true;
                         dataGridView_ProjCritProdFulf.Columns["Criterion_ID"].ReadOnly = true;
                         dataGridView_ProjCritProdFulf.Columns["Parent_Criterion_Id"].ReadOnly = true;
                        dataGridView_ProjCritProdFulf.Columns[0].Width = 50;
                         dataGridView_ProjCritProdFulf.Columns[1].Width = 50;
                         dataGridView_ProjCritProdFulf.Columns[2].Width = 50;
                         dataGridView_ProjCritProdFulf.Columns[4].Width = 50;
                         dataGridView_ProjCritProdFulf.Columns[3].Width = 150;
                         dataGridView_ProjCritProdFulf.Columns[5].Width = 200;
                         foreach (DataGridViewRow row in dataGridView_ProjCritProdFulf.Rows)
                         {
                             row.Cells["Erfüllung"].Value = false;
                         }

                     }
            }
            catch (Exception i)
            {
                MessageBox.Show(i.Message);
            }
            this.dataGridView_ProjCritProdFulf.CellValidating += new
            DataGridViewCellValidatingEventHandler(dataGridView_ProjCritProdFulf_CellValidating);
            this.FormClosing += new FormClosingEventHandler(ProjCritProdFulfillment_View_FormClosing);
        }
        /// <summary>
        /// Methode um Pdf erstellen etc.
        /// </summary>
        /// 
        /// Erstellt von Adrian Glasnek
        public void CreateFulfillmentForEveryProductPdf()
        {
            ProjectProductController projprodContr = new ProjectProductController();
            this.AllProductsForThisProject = projprodContr.GetAllProjectProductsForOneProject(this.Project.Project_Id);
            List<ProjectCriterion> baseCriterions = this.ProjCritContr.GetBaseProjectCriterions(this.Project.Project_Id); //Get all base Criterions

            SfdFulfillment.Filter = "Pdf File |*.pdf";
            if (SfdFulfillment.ShowDialog() == DialogResult.OK)
            {

                FulfillmentPrinter.SetMargins(50, 200, 50, 125); //Seitenränder definieren
                try //try catch um Fehler abzufangen wenn eine gleichnamige PDF noch geöffnet ist
                {
                    PdfWriter writer = PdfWriter.GetInstance(FulfillmentPrinter, new FileStream(SfdFulfillment.FileName, FileMode.Create));
                    writer.PageEvent = new PdfPageEvents();
                }
                catch (Exception) { throw new Exception("Bitte schließen Sie das geöffnete Pdf!"); }

                //Dokument öffnen um es bearbeiten zu können
                FulfillmentPrinter.Open();

                ////int der die Anzahl der festen Spalten und die variable Anzahl der Produkte enthält
                int countProducts = AllProductsForThisProject.Count();

                int prodCounter = 1;
                //Zählt wieviele Produkte in der Datenbank liegen und schreibt dementsprechend viele Spalten auf das Pdf
                foreach (ProjectProduct Prod in AllProductsForThisProject)
                {
                    //Paragraph um Namen der Produkte mit den Abkürzungen in der Tabelle verbinden zu können
                    //Font für die Ausgabe der Produktlegende
                    Paragraph productName = new Paragraph();
                    Font prodNameFont = FontFactory.GetFont("Arial", 9);
                    productName.Font = prodNameFont;
                    productName.Add("Prd. " + prodCounter.ToString() + "     -     " + Prod.Product.Name+ "\n");
                    FulfillmentPrinter.Add(productName);   //Produktname der vergliechenen Produkte auf dem Dokument anzeige

                    prodCounter++;
                }

                //Bei einer Anzahl von mehr als 5 Produkten innerhalb eines NWA-Projekts werden jeweils weitere Tabellen mit den restlichen Produkten generiert
                List<List<ProjectProduct>> tableLists = GetProdTableLists();
                int firstProdId = 1;
                int tableNumber = 1;
                foreach (List<ProjectProduct> prodsInTable in tableLists)
                {

                    PdfPTable CritTable = GetNewProductTable(prodsInTable, firstProdId, tableNumber);

                    //Methodenaufruf
                    PrintCriterionStructure(ref CritTable, prodsInTable);

                    //Tabelle zum Dokument Adden
                    FulfillmentPrinter.Add(CritTable);

                    // Neue Seite ab jedem neuem "Teil" der tabellarischen Ansicht
                    FulfillmentPrinter.NewPage();

                    firstProdId += this.maxProductsInTable;
                    tableNumber++;
                }

                //Close Dokument - Bearbeitung Beenden
                FulfillmentPrinter.Close();

                //Aufrufen der Hilfsmethode (aus Klasse CriterionStructurePrinter)- Seitenzahl und den Projektnamen auf Pdf
                GetPageNumber(SfdFulfillment, 800);

                //Erfolgsmeldung
                MessageBox.Show("Pdf erfolgreich erstellt!");

                //PDf wird automatisch geöffnet nach der erfolgreichen Speicherung
                System.Diagnostics.Process.Start(SfdFulfillment.FileName);

            }
        }
        /// <summary>
        /// Handles the Load event of the ProjProdAssign_Form control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        /// Erstellt von Veit Berg, am 27.01.16
        private void ProjProdAssign_Form_Load(object sender, EventArgs e)
        {
            try
            {
                using (ProjectProductController proProCont = new ProjectProductController())
                {
                    ProjProds = proProCont.GetAllProjectProductsForOneProject(ProjectId);
                    using (ProductController prodCon = new ProductController())
                    {
                        foreach (ProjectProduct projProd in ProjProds)
                        {
                            var singleProdId = prodCon.GetProductById(projProd.Product_Id);
                            projProd.Name = singleProdId.Name.ToString();
                        }
                    }

                }

                using (ProductController prodCont = new ProductController())
                {
                    AllProds = prodCont.GetAllProductsFromDb();

                    if (ProjProds.Count != 0)
                    {
                        foreach (ProjectProduct projProd in ProjProds)
                        {
                            Product allocatedProd = AllProds.Single(prod => prod.Product_Id == projProd.Product_Id);
                            AllProds.Remove(allocatedProd);
                        }
                    }
                }
                dataGridView_prodAvail.Rows.Clear();
                var ProdBindingList = new BindingList<Product>(AllProds);
                var prodSource = new BindingSource(ProdBindingList, null);
                dataGridView_prodAvail.DataSource = AllProds;
                dataGridView_prodAvail.Columns["Producer"].HeaderText = "Hersteller";
                dataGridView_prodAvail.Columns["Product_Id"].HeaderText = "Produkt ID";
                dataGridView_prodAvail.Columns["Price"].HeaderText = "Preis";

                dataGridView_ProjProd.Rows.Clear();

                var ProjProdBindingList = new BindingList<ProjectProduct>(ProjProds);
                var projProdSource = new BindingSource(ProjProdBindingList, null);
                dataGridView_ProjProd.DataSource = ProjProds;
                dataGridView_ProjProd.Columns.Remove("Project_Id");
                dataGridView_ProjProd.Columns.Remove("Product");
                dataGridView_ProjProd.Columns.Remove("Project");
                dataGridView_ProjProd.Columns["Product_Id"].HeaderText = "Produkt ID";
                dataGridView_ProjProd.Columns[1].Width = 200;
                this.FormClosing += new FormClosingEventHandler(ProjProdAssign_View_FormClosing);
            }
            catch (Exception i)
            {
                MessageBox.Show(i.Message);
            }
        }