コード例 #1
0
        /// <summary>
        /// Handles the Click event of the btn_CritCreate control.
        /// Holt die Einträge aus den Textboxen, überprüft diese auf unerlaubte Sonderzeichen und speichert das neue Kriterium ab
        /// </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 btn_CritCreate_Click(object sender, EventArgs e)
        {
            //try{
            String Name = textBox_CritNameCreate.Text;
            String Desc = textBox_CritDescCreate.Text;

            if (CommonMethods.ChreckIfStringIsEmpty(Name) || CommonMethods.ChreckIfStringIsEmpty(Desc))
            {
                MessageBox.Show(CommonMethods.MessageTextIsEmpty());
            }
            else
            {
                if (CommonMethods.CheckIfForbiddenDelimiterInDb(Name) ||
                    CommonMethods.CheckIfForbiddenDelimiterInDb(Desc))
                {
                    MessageBox.Show(CommonMethods.MessageForbiddenDelimiterWasFoundInText());
                }
                else
                {
                    Criterion Crit = new Criterion {
                        Name = Name, Description = Desc
                    };
                    this.critCont.InsertCriterionIntoDb(Crit);
                    this.Close();
                }
            }
            //}
            //catch (Exception x)
            //{
            //    MessageBox.Show(x.Message);
            //}
        }
コード例 #2
0
 /// <summary>
 /// Handles the Click event of the btn_CritUpdate control.
 /// speichert den neuen Namen und Beschreibung in der DB ab sofern keine unerlaubten Zeichen vorkommen
 /// </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 btn_CritUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         using (CriterionController CritUpdClick = new CriterionController())
         {
             Criterion critUpd = CritUpdClick.GetCriterionById(Criterion.Criterion_Id);
             critUpd.Criterion_Id = this.Criterion.Criterion_Id;
             if (CommonMethods.CheckIfForbiddenDelimiterInDb(textBox_CritNameUpdate.Text) ||
                 CommonMethods.CheckIfForbiddenDelimiterInDb(textBox_CritDescUpdate.Text))
             {
                 MessageBox.Show(CommonMethods.MessageForbiddenDelimiterWasFoundInText());
             }
             else
             {
                 critUpd.Name        = textBox_CritNameUpdate.Text;
                 critUpd.Description = textBox_CritDescUpdate.Text;
                 CritUpdClick.UpdateCriterionInDb(critUpd);
                 this.Close();
             }
         }
     }
     catch (Exception x)
     {
         MessageBox.Show(x.Message);
     }
 }
コード例 #3
0
        /// <summary>
        /// Handles the CellValidating event of the dataGridView_ProjCritProdFulf control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DataGridViewCellValidatingEventArgs"/> instance containing the event data.</param>
        /// Erstellt von Veit Berg, am 27.01.16
        private void dataGridView_ProjCritProdFulf_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            try{
                if (e.ColumnIndex == 5)
                {
                    dataGridView_ProjCritProdFulf.Rows[e.RowIndex].ErrorText = "";
                    if (CommonMethods.CheckIfForbiddenDelimiterInDb(e.FormattedValue.ToString()))
                    {
                        MessageBox.Show(CommonMethods.MessageForbiddenDelimiterWasFoundInText());
                    }

                    {
                    }
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
            }
        }
コード例 #4
0
        /// <summary>
        /// Handles the Click event of the btn_ProjUpdate 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 btn_ProjUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                Project projUpd = ProjectCont.GetProjectById(Project.Project_Id);
                projUpd.Project_Id = this.Project.Project_Id;

                bool forbiddenCharInStrings = false;
                if (CommonMethods.CheckIfForbiddenDelimiterInDb(textBox_ProjNameUpdate.Text) ||
                    CommonMethods.CheckIfForbiddenDelimiterInDb(textBox_ProjNameUpdate.Text))
                {
                    MessageBox.Show(CommonMethods.MessageForbiddenDelimiterWasFoundInText());
                }
                else
                {
                    if (CommonMethods.CheckIfSpecialCharsAreInString(textBox_ProjNameUpdate.Text))
                    {
                        forbiddenCharInStrings = true;
                        MessageBox.Show(CommonMethods.MessageForbiddenDelimiterWasFoundInProjectName());
                    }
                    if (CommonMethods.CheckIfForbiddenDelimiterInDb(textBox_ProjNameUpdate.Text))
                    {
                        forbiddenCharInStrings = true;
                        MessageBox.Show(CommonMethods.MessageForbiddenDelimiterWasFoundInText());
                    }
                    if (!forbiddenCharInStrings)
                    {
                        projUpd.Name        = textBox_ProjNameUpdate.Text;
                        projUpd.Description = textBox_ProjDescUpdate.Text;
                        ProjectCont.UpdateProjectInDb(projUpd);

                        this.Close();
                    }
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
            }
        }
コード例 #5
0
 /// <summary>
 /// Handles the Click event of the btn_ProdCreate 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 btn_ProdCreate_Click(object sender, EventArgs e)
 {
     try{
         Product prodCre  = new Product();
         String  Name     = textBox_ProdNameCreate.Text;
         String  Producer = textBox_ProdManuCreate.Text;
         prodCre.Name     = textBox_ProdNameCreate.Text;
         prodCre.Producer = textBox_ProdManuCreate.Text;
         double check;
         if (CommonMethods.ChreckIfStringIsEmpty(Name) || CommonMethods.ChreckIfStringIsEmpty(Producer))
         {
             MessageBox.Show(CommonMethods.MessageTextIsEmpty());
         }
         else
         {
             if (CommonMethods.CheckIfForbiddenDelimiterInDb(prodCre.Name) ||
                 CommonMethods.CheckIfForbiddenDelimiterInDb(prodCre.Producer))
             {
                 MessageBox.Show(CommonMethods.MessageForbiddenDelimiterWasFoundInText());
             }
             else
             {
                 if (Double.TryParse(textBox_ProdPrizeCreate.Text, out check))
                 {
                     prodCre.Price = Convert.ToDouble(textBox_ProdPrizeCreate.Text);
                     prodCont.InsertProductIntoDb(prodCre);
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show("Der Preis darf nur aus Zahlen bestehen!");
                 }
             }
         }
     }
     catch (Exception x)
     {
         MessageBox.Show(x.Message);
     }
 }
コード例 #6
0
        /// <summary>
        /// Handles the Click event of the btn_ProjCreate 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 btn_ProjCreate_Click(object sender, EventArgs e)
        {
            try
            {
                String Name        = textBox_ProjNameCreate.Text;
                String Description = textBox_ProjDescCreate.Text;
                if (CommonMethods.ChreckIfStringIsEmpty(Name) || CommonMethods.ChreckIfStringIsEmpty(Description))
                {
                    MessageBox.Show(CommonMethods.MessageTextIsEmpty());
                }
                else
                {
                    Project projCre = new Project();
                    bool    forbiddenCharInStrings = false;
                    if (CommonMethods.CheckIfSpecialCharsAreInString(textBox_ProjNameCreate.Text))
                    {
                        forbiddenCharInStrings = true;
                        MessageBox.Show(CommonMethods.MessageForbiddenDelimiterWasFoundInProjectName());
                    }
                    if (CommonMethods.CheckIfForbiddenDelimiterInDb(textBox_ProjDescCreate.Text))
                    {
                        forbiddenCharInStrings = true;
                        MessageBox.Show(CommonMethods.MessageForbiddenDelimiterWasFoundInText());
                    }
                    if (!forbiddenCharInStrings)
                    {
                        projCre.Name        = textBox_ProjNameCreate.Text;
                        projCre.Description = textBox_ProjDescCreate.Text;
                        projCont.InsertProjectIntoDb(projCre);

                        this.Close();
                    }
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
            }
        }
コード例 #7
0
        /// <summary>
        /// Handles the Click event of the btn_ProdUpdate 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 btn_ProdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                using (ProductController prodUpdate = new ProductController())
                {
                    Product prodNew = prodUpdate.GetProductById(Product.Product_Id);
                    prodNew.Product_Id = this.Product.Product_Id;
                    prodNew.Name       = textBox_ProdNameUpdate.Text;
                    prodNew.Producer   = textBox_ProdManuUpdate.Text;

                    double check;
                    if (CommonMethods.CheckIfForbiddenDelimiterInDb(prodNew.Name) ||
                        CommonMethods.CheckIfForbiddenDelimiterInDb(prodNew.Producer))
                    {
                        MessageBox.Show(CommonMethods.MessageForbiddenDelimiterWasFoundInText());
                    }
                    else
                    {
                        if (Double.TryParse(textBox_ProdPrizeUpdate.Text, out check))
                        {
                            prodNew.Price = Convert.ToDouble(textBox_ProdPrizeUpdate.Text);
                            prodUpdate.UpdateProductInDb(prodNew);
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("Der Preis darf nur aus Zahlen bestehen!");
                        }
                    }
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
            }
        }
コード例 #8
0
        /// <summary>
        /// Handles the Click event of the btn_ProjCritProdFulfSave 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 btn_ProjCritProdFulfSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBox_ProjCritProdFulf.SelectedIndex != -1)
                {
                    using (FulfillmentController fulCont = new FulfillmentController())
                    {
                        bool saveSucceeded = true;
                        foreach (DataGridViewRow row in dataGridView_ProjCritProdFulf.Rows)
                        {
                            if (CommonMethods.CheckIfForbiddenDelimiterInDb((string)row.Cells["Bemerkung"].Value))
                            {
                                CommonMethods.MessageForbiddenDelimiterWasFoundInText();
                                break;
                            }
                            else
                            {
                                Fulfillment fulFi = new Fulfillment();
                                fulFi.Criterion_Id = (int)row.Cells[0].Value;
                                fulFi.Project_Id   = Project.Project_Id;
                                int     selectedIndex = comboBox_ProjCritProdFulf.SelectedIndex;
                                Product selectedValue = new Product();
                                selectedValue = (Product)comboBox_ProjCritProdFulf.SelectedItem;


                                fulFi.Product_Id = selectedValue.Product_Id;
                                fulFi.Comment    = (string)row.Cells["Bemerkung"].Value;
                                if ((bool)row.Cells["Erfüllung"].Value == true)
                                {
                                    fulFi.Fulfilled = true;
                                }
                                else if ((bool)row.Cells["Erfüllung"].Value == false)
                                {
                                    fulFi.Fulfilled = false;
                                }

                                if (!fulCont.UpdateFulfillmentEntry(fulFi))
                                {
                                    saveSucceeded = false;
                                }
                            }
                        }
                        if (saveSucceeded)
                        {
                            MessageBox.Show("Die Änderungen wurden erfolgreich gespeichert.");
                        }
                        else
                        {
                            MessageBox.Show("Beim Speichern ist ein Fehler unterlaufen.");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Sie müssen ein Produkt auswählen.");
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
            }
        }