public static section getsectionbyname(LinkedList <section> arr, string text)
        {
            section sec = new section();

            for (int i = 0; i < arr.Count; i++)
            {
                if (arr.ElementAt(i).name == text)
                {
                    sec = arr.ElementAt(i);
                    break;
                }
            }
            return(sec);
        }
        public static section getsectionbyid(LinkedList <section> arr, int id)
        {
            section sec = new section();

            for (int i = 0; i < arr.Count; i++)
            {
                if (arr.ElementAt(i).id == id)
                {
                    sec = arr.ElementAt(i);
                    break;
                }
            }
            return(sec);
        }
Beispiel #3
0
        }//edit

        public static LinkedList <Items> filtersection(LinkedList <Items> itemlist, string sectionname)
        {
            LinkedList <Items> returnsection = new LinkedList <Items>();

            for (int i = 0; i < itemlist.Count; i++)
            {
                section sec = new section();
                sec = section.getsectionbyname(Variables.sectionlist, sectionname);
                if (sec.id == itemlist.ElementAt(i).section_id)
                {
                    returnsection.AddLast(itemlist.ElementAt(i));
                }
            }
            return(returnsection);
        }
        public bool addsection(LinkedList <section> arr, section newsection)
        {
            for (int i = 0; i < arr.Count; i++)
            {
                if (arr.ElementAt(i).name == newsection.name)
                {
                    MessageBox.Show("enter another name.");
                    return(false);
                }
            }
            newsection.id = arr.ElementAt(arr.Count - 1).id + 1;
            arr.AddLast(newsection);

            return(true);
        }
        private void Colorlist_SelectedValueChanged(object sender, EventArgs e)
        {
            itemsnow = Items.itemsearch(Variables.brandlist, searchBox.Text);
            itemsnow = Items.filtercolor(itemsnow, Colorlist.Text);
            flowLayoutPanel3.Controls.Clear();


            for (int i = 0; i < itemsnow.Count; i++)
            {
                Item_UC itemui = new Item_UC();

                itemui.item       = itemsnow.ElementAt(i);
                itemui.name.Text  = "Name : " + itemsnow.ElementAt(i).name;
                itemui.price.Text = "Price : " + itemsnow.ElementAt(i).price;
                itemui.color.Text = "Color : " + itemsnow.ElementAt(i).color;
                // draw hair
                // it.image.ImageLocation = Section.itemlist[i].image;
                if (itemsnow.ElementAt(i).image != null)
                {
                    MemoryStream stream = new MemoryStream(itemsnow.ElementAt(i).image);
                    itemui.image.Image = System.Drawing.Image.FromStream(stream);
                }
                Brand brand = new Brand();
                brand             = Brand.getbrandbyid(Variables.brandlist, itemsnow.ElementAt(i).brand_id);
                itemui.brand.Text = "Brand : " + brand.name;
                if (!Brandlist.Items.Contains(brand.name))
                {
                    Brandlist.Items.Add(Variables.brandlist.ElementAt(i).name);
                }
                section sec = new section();
                sec = section.getsectionbyid(Variables.sectionlist, itemsnow.ElementAt(i).section_id);
                if (!sectionlist.Items.Contains(sec.name))
                {
                    sectionlist.Items.Add(sec.name);
                }
                if (!Colorlist.Items.Contains(itemsnow.ElementAt(i).color))
                {
                    Colorlist.Items.Add(itemsnow.ElementAt(i).color);
                }

                itemui.descripiton.Text = "Description : " + itemsnow.ElementAt(i).description;
                flowLayoutPanel3.Controls.Add(itemui);
            }
        }
Beispiel #6
0
        private void ViewBtn_Click(object sender, EventArgs e)
        {
            //here

            Home hom;

            hom = (Home)this.FindForm();
            hom.filt_panel.Visible = true;
            Form1.home.flowLayoutPanel3.Controls.Clear();
            Form1.home.itemsnow.Clear();
            Form1.home.Colorlist.Items.Clear();
            Form1.home.Brandlist.Items.Clear();
            Form1.home.sectionlist.Items.Clear();
            for (int i = 0; i < brand.itemlist.Count; i++)
            {
                Item_UC it = new Item_UC();
                it.item       = brand.itemlist[i];
                it.name.Text  = "Name : " + brand.itemlist[i].name;
                it.price.Text = "Price : " + brand.itemlist[i].price;
                it.color.Text = "Color : " + brand.itemlist[i].color;
                //draw hair
                // it.image = brand.itemlist[i].image;
                if (brand.itemlist[i].image != null)
                {
                    MemoryStream stream = new MemoryStream(brand.itemlist[i].image);
                    it.image.Image = System.Drawing.Image.FromStream(stream);
                }
                it.brand.Text       = "Brand : " + brand.name;
                it.descripiton.Text = "Description : " + brand.itemlist[i].description;
                Form1.home.itemsnow.AddLast(brand.itemlist[i]);
                Form1.home.flowLayoutPanel3.Controls.Add(it);
                if (!Form1.home.Colorlist.Items.Contains(brand.itemlist[i].color))
                {
                    Form1.home.Colorlist.Items.Add(brand.itemlist[i].color);
                }
                section sec = section.getsectionbyid(Variables.sectionlist, brand.itemlist[i].section_id);
                if (!Form1.home.sectionlist.Items.Contains(sec.name))
                {
                    Form1.home.sectionlist.Items.Add(sec.name);
                }
            }
            Form1.home.Brandlist.Items.Add(brand.name);
        }
        public bool editsection(LinkedList <section> arr, string oldname, section editsection)
        {
            int index = new int();//??

            for (int i = 0; i < arr.Count; i++)
            {
                if (arr.ElementAt(i).name == oldname)//&& arr.ElementAt(i).id != editbrand.id)
                {
                    index = i;
                    break;
                }
            }


            arr.ElementAt(index).image       = editsection.image;
            arr.ElementAt(index).name        = editsection.name;
            arr.ElementAt(index).description = editsection.description;
            MessageBox.Show("Edited");
            return(true);
        }
        private void searchBox_TextChanged(object sender, EventArgs e)
        {
            if (searchBox.Text == "")
            {
                bunifuFlatButton2.Click += new EventHandler(bunifuFlatButton2_Click);
            }
            else
            {
                flowLayoutPanel3.Controls.Clear();
                Brandlist.Items.Clear();
                sectionlist.Items.Clear();
                Colorlist.Items.Clear();
                itemsnow.Clear();
                sortlist.Text = "";
                if (comboBox1.Text == "Item")
                {
                    filt_panel.Visible = true;
                    flowLayoutPanel3.Controls.Clear();

                    itemsnow = Items.itemsearch(Variables.brandlist, searchBox.Text);
                    for (int i = 0; i < itemsnow.Count; i++)
                    {
                        Item_UC itemui = new Item_UC();

                        itemui.item       = itemsnow.ElementAt(i);
                        itemui.name.Text  = "Name : " + itemsnow.ElementAt(i).name;
                        itemui.price.Text = "Price : " + itemsnow.ElementAt(i).price;
                        itemui.color.Text = "Color : " + itemsnow.ElementAt(i).color;
                        // draw hair
                        // it.image.ImageLocation = Section.itemlist[i].image;
                        if (itemsnow.ElementAt(i).image != null)
                        {
                            MemoryStream stream = new MemoryStream(itemsnow.ElementAt(i).image);
                            itemui.image.Image = System.Drawing.Image.FromStream(stream);
                        }
                        Brand brand = new Brand();
                        brand             = Brand.getbrandbyid(Variables.brandlist, itemsnow.ElementAt(i).brand_id);
                        itemui.brand.Text = "Brand : " + brand.name;
                        if (!Brandlist.Items.Contains(brand.name))
                        {
                            Brandlist.Items.Add(brand.name);
                        }
                        section sec = new section();
                        sec = section.getsectionbyid(Variables.sectionlist, itemsnow.ElementAt(i).section_id);
                        if (!sectionlist.Items.Contains(sec.name))
                        {
                            sectionlist.Items.Add(sec.name);
                        }
                        if (!Colorlist.Items.Contains(itemsnow.ElementAt(i).color))
                        {
                            Colorlist.Items.Add(itemsnow.ElementAt(i).color);
                        }

                        itemui.descripiton.Text = "Description : " + itemsnow.ElementAt(i).description;
                        flowLayoutPanel3.Controls.Add(itemui);
                    }
                }
                else if (comboBox1.Text == "Brand")
                {
                    filt_panel.Visible = true;
                    flowLayoutPanel3.Controls.Clear();

                    brandsnow = Brand.brandsearch(Variables.brandlist, searchBox.Text);
                    for (int i = 0; i < brandsnow.Count; i++)
                    {
                        viewbrandsection newbrand = new viewbrandsection();
                        newbrand.brand = brandsnow.ElementAt(i);
                        if (brandsnow.ElementAt(i).image != null)
                        {
                            MemoryStream stream = new MemoryStream(brandsnow.ElementAt(i).image);
                            newbrand.image.Image = System.Drawing.Image.FromStream(stream);
                        }
                        newbrand.name.Text        = "Name : " + brandsnow.ElementAt(i).name;
                        newbrand.phone.Text       = "Phone : " + brandsnow.ElementAt(i).phone;
                        newbrand.mail.Text        = "Email : " + brandsnow.ElementAt(i).mail;
                        newbrand.description.Text = "Description : " + brandsnow.ElementAt(i).category;
                        newbrand.country.Text     = "Country : " + brandsnow.ElementAt(i).country;
                        //newbrand.image.ImageLocation =@"C:\\Users\\nader\\Desktop\\nader.jpg";
                        flowLayoutPanel3.Controls.Add(newbrand);
                    }
                }
                else if (comboBox1.Text == "Section")
                {
                    filt_panel.Visible = true;
                    flowLayoutPanel3.Controls.Clear();
                    sectionsnow = section.searchsection(Variables.sectionlist, searchBox.Text);
                    for (int i = 0; i < sectionsnow.Count; i++)
                    {
                        viewsection newsection = new viewsection();
                        newsection.Section          = sectionsnow.ElementAt(i);
                        newsection.name.Text        = "Name : " + sectionsnow.ElementAt(i).name;
                        newsection.description.Text = "Description : " + sectionsnow.ElementAt(i).description;
                        if (Variables.sectionlist.ElementAt(i).image != null)
                        {
                            MemoryStream stream = new MemoryStream(sectionsnow.ElementAt(i).image);
                            newsection.image.Image = System.Drawing.Image.FromStream(stream);
                        }
                        flowLayoutPanel3.Controls.Add(newsection);
                    }
                }
            }
        }