Exemplo n.º 1
0
        public AddFamille()
        {
            InitializeComponent();
            FamillyController Familly_Controller = new FamillyController();

            Text_Box_Reference.Text = (Familly_Controller.GetMaxFamillyId() + 1).ToString();
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
        /// <summary>
        /// initialisation
        /// </summary>
        private void InitializeForm()
        {
            FamillyController Familly_Controller = new FamillyController();
            List <Familly>    List_Familly       = Familly_Controller.GetAllFamilly();

            foreach (Familly Familly in List_Familly)
            {
                this.comboBox_F.Items.Add(Familly.Nom1);
            }
        }
Exemplo n.º 4
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;
            }
        }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
0
        /// <summary>
        /// load all the families to the family listiew
        /// </summary>
        private void LoadFamillies()
        {
            this.familleListView.Items.Clear();

            FamillyController Familly_Controller = new FamillyController();
            List <Familly>    List_Familly       = Familly_Controller.GetAllFamilly();

            foreach (Familly Familly in List_Familly)
            {
                ListViewItem refItem = new ListViewItem(Convert.ToString(Familly.RefFamille1));
                ListViewItem.ListViewSubItem nomItem = new ListViewItem.ListViewSubItem(refItem, Familly.Nom1);

                refItem.SubItems.Add(nomItem);
                familleListView.Items.Add(refItem);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// delete a family and update it on time
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            FamillyController Familly_Controller = new FamillyController();

            if (SelectedFamily != null)
            {
                Response Response = Familly_Controller.DeleteFamilly(int.Parse(SelectedFamily.Text));
                if (Response.State1)
                {
                    LoadFamillies();
                }
                else
                {
                    MessageBox.Show(Response.Message1, "Failed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Exemplo n.º 8
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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 10
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);
            }
        }