コード例 #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();
        }
コード例 #2
0
ファイル: AddArticle.cs プロジェクト: ywlqjl/S7_Projet_Net
        /// <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);
            }
        }
コード例 #3
0
        /// <summary>
        /// initialization
        /// </summary>
        private void InitializeForm()
        {
            SubFamillyController Sub_Familly_Controller = new SubFamillyController();
            List <SubFamilly>    List_Sub_Familly       = Sub_Familly_Controller.GetAllSubFamilly();

            foreach (SubFamilly SubFamilly in List_Sub_Familly)
            {
                this.comboBox_SubFamily.Items.Add(SubFamilly.Nom1);
                //Combo_Box_Sous_Famille.SelectedIndex = 0;
            }

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

            foreach (Mark Mark in List_Mark)
            {
                this.comboBox_Brand.Items.Add(Mark.Nom1);
                //Combo_Box_Marque.SelectedIndex = 0;
            }
        }
コード例 #4
0
        /// <summary>
        /// load all the subfamilies
        /// </summary>
        private void LoadSubFamillies()
        {
            this.List_View_Sous_Famille.Items.Clear();

            SubFamillyController Sub_Familly_Controller = new SubFamillyController();
            List <SubFamilly>    List_Sub_Familly       = Sub_Familly_Controller.GetAllSubFamilly();

            foreach (SubFamilly SubFamilly in List_Sub_Familly)
            {
                ListViewItem Item = new ListViewItem(Convert.ToString(SubFamilly.RefSousFamille1));

                ListViewItem.ListViewSubItem Name_Item = new ListViewItem.ListViewSubItem(Item, SubFamilly.Nom1);
                Item.SubItems.Add(Name_Item);

                FamillyController Familly_Controller = new FamillyController();
                Familly           Familly            = Familly_Controller.GetFamillyByRef(SubFamilly.RefFamille1.RefFamille1);

                ListViewItem.ListViewSubItem familly_Item = new ListViewItem.ListViewSubItem(Item, Familly != null ? Familly.Nom1 : "");
                Item.SubItems.Add(familly_Item);

                List_View_Sous_Famille.Items.Add(Item);
            }
        }