示例#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();
        }
示例#2
0
        public Familly MakeFamilly(int RefFamilly, string Name)
        {
            Familly Familly = new Familly();

            Familly.RefFamille1 = RefFamilly;
            Familly.Nom1        = Name;


            return(Familly);
        }
示例#3
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();
        }
示例#4
0
        /// <summary>
        /// Update familly
        /// </summary>
        /// <param name="Familly">Object Familly</param>
        /// <returns>Number of row</returns>
        public int UpdateFamilly(Familly Familly)
        {
            int           Count         = 0;
            SQLiteCommand InsertCommand = new SQLiteCommand(Connection);

            using (SQLiteTransaction Tran = Connection.BeginTransaction())
            {
                InsertCommand.CommandText = "UPDATE Familles SET Nom = @Nom WHERE RefFamille = @Ref";
                InsertCommand.Parameters.AddRange(new[] {
                    new SQLiteParameter("@Nom", Familly.Nom1),
                    new SQLiteParameter("@Ref", Familly.RefFamille1),
                });
                Count = InsertCommand.ExecuteNonQuery();
                Tran.Commit();
            }
            return(Count);
        }
示例#5
0
        /// <summary>
        /// Select all familly
        /// </summary>
        /// <returns>List of familly</returns>
        public List <Familly> SelectAllFamilly()
        {
            List <Familly> L_Familly = new List <Familly>();

            SQLiteCommand SelectCommand = new SQLiteCommand(Connection);

            using (SQLiteTransaction Tran = Connection.BeginTransaction())
            {
                SelectCommand.CommandText = "SELECT * FROM Familles";
                SQLiteDataReader reader = SelectCommand.ExecuteReader();
                Tran.Commit();
                while (reader.Read())
                {
                    Familly Familly = this.MakeFamilly(int.Parse(reader["RefFamille"].ToString()), reader["Nom"].ToString());
                    L_Familly.Add(Familly);
                }
            }
            return(L_Familly);
        }
示例#6
0
        public int InsertFamilly(Familly Familly)
        {
            int           Count         = 0;
            SQLiteCommand InsertCommand = new SQLiteCommand(Connection);

            using (SQLiteTransaction Tran = Connection.BeginTransaction())
            {
                if (this.SelectFamillyByRef(Familly.RefFamille1) == null)
                {
                    InsertCommand.CommandText = "INSERT INTO Familles VALUES(@RefF,@Nom)";
                    InsertCommand.Parameters.AddRange(new[] {
                        new SQLiteParameter("@RefF", Familly.RefFamille1),
                        new SQLiteParameter("@Nom", Familly.Nom1)
                    });
                    Count = InsertCommand.ExecuteNonQuery();
                    Tran.Commit();
                }
            }
            return(Count);
        }
示例#7
0
        /// <summary>
        /// Insert one familly
        /// </summary>
        /// <param name="RefFamilly">Familly Reference</param>
        /// <param name="Name">Familly Name</param>
        /// <returns>Response Object</returns>
        public Response InsertFamilly(int RefFamilly, string Name)
        {
            Response Response = new Response();

            try
            {
                Familly Familly = this.FamillyDAO.MakeFamilly(RefFamilly, Name);
                int     Count   = 0;
                Count             = FamillyDAO.InsertFamilly(Familly);
                Response.State1   = true;
                Response.Message1 = Count.ToString();
                return(Response);
            }
            catch (Exception E)
            {
                Response.State1   = false;
                Response.Message1 = E.Message;
                return(Response);
            }
        }
示例#8
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);
            }
        }
示例#9
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);
            }
        }
示例#10
0
        public Familly SelectFamillyByRef(int Ref)
        {
            Familly       Familly       = null;
            SQLiteCommand SelectCommand = new SQLiteCommand(Connection);

            using (SQLiteTransaction Tran = Connection.BeginTransaction())
            {
                SelectCommand.CommandText = "SELECT * FROM Familles WHERE RefFamille = @Ref";
                SelectCommand.Parameters.AddRange(new[] {
                    new SQLiteParameter("@Ref", Ref)
                });

                SQLiteDataReader reader = SelectCommand.ExecuteReader();
                Tran.Commit();
                if (reader.HasRows)
                {
                    reader.Read();
                    Familly = this.MakeFamilly(int.Parse(reader["RefFamille"].ToString()), reader["Nom"].ToString());
                }


                return(Familly);
            }
        }
示例#11
0
        /// <summary>
        /// Parse the article to be readable
        /// </summary>
        /// <returns></returns>
        public List <Article> ParseArticle()
        {
            // data structures


            int Mark_Count   = 1;
            int SubFam_Count = 1;
            int Fam_Count    = 1;

            foreach (OriArticle OriArc in this.List_Ori_Ari)
            {
                // set articles
                Article Art = new Article();
                Art.RefArticle1  = OriArc.RefArticle1;
                Art.Description1 = OriArc.Description1;
                Art.PriceHT1     = float.Parse(OriArc.PrixHT1);
                Art.Quantity1    = 1;
                //try catch here

                // set mark
                Mark Mark = new Mark();
                Mark.RefMarque1 = Mark_Count;
                Mark.Nom1       = OriArc.Marque1;
                if (L_Mark.Contains(Mark))
                {
                    int Id = L_Mark.IndexOf(Mark);
                    Mark = L_Mark.ElementAt(Id);
                }
                else
                {
                    Mark_Count++;
                    L_Mark.Add(Mark);
                }
                Art.RefMark1 = Mark;

                // set familly
                Familly Familly = new Familly();
                Familly.Nom1        = OriArc.Famille1;
                Familly.RefFamille1 = Fam_Count;

                if (L_Familly.Contains(Familly))
                {
                    int Id = L_Familly.IndexOf(Familly);
                    Familly = L_Familly.ElementAt(Id);
                }
                else
                {
                    Fam_Count++;
                    L_Familly.Add(Familly);
                }


                // set subfamilly
                SubFamilly SubFamilly = new SubFamilly();
                SubFamilly.Nom1            = OriArc.SousFamille1;
                SubFamilly.RefSousFamille1 = SubFam_Count;
                SubFamilly.RefFamille1     = Familly;
                if (L_SubFamilly.Contains(SubFamilly))
                {
                    int Id = L_SubFamilly.IndexOf(SubFamilly);
                    SubFamilly = L_SubFamilly.ElementAt(Id);
                }
                else
                {
                    SubFam_Count++;
                    L_SubFamilly.Add(SubFamilly);
                }

                Art.RefSubFamilly1 = SubFamilly;

                // add to list
                L_Article.Add(Art);
            }
            return(L_Article);
        }