Esempio n. 1
0
        /// <summary>
        /// Modify the selected article and save it.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_SubmitModifyArticle_Click(object sender, EventArgs e)
        {
            Reference   = textBox_RefArticle.Text;
            Description = textBox_Description.Text;
            Price       = textBox_PriceHT.Text;
            Quantity    = textBox_Quantity.Text;

            Sub_Familly_Index = comboBox_SubFamily.SelectedIndex;
            Mark_Index        = comboBox_Brand.SelectedIndex;


            float Price_Float  = float.Parse(Price);
            int   Quantity_Int = int.Parse(Quantity);

            SubFamillyController Sub_Familly_Controller = new SubFamillyController();
            List <SubFamilly>    List_Sub_Familly       = Sub_Familly_Controller.GetAllSubFamilly();
            SubFamilly           Sub_Familly            = List_Sub_Familly[Sub_Familly_Index];

            MarkController Mark_Controller = new MarkController();
            List <Mark>    List_Mark       = Mark_Controller.GetAllMark();
            Mark           Mark            = List_Mark[Mark_Index];

            ArticleController Article_Controller = new ArticleController();
            Article           Article            = Article_Controller.GetArticleByRef(Reference);

            Article_Controller.UpdateArticle(Reference, Description, Sub_Familly.RefSousFamille1, Mark.RefMarque1, Price_Float, Quantity_Int);
            MessageBox.Show("Article modified successfully ;)", "Article modified", MessageBoxButtons.OK, MessageBoxIcon.Information);

            this.DialogResult = DialogResult.OK;
            this.Dispose();
            //this.Close();
        }
Esempio n. 2
0
        /// <summary>
        /// Add article listner
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Add_Article_Click(object sender, EventArgs e)
        {
            String Reference   = Text_Box_Reference.Text;
            String Description = Text_Box_Description.Text;
            String Price       = Text_Box_Price.Text;
            String Quantity    = Text_Box_Quantity.Text;

            int Sub_Familly_Index = Combo_Box_Sous_Famille.SelectedIndex;
            int Mark_Index        = Combo_Box_Marque.SelectedIndex;

            if (Mark_Index > -1 && Sub_Familly_Index > -1 && !Reference.Equals("") && !Description.Equals("") && !Price.Equals("") && !Quantity.Equals(""))
            {
                try
                {
                    float Price_Float  = float.Parse(Price);
                    int   Quantity_Int = int.Parse(Quantity);

                    SubFamillyController Sub_Familly_Controller = new SubFamillyController();
                    List <SubFamilly>    List_Sub_Familly       = Sub_Familly_Controller.GetAllSubFamilly();
                    SubFamilly           Sub_Familly            = List_Sub_Familly[Sub_Familly_Index];

                    MarkController Mark_Controller = new MarkController();
                    List <Mark>    List_Mark       = Mark_Controller.GetAllMark();
                    Mark           Mark            = List_Mark[Mark_Index];


                    //Article article = new Article(Reference, Description, Price, Quantity, sousFamille.Ref_Sous_Famille, marque.Ref_Marque);
                    ArticleController Article_Controller = new ArticleController();
                    Article           Article            = Article_Controller.GetArticleByRef(Reference);

                    if (Article == null)
                    {
                        Article_Controller.InsertArticle(Reference, Description, Sub_Familly.RefSousFamille1, Mark.RefMarque1, Price_Float, Quantity_Int);
                        MessageBox.Show("Article added successfully ;)", "Article added", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Article exists already in DataBase", "Error Add Article", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    this.DialogResult = DialogResult.OK;
                    this.Dispose();
                }
                catch (FormatException e1)
                {
                    //Message de l'exception pour notifier l'utilisateur
                    MessageBox.Show(e1.Message, "Error Add Article", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("Please fill in all the fields", "Error Add Article", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// show the details of the selected item in modify window
        /// </summary>
        /// <param name="SelectedArticle">selected item</param>
        public void GetArticleToModify(ListViewItem SelectedArticle)
        {
            //ArticleController ArtController = new ArticleController();
            Article ArticleToModify = new Article();


            ArticleController ArticleController1 = new ArticleController();

            ArticleToModify = ArticleController1.GetArticleByRef(SelectedArticle.Text);

            this.textBox_RefArticle.Text  = ArticleToModify.RefArticle1.ToString();
            this.textBox_Description.Text = ArticleToModify.Description1.ToString();
            this.comboBox_SubFamily.Text  = ArticleToModify.RefSubFamilly1.Nom1.ToString();
            this.comboBox_Brand.Text      = ArticleToModify.RefMark1.Nom1.ToString();
            this.textBox_PriceHT.Text     = ArticleToModify.PriceHT1.ToString();
            this.textBox_Quantity.Text    = ArticleToModify.Quantity1.ToString();
        }