Esempio n. 1
0
        /// <summary>
        /// Get the informations of the selected item
        /// </summary>
        /// <param name="SelectedFamily"></param>
        public void GetFamilyToModify(ListViewItem SelectedFamily)
        {
            FamillyController FamController  = new FamillyController();
            Familly           FamilyToModify = new Familly();

            FamilyToModify = FamController.GetFamillyByRef(Convert.ToInt32(SelectedFamily.Text));
            this.txtBox_ReferenceF.Text = FamilyToModify.RefFamille1.ToString();
            this.txtBox_NameF.Text      = FamilyToModify.Nom1.ToString();
        }
Esempio n. 2
0
        /// <summary>
        /// Subimit the modification of Family
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_MF_Submit_Click(object sender, EventArgs e)
        {
            RefFamily  = txtBox_ReferenceF.Text;
            NameFamily = txtBox_NameF.Text;

            int RefFamily_Int = int.Parse(RefFamily);

            FamillyController Family_Controller = new FamillyController();
            Familly           Family            = Family_Controller.GetFamillyByRef(RefFamily_Int);

            Family_Controller.UpdateFamilly(RefFamily_Int, NameFamily);
            MessageBox.Show("Family modified successfully ;)", "Family modified", MessageBoxButtons.OK, MessageBoxIcon.Information);

            this.DialogResult = DialogResult.OK;
            this.Dispose();
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// add family button listner
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Add_Famille_Click(object sender, EventArgs e)
        {
            FamillyController Familly_Controller = new FamillyController();

            String Reference = Text_Box_Reference.Text;
            String Name      = Text_Box_Name.Text;

            if (!Reference.Equals("") && !Name.Equals(""))
            {
                try
                {
                    int     Reference_Int = int.Parse(Reference);
                    Familly Familly       = Familly_Controller.GetFamillyByRef(Reference_Int);
                    if (Familly == null)
                    {
                        Familly_Controller.InsertFamilly(Reference_Int, Name);
                        MessageBox.Show("Familly added successfully ;) ", "Added Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("This reference already exists in DataBase", "Error Add Familly", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    this.DialogResult = DialogResult.OK;
                    this.Dispose();
                }
                catch (FormatException e2)
                {
                    MessageBox.Show(e2.Message, "Error add familly ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Please fill in all fields", "Error Add Familly ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }