Пример #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
        /// <summary>
        /// button: sava all the changes and close the window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_SF_Submit_Click(object sender, EventArgs e)
        {
            RefSubFamily = textBox_RefSF.Text;
            // NameSubFamily = textBox_NameSF.Text;
            //RefFamily = comboBox_F.SelectedIndex;
            //Console.WriteLine("refFamily-before:" + RefFamily);


            int RefSubFamily_Int = int.Parse(RefSubFamily);

            //FamillyController Familly_Controller = new FamillyController();
            //List<Familly> List_Familly = Familly_Controller.GetAllFamilly();
            //Familly Familly = List_Familly[RefFamily];
            //Console.WriteLine("family id:", Familly.Nom1);
            //Console.WriteLine("family nom:",Familly.Nom1);

            SubFamillyController SubFamily_Controller = new SubFamillyController();

            //SubFamilly SubFamilly = SubFamily_Controller.GetSubFamillyByRef(RefSubFamily_Int);


            SubFamily_Controller.UpdateSubFamilly(RefSubFamily_Int, RefFamily, NameSubFamily);
            MessageBox.Show("SubFamily modified successfully ;)", "SubFamily modified", MessageBoxButtons.OK, MessageBoxIcon.Information);

            this.DialogResult = DialogResult.OK;
            this.Dispose();
        }
Пример #3
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);
            }
        }
Пример #4
0
        /// <summary>
        /// get the infomations of the selected item
        /// </summary>
        /// <param name="SelectedSubFamily"></param>
        public void GetSubFamilyToModify(ListViewItem SelectedSubFamily)
        {
            SubFamillyController SubFamController  = new SubFamillyController();
            SubFamilly           SubFamilyToModify = new SubFamilly();

            SubFamilyToModify = SubFamController.GetSubFamillyByRef(int.Parse(SelectedSubFamily.Text));
            //Console.WriteLine("列表中选中的sub id"+SelectedSubFamily.Text);

            this.textBox_RefSF.Text  = SubFamilyToModify.RefSousFamille1.ToString();
            this.textBox_NameSF.Text = SubFamilyToModify.Nom1.ToString();
            this.comboBox_F.Text     = SubFamilyToModify.RefFamille1.Nom1.ToString();
        }
Пример #5
0
        /// <summary>
        /// initialisation of the add subfamily form
        /// </summary>
        private void InitializeForm()
        {
            FamillyController    Familly_Controller     = new FamillyController();
            List <Familly>       List_Familly           = Familly_Controller.GetAllFamilly();
            SubFamillyController Sub_Familly_Controller = new SubFamillyController();

            Text_Box_Reference.Text = (Sub_Familly_Controller.GetMaxSubFamillyId() + 1).ToString();
            foreach (Familly Familly in List_Familly)
            {
                Combo_Box_Famille.Items.Add(Familly.Nom1);
                //Combo_Box_Famille.SelectedIndex = 0;
            }
        }
Пример #6
0
        /// <summary>
        /// item in a menu: delete a subfamily
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SubFamillyController Sub_Familly_Controller = new SubFamillyController();

            if (SelectedSubFamily != null)
            {
                Response Response = Sub_Familly_Controller.DeleteSubFamilly(int.Parse(SelectedSubFamily.Text));
                if (Response.State1)
                {
                    LoadSubFamillies();
                }
                else
                {
                    MessageBox.Show(Response.Message1, "Failed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Пример #7
0
        /// <summary>
        /// add subfamily
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Add_Sous_Famille_Click(object sender, EventArgs e)
        {
            String Reference = Text_Box_Reference.Text;
            String Name      = Text_Box_Name.Text;

            int Familly_Index = Combo_Box_Famille.SelectedIndex;

            if (Familly_Index > -1 && !Reference.Equals("") && !Name.Equals(""))
            {
                try
                {
                    int Reference_Int = int.Parse(Reference);

                    SubFamillyController Sub_Familly_Controller = new SubFamillyController();
                    SubFamilly           Sub_Familly            = Sub_Familly_Controller.GetSubFamillyByRef(Reference_Int);

                    List <Familly> List_Familly      = new FamillyController().GetAllFamilly();
                    int            Reference_Familly = List_Familly[Familly_Index].RefFamille1;


                    if (Sub_Familly == null)
                    {
                        Sub_Familly_Controller.InsertSubFamilly(Reference_Int, Reference_Familly, Name);
                        MessageBox.Show("Sub Familly added successfully ;)", "Sub Familly Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Sub Familly exists already in database", "Error Add Sub Familly", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    this.DialogResult = DialogResult.OK;
                    this.Dispose();
                }
                catch (FormatException e1)
                {
                    MessageBox.Show(e1.Message, "Error Add Sub Familly", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Please fill in all the fields", "Error Add Sub Familly", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #8
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;
            }
        }
Пример #9
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);
            }
        }