Example #1
0
    public void setproduct()
    {
        products  pr   = new products();
        DataTable dt   = new DataTable();
        category  cat  = new category();
        brand     brnd = new brand();

        if (Request.QueryString["cat_id"] == null && Request.QueryString["brand_id"] == null)
        {
            dt = pr.getproduct();
        }
        else if (Request.QueryString["cat_id"] != null && Request.QueryString["brand_id"] == null)
        {
            dt = pr.getproduct_cat(Request.QueryString["cat_id"].ToString());
            list_footer_menu.InnerHtml += "<li><span class=\"icon-chevron-left\"></span></li>";

            string cat_name = cat.getcategory(Request.QueryString["cat_id"].ToString()).Rows[0]["name"].ToString();
            list_footer_menu.InnerHtml += "<li><a href=\"shop.aspx?cat_id=" + Request.QueryString["cat_id"].ToString() + "\">" + cat_name + "</a> </li>";
            tourStep2.InnerHtml         = "";
        }
        else if (Request.QueryString["cat_id"] == null && Request.QueryString["brand_id"] != null)
        {
            dt = pr.getproduct_brand(Request.QueryString["brand_id"].ToString());
            list_footer_menu.InnerHtml += "<li><span class=\"icon-chevron-left\"></span></li>";

            string brand_name = brnd.getbrandbyid(Request.QueryString["brand_id"].ToString()).Rows[0]["name"].ToString();
            list_footer_menu.InnerHtml += "<li><a href=\"shop.aspx?brand_id=" + Request.QueryString["brand_id"].ToString() + "\">" + brand_name + "</a> </li>";
            tourStep3.InnerHtml         = "";
        }


        foreach (DataRow list in dt.Rows)
        {
            DataTable pname     = pr.getonepic(Convert.ToInt32(list["id"]));
            string    catname   = cat.getcategory(list["cat_id"].ToString()).Rows[0]["name"].ToString();
            string    brandname = brnd.getbrandbyid(list["brand_id"].ToString()).Rows[0]["name"].ToString();

            //Response.Write(catname);
            //Response.Write("-");
            //Response.Write(pname["name"].ToString());
            //Response.Write("-");

            HtmlGenericControl div = new HtmlGenericControl("div");
            // div.Attributes.Add("id", "p-item" + list["id"].ToString());
            div.Attributes.Add("class", "span3 filter--cat_id" + list["cat_id"]);
            div.Attributes.Add("data-price", list["price"].ToString());
            div.Attributes.Add("data-popularity", "2");
            div.Attributes.Add("data-size", "xs|s|m|xl");
            div.Attributes.Add("data-color", "pink");
            div.Attributes.Add("data-brand", "brand_id" + list["brand_id"].ToString());
            //div.Attributes.Add("runat", "server");


            HtmlGenericControl divproduct = new HtmlGenericControl("div");
            //div2.Attributes.Add("id", "p-item2-" + list["id"].ToString());
            divproduct.Attributes.Add("class", "product");


            HtmlGenericControl divproductimg = new HtmlGenericControl("div");
            // div3.Attributes.Add("id", "p-item3-" + list["id"].ToString());
            divproductimg.Attributes.Add("class", "product-img");


            HtmlGenericControl divpicture = new HtmlGenericControl("div");
            //div4.Attributes.Add("id", "p-item4-" + list["id"].ToString());
            divpicture.Attributes.Add("class", "picture");


            HtmlGenericControl imgpicture = new HtmlGenericControl("img");
            imgpicture.Attributes.Add("id", "p-img" + list["id"].ToString());
            //img1.Attributes.Add("runat", "server");
            imgpicture.Attributes.Add("width", "540");
            imgpicture.Attributes.Add("height", "374");
            imgpicture.Attributes.Add("alt", "");
            // img1.Attributes.Add("src", (Server.MapPath("~/images/Ppic/").ToString())+list["id"].ToString()+".jpg");
            //imgpicture.Attributes.Add("src", "images/Ppic/" + pname.Rows[0]["name"].ToString() + ".jpg");
            string picname = null;
            if (pname.Rows.Count != 0)
            {
                //imgpicture.Attributes.Add("src", "images/Ppic/" + pname.Rows[0]["name"].ToString() + ".jpg");
                picname = "images/Ppic/" + pname.Rows[0]["name"].ToString() + ".jpg";
            }
            else
            {
                //imgpicture.Attributes.Add("src", "images/Ppic/noimage.jpg");
                picname = "images/Ppic/noimage.jpg";
            }
            imgpicture.Attributes.Add("src", picname);

            divpicture.Controls.Add(imgpicture);

            HtmlGenericControl divimgoverlay = new HtmlGenericControl("div");
            //div5.Attributes.Add("id", "p-div5" + list["id"].ToString());
            divimgoverlay.Attributes.Add("class", "img-overlay");


            //HtmlGenericControl br1 = new HtmlGenericControl("br");
            //div2.Controls.Add(br1);

            HtmlGenericControl aimgoverlay = new HtmlGenericControl("a");
            ///a1.Attributes.Add("id", "a1" + list["id"].ToString());
            aimgoverlay.Attributes.Add("href", "product.aspx?id=" + list["id"].ToString());
            aimgoverlay.Attributes.Add("class", "btn more btn-primary");
            aimgoverlay.InnerText = "توضیحات بیشتر";
            divimgoverlay.Controls.Add(aimgoverlay);

            HtmlAnchor aimgoverlay2 = new HtmlAnchor();
            aimgoverlay2.ID           = "addtocart" + list["id"].ToString();
            aimgoverlay2.HRef         = "#";
            aimgoverlay2.Name         = list["id"].ToString() + "," + list["price"].ToString() + "," + picname + "," + catname + " - " + brandname + " - " + list["name"].ToString();
            aimgoverlay2.ServerClick += new System.EventHandler(addtocart_click);
            aimgoverlay2.Attributes.Add("class", "btn buy btn-danger");
            aimgoverlay2.Attributes.Add("onclick", "addtocart('" + "p-img" + list["id"].ToString() + "');");
            aimgoverlay2.InnerText = "اضافه به سبد خرید";

            UpdatePanel up = new UpdatePanel();
            up.ContentTemplateContainer.Controls.Add(aimgoverlay2);
            divimgoverlay.Controls.Add(up);
            divimgoverlay.Controls.Add(aimgoverlay);
            //divimgoverlay.Controls.Add(aimgoverlay2);
            divpicture.Controls.Add(divimgoverlay);
            divproductimg.Controls.Add(divpicture);
            divproduct.Controls.Add(divproductimg);
            //HtmlGenericControl a2 = new HtmlGenericControl("a");
            //// a2.Attributes.Add("id", "a2" + list["id"].ToString());
            //a2.Attributes.Add("href", "#");
            //a2.Attributes.Add("class", "btn buy btn-danger");
            //
            //div5.Controls.Add(a2);

            //                    <!-- Sub Text -->
            HtmlGenericControl divmaintitle = new HtmlGenericControl("div");
            // div6.Attributes.Add("id", "p-div6" + list["id"].ToString());
            divmaintitle.Attributes.Add("class", "main-titles no-margin");


            HtmlGenericControl h4maintitle = new HtmlGenericControl("h4");
            h4maintitle.Attributes.Add("class", "title");
            h4maintitle.InnerText = catname + " - " + brandname + " - " + list["name"].ToString();
            divmaintitle.Controls.Add(h4maintitle);

            HtmlGenericControl h5maintitle = new HtmlGenericControl("h5");
            h5maintitle.Attributes.Add("class", "no-margin isotope--title");
            h5maintitle.InnerText = String.Format("{0:#,##0}", list["price"]) + " ریال";
            divmaintitle.Controls.Add(h5maintitle);
            divproduct.Controls.Add(divmaintitle);
            div.Controls.Add(divproduct);
            isotopeContainer.Controls.Add(div);
        }
    }
Example #2
0
    public void set_related(string name, string id)
    {
        related.InnerHtml = "";
        products  p       = new products();
        DataTable dt      = new DataTable();
        category  cat     = new category();
        brand     brnd    = new brand();
        string    picname = null;

        // string brandname = null;

        dt = p.getproduct_related_top(name, id);;
        int i = 0;
        HtmlGenericControl divslide = null;
        HtmlGenericControl divrow   = null;

        if (dt.Rows.Count > 0)
        {
            //<div class="arrows">
            //            <a href="#" class="icon-chevron-right" id="featuredItemsRight"></a><a href="#" class="icon-chevron-left"
            //                id="featuredItemsLeft"></a>
            //        </div>


            HtmlGenericControl h = new HtmlGenericControl("h2");
            h.Attributes.Add("class", "title");

            HtmlGenericControl span = new HtmlGenericControl("span");
            span.Attributes.Add("class", "light");
            span.InnerText = "محصولات مرتبط";

            HtmlGenericControl divarrow = new HtmlGenericControl("div");
            divarrow.Attributes.Add("class", "arrows");

            HtmlGenericControl a_right_divarrow = new HtmlGenericControl("a");
            a_right_divarrow.Attributes.Add("class", "icon-chevron-right");
            a_right_divarrow.Attributes.Add("id", "featuredItemsRight");
            a_right_divarrow.Attributes.Add("href", "#");
            a_right_divarrow.ClientIDMode = ClientIDMode.Static;
            divarrow.Controls.Add(a_right_divarrow);

            HtmlGenericControl a_left_divarrow = new HtmlGenericControl("a");
            a_left_divarrow.Attributes.Add("class", "icon-chevron-left");
            a_left_divarrow.Attributes.Add("id", "featuredItemsLeft");
            a_left_divarrow.Attributes.Add("href", "#");
            a_left_divarrow.ClientIDMode = ClientIDMode.Static;
            divarrow.Controls.Add(a_left_divarrow);


            h.Controls.Add(span);

            title.Controls.Add(h);
            title.Controls.Add(divarrow);
        }


        foreach (DataRow dr in dt.Rows)
        {
            if (i % 3 == 0)
            {
                divslide = new HtmlGenericControl("div");
                divslide.Attributes.Add("class", "slide");
                divrow = new HtmlGenericControl("div");
                divrow.Attributes.Add("class", "row");
            }

            string catname   = cat.getcategory(dr["cat_id"].ToString()).Rows[0]["name"].ToString();
            string brandname = brnd.getbrandbyid(dr["brand_id"].ToString()).Rows[0]["name"].ToString();


            DataTable          pname    = p.getonepic(Convert.ToInt32(dr["id"]));
            HtmlGenericControl divspan4 = new HtmlGenericControl("div");
            divspan4.Attributes.Add("class", "span4");

            if (pname.Rows.Count != 0)
            {
                //imgpicture.Attributes.Add("src", "images/Ppic/" + pname.Rows[0]["name"].ToString() + ".jpg");
                picname = "images/Ppic/" + pname.Rows[0]["name"].ToString() + ".jpg";
            }
            else
            {
                //imgpicture.Attributes.Add("src", "images/Ppic/noimage.jpg");
                picname = "images/Ppic/noimage.jpg";
            }

            HtmlGenericControl divproduct = new HtmlGenericControl("div");
            divproduct.Attributes.Add("class", "product");


            HtmlGenericControl divproductimg = new HtmlGenericControl("div");
            divproductimg.Attributes.Add("class", "product-img featured");


            HtmlGenericControl divpicture = new HtmlGenericControl("div");
            divpicture.Attributes.Add("class", "picture");


            HtmlGenericControl imgpicture = new HtmlGenericControl("img");
            imgpicture.Attributes.Add("id", "p-img-f" + dr["id"].ToString());
            //img1.Attributes.Add("runat", "server");
            imgpicture.Attributes.Add("width", "518");
            imgpicture.Attributes.Add("height", "358");
            imgpicture.Attributes.Add("alt", "");

            imgpicture.Attributes.Add("src", picname);
            divpicture.Controls.Add(imgpicture);


            HtmlGenericControl divimgoverlay = new HtmlGenericControl("div");
            divimgoverlay.Attributes.Add("class", "img-overlay");


            HtmlGenericControl aimgoverlay = new HtmlGenericControl("a");
            aimgoverlay.Attributes.Add("href", "product.aspx?id=" + dr["id"].ToString());
            aimgoverlay.Attributes.Add("class", "btn more btn-primary");
            aimgoverlay.InnerText = "توضیحات بیشتر";
            divimgoverlay.Controls.Add(aimgoverlay);



            HtmlAnchor aimgoverlay2 = new HtmlAnchor();
            aimgoverlay2.ID           = "addtocart" + dr["id"].ToString();
            aimgoverlay2.HRef         = "#";
            aimgoverlay2.Name         = dr["id"].ToString() + "," + dr["price"].ToString() + "," + picname + "," + catname + " - " + brandname + " - " + dr["name"].ToString();
            aimgoverlay2.ServerClick += new System.EventHandler(Addcart_Click);
            aimgoverlay2.Attributes.Add("class", "btn buy btn-danger");
            aimgoverlay2.Attributes.Add("onclick", "addtocart('" + "p-img-f" + dr["id"].ToString() + "');");
            aimgoverlay2.InnerText = "اضافه به سبد خرید";

            UpdatePanel up = new UpdatePanel();
            up.ContentTemplateContainer.Controls.Add(aimgoverlay2);
            divimgoverlay.Controls.Add(up);
            divimgoverlay.Controls.Add(aimgoverlay);
            divpicture.Controls.Add(divimgoverlay);
            divproductimg.Controls.Add(divpicture);
            divproduct.Controls.Add(divproductimg);

            HtmlGenericControl divmaintitle = new HtmlGenericControl("div");
            divmaintitle.Attributes.Add("class", "main-titles");


            HtmlGenericControl h4maintitle = new HtmlGenericControl("h4");
            h4maintitle.Attributes.Add("class", "title");
            h4maintitle.InnerText = catname + "-" + brandname + " - " + dr["name"].ToString();
            divmaintitle.Controls.Add(h4maintitle);

            HtmlGenericControl h5maintitle = new HtmlGenericControl("h5");
            h5maintitle.Attributes.Add("class", "no-margin");
            h5maintitle.InnerText = String.Format("{0:#,##0}", dr["price"]) + " ریال"; //int.Parse(dr["price"].ToString()).ToString("N1",CultureInfo.InvariantCulture);
            divmaintitle.Controls.Add(h5maintitle);
            divproduct.Controls.Add(divmaintitle);

            HtmlGenericControl pdesc = new HtmlGenericControl("p");
            pdesc.Attributes.Add("class", "desc");
            pdesc.InnerText = dr["detail"].ToString();
            divproduct.Controls.Add(pdesc);

            divspan4.Controls.Add(divproduct);


            if (i % 3 < 3)
            {
                divrow.Controls.Add(divspan4);
                divslide.Controls.Add(divrow);
            }
            if (i % 3 == 2 || (i + 1) == dt.Rows.Count)
            {
                related.Controls.Add(divslide);
            }
            i++;
        }
    }
    public void order_detail_inner(HtmlGenericControl divcollapse_inner, string order_id, string sendprice, string totalprice)
    {
        orderlist          orlist        = new orderlist();
        category           cat           = new category();
        brand              brnd          = new brand();
        DataTable          product_order = orlist.get_product_order(order_id);
        products           pro           = new products();
        HtmlGenericControl table_order   = new HtmlGenericControl("table");

        table_order.Attributes.Add("class", "table table-items");
        HtmlGenericControl table_head    = new HtmlGenericControl("thead");
        HtmlGenericControl tr_table_head = new HtmlGenericControl("tr");

        HtmlGenericControl th_name_tr_table_head = new HtmlGenericControl("th");

        th_name_tr_table_head.Attributes.Add("colspan", "2");
        th_name_tr_table_head.InnerHtml = "مشخصات محصول";
        tr_table_head.Controls.Add(th_name_tr_table_head);

        HtmlGenericControl th_number_tr_table_head     = new HtmlGenericControl("th");
        HtmlGenericControl div_th_number_tr_table_head = new HtmlGenericControl("div");

        div_th_number_tr_table_head.Attributes.Add("class", "align-center");
        div_th_number_tr_table_head.InnerText = "تعداد";
        th_number_tr_table_head.Controls.Add(div_th_number_tr_table_head);
        tr_table_head.Controls.Add(th_number_tr_table_head);

        HtmlGenericControl th_unitprice_tr_table_head     = new HtmlGenericControl("th");
        HtmlGenericControl div_th_unitprice_tr_table_head = new HtmlGenericControl("div");

        div_th_unitprice_tr_table_head.Attributes.Add("class", "align-right");
        div_th_unitprice_tr_table_head.InnerText = "قیمت واحد";
        th_unitprice_tr_table_head.Controls.Add(div_th_unitprice_tr_table_head);
        tr_table_head.Controls.Add(th_unitprice_tr_table_head);

        HtmlGenericControl th_price_tr_table_head     = new HtmlGenericControl("th");
        HtmlGenericControl div_th_price_tr_table_head = new HtmlGenericControl("div");

        div_th_price_tr_table_head.Attributes.Add("class", "align-right");
        div_th_price_tr_table_head.InnerText = "قیمت کل";
        th_price_tr_table_head.Controls.Add(div_th_price_tr_table_head);
        tr_table_head.Controls.Add(th_price_tr_table_head);


        table_head.Controls.Add(tr_table_head);
        table_order.Controls.Add(table_head);


        HtmlGenericControl table_body_order = new HtmlGenericControl("tbody");
        int total_price = 0;

        foreach (DataRow dr in product_order.Rows)
        {
            string             catname   = cat.getcategory(dr["cat_id"].ToString()).Rows[0]["name"].ToString();
            string             brandname = brnd.getbrandbyid(dr["brand_id"].ToString()).Rows[0]["name"].ToString();
            DataTable          pic       = pro.getonepic(int.Parse(dr["product_id"].ToString()));
            HtmlGenericControl tr        = new HtmlGenericControl("tr");
            HtmlGenericControl tdimg     = new HtmlGenericControl("td");
            tdimg.Attributes.Add("class", "image");
            HtmlGenericControl img = new HtmlGenericControl("img");
            img.Attributes.Add("src", "images/Ppic/" + pic.Rows[0]["name"].ToString() + ".jpg");
            img.Attributes.Add("alt", "");
            img.Attributes.Add("width", "50");
            img.Attributes.Add("height", "50");
            tdimg.Controls.Add(img);
            tr.Controls.Add(tdimg);//finish td img

            HtmlGenericControl tddesc = new HtmlGenericControl("td");
            tddesc.Attributes.Add("class", "desc");
            tddesc.InnerText = catname + "-" + brandname + " - " + dr["name"].ToString();


            tr.Controls.Add(tddesc);//finish td by class desc

            HtmlGenericControl tdqty = new HtmlGenericControl("td");
            tdqty.Attributes.Add("class", "qty");
            HtmlGenericControl divnumber = new HtmlGenericControl("div");
            divnumber.Attributes.Add("class", "numbered");
            divnumber.Controls.Add(new LiteralControl("&nbsp;"));
            divnumber.Controls.Add(new LiteralControl("&nbsp;"));
            divnumber.Controls.Add(new LiteralControl("&nbsp;"));
            divnumber.Controls.Add(new LiteralControl("&nbsp;"));
            divnumber.Controls.Add(new LiteralControl("&nbsp;"));
            divnumber.Controls.Add(new LiteralControl("&nbsp;"));
            divnumber.Controls.Add(new LiteralControl("&nbsp;"));
            divnumber.Controls.Add(new LiteralControl("&nbsp;"));
            divnumber.Controls.Add(new LiteralControl("&nbsp;"));
            divnumber.Controls.Add(new LiteralControl("&nbsp;"));
            //HtmlInputText input = new HtmlInputText();
            HtmlGenericControl input = new HtmlGenericControl("input");
            input.Attributes.Add("name", "input_number" + dr["id"].ToString());
            input.Attributes.Add("class", "tiny-size");
            input.Attributes.Add("value", dr["count"].ToString());
            input.Attributes.Add("type", "text");
            input.Attributes.Add("readonly", "readonly");
            input.Attributes.Add("id", "input_number" + dr["id"].ToString());
            divnumber.Controls.Add(input); //finish input
            tdqty.Controls.Add(divnumber);
            tr.Controls.Add(tdqty);        //finish td by class qty

            HtmlGenericControl td_unit_price = new HtmlGenericControl("td");
            td_unit_price.Attributes.Add("class", "price");
            td_unit_price.InnerText = dr["price"].ToString() + "  ریال  ";
            tr.Controls.Add(td_unit_price);//finish td price

            HtmlGenericControl tdprice = new HtmlGenericControl("td");
            tdprice.Attributes.Add("class", "price");
            tdprice.InnerText = ((Int32)dr["price"] * (Int16)dr["count"]).ToString() + "  ریال  ";
            tr.Controls.Add(tdprice);//finish td price
            table_body_order.Controls.Add(tr);
            total_price += (Int32)dr["price"] * (Int16)dr["count"];
        }


        HtmlGenericControl tr_send_price = new HtmlGenericControl("tr");
        HtmlGenericControl td_space      = new HtmlGenericControl("td");

        td_space.Attributes.Add("colspan", "3");
        td_space.Attributes.Add("rowspan", "3");
        td_space.Controls.Add(new LiteralControl("&nbsp;"));
        tr_send_price.Controls.Add(td_space);

        HtmlGenericControl td_stronger_lable = new HtmlGenericControl("td");

        td_stronger_lable.Attributes.Add("class", "stronger");
        td_stronger_lable.InnerText = "هزينه ارسال :";
        tr_send_price.Controls.Add(td_stronger_lable);


        HtmlGenericControl td_stronger_price = new HtmlGenericControl("td");

        td_stronger_price.Attributes.Add("class", "stronger");
        HtmlGenericControl div_td_stronger_price = new HtmlGenericControl("div");

        div_td_stronger_price.Attributes.Add("class", "align-right");
        div_td_stronger_price.InnerText = sendprice + " ریال";
        td_stronger_price.Controls.Add(div_td_stronger_price);
        tr_send_price.Controls.Add(td_stronger_price);
        table_body_order.Controls.Add(tr_send_price);

        HtmlGenericControl tr_total_price = new HtmlGenericControl("tr");
        HtmlGenericControl td_stronger_lable_totalprice = new HtmlGenericControl("td");

        td_stronger_lable_totalprice.Attributes.Add("class", "stronger");
        td_stronger_lable_totalprice.InnerText = "جمع کل :";
        tr_total_price.Controls.Add(td_stronger_lable_totalprice);


        HtmlGenericControl td_stronger_totalprice = new HtmlGenericControl("td");

        td_stronger_totalprice.Attributes.Add("class", "stronger");
        HtmlGenericControl div_td_stronger_totalprice = new HtmlGenericControl("div");

        div_td_stronger_totalprice.Attributes.Add("class", "size-16 align-right");
        div_td_stronger_totalprice.InnerText = total_price + " ریال";
        td_stronger_totalprice.Controls.Add(div_td_stronger_totalprice);
        tr_total_price.Controls.Add(td_stronger_totalprice);
        table_body_order.Controls.Add(tr_total_price);


        table_order.Controls.Add(table_body_order);
        divcollapse_inner.Controls.Add(table_order);
    }
Example #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string    id = Request.QueryString["id"];
        int       i  = 0;
        DataTable dt = new DataTable();

        if (id != null)
        {
            category cat  = new category();
            brand    brnd = new brand();
            products pro  = new products();
            dt = pro.getproductbyid(Convert.ToInt16(id));
            string pro_name = dt.Rows[0]["name"].ToString();


            string catname   = cat.getcategory(dt.Rows[0]["cat_id"].ToString()).Rows[0]["name"].ToString();
            string brandname = brnd.getbrandbyid(dt.Rows[0]["brand_id"].ToString()).Rows[0]["name"].ToString();


            DataTable pname   = pro.getpic(Convert.ToInt32(id));
            string    picname = "";

            if (pname.Rows.Count != 0)
            {
                picname = ("images/Ppic/" + pname.Rows[0]["name"].ToString() + ".jpg");

                HtmlGenericControl li_main = new HtmlGenericControl("li");
                HtmlAnchor         a       = new HtmlAnchor();
                a.Attributes.Add("href", "index.aspx");
                a.InnerText = "صفحه اصلی";
                li_main.Controls.Add(a);
                adres.Controls.Add(li_main);

                HtmlGenericControl li_shop_sp = new HtmlGenericControl("li");
                HtmlGenericControl a1_sp      = new HtmlGenericControl("span");
                a1_sp.Attributes.Add("class", "icon-chevron-left");
                a1_sp.InnerHtml = "&nbsp;";
                li_shop_sp.Controls.Add(a1_sp);
                adres.Controls.Add(li_shop_sp);



                HtmlGenericControl li_shop = new HtmlGenericControl("li");
                HtmlAnchor         a2      = new HtmlAnchor();
                a2.Attributes.Add("href", "shop.aspx");
                a2.InnerText = "فروشگاه";
                li_shop.Controls.Add(a2);
                adres.Controls.Add(li_shop);


                HtmlGenericControl li_spliter2 = new HtmlGenericControl("li");
                HtmlGenericControl a_sp2       = new HtmlGenericControl("span");
                a_sp2.Attributes.Add("class", "icon-chevron-left");
                a_sp2.InnerHtml = "&nbsp;";
                li_spliter2.Controls.Add(a_sp2);
                adres.Controls.Add(li_spliter2);


                HtmlGenericControl li_brand = new HtmlGenericControl("li");
                HtmlAnchor         a4       = new HtmlAnchor();
                a4.Attributes.Add("href", "shop.aspx?brand_id=" + dt.Rows[0]["brand_id"].ToString());
                a4.InnerText = brandname;
                li_brand.Controls.Add(a4);
                adres.Controls.Add(li_brand);



                HtmlGenericControl li_spliter1 = new HtmlGenericControl("li");
                HtmlGenericControl a_sp        = new HtmlGenericControl("span");
                a_sp.Attributes.Add("class", "icon-chevron-left");
                a_sp.InnerHtml = "&nbsp;";
                li_spliter1.Controls.Add(a_sp);
                adres.Controls.Add(li_spliter1);



                HtmlGenericControl li_cat = new HtmlGenericControl("li");
                HtmlAnchor         a3     = new HtmlAnchor();
                a3.Attributes.Add("href", "shop.aspx?cat_id=" + dt.Rows[0]["cat_id"].ToString());
                a3.InnerText = catname;
                li_cat.Controls.Add(a3);
                adres.Controls.Add(li_cat);


                /*
                 *        <li><span class="icon-chevron-left"></span></li>
                 *        <li><a href="shop.aspx">فروشگاه</a> </li>
                 *        <li><span class="icon-chevron-left"></span></li>
                 *
                 */



                //--------------------
                foreach (DataRow list in pname.Rows)
                {
                    HtmlGenericControl divimg = new HtmlGenericControl("div");
                    if (i == 0)
                    {
                        divimg.Attributes.Add("class", "thumb active");
                    }
                    else
                    {
                        divimg.Attributes.Add("class", "thumb");
                    }
                    imgroot.Controls.Add(divimg);
                    HtmlGenericControl an = new HtmlGenericControl("a");
                    an.Attributes.Add("href", "#MainContent_mainPreviewImg");
                    an.Attributes.Add("alt", "");
                    divimg.Controls.Add(an);
                    HtmlGenericControl pimg = new HtmlGenericControl("img");
                    pimg.Attributes.Add("alt", "");
                    pimg.Attributes.Add("width", "940");
                    pimg.Attributes.Add("height", "940");
                    pimg.Attributes.Add("src", "images/Ppic/" + list["name"].ToString() + ".jpg");
                    an.Controls.Add(pimg);
                    i++;
                }
            }
            //--------------------
            else
            {
                picname = ("images/Ppic/" + "noimage" + ".jpg");
                HtmlGenericControl divimg = new HtmlGenericControl("div");
                divimg.Attributes.Add("class", "thumb active");
                imgroot.Controls.Add(divimg);
                HtmlGenericControl an = new HtmlGenericControl("a");
                an.Attributes.Add("href", "#MainContent_mainPreviewImg");
                an.Attributes.Add("alt", "");
                divimg.Controls.Add(an);
                HtmlGenericControl pimg = new HtmlGenericControl("img");
                pimg.Attributes.Add("alt", "");
                pimg.Attributes.Add("width", "940");
                pimg.Attributes.Add("height", "940");
                pimg.Attributes.Add("src", picname);
                an.Controls.Add(pimg);
            }


            mainPreviewImg.Src = (picname);

            product_detail.InnerText = dt.Rows[0]["detail"].ToString();
            product_price.InnerText  = string.Format("{0:#,##0}", dt.Rows[0]["price"]) + " ریال";
            product_name.InnerText   = catname + " " + brandname + " " + dt.Rows[0]["name"].ToString();

            HtmlGenericControl span_status = new HtmlGenericControl("span_status");


            if ((Int16.Parse(dt.Rows[0]["movjodi"].ToString())) >= 5)
            {
                span_status.Attributes.Add("class", "btn btn-success");
                span_status.InnerText = "موجود";
            }
            else if ((Int16.Parse(dt.Rows[0]["movjodi"].ToString())) >= 1)
            {
                span_status.Attributes.Add("class", "btn btn-warning");
                span_status.InnerText = "تماس بگیرید";
            }
            else
            {
                span_status.Attributes.Add("class", "btn btn-danger");
                span_status.InnerText = "اتمام موجودی";
            }

            product_status.Controls.Add(span_status);



            //foreach (DataRow list in pname.Rows)
            //{
            //    HtmlGenericControl divimg = new HtmlGenericControl("div");
            //    if (i == 0)
            //    {
            //        divimg.Attributes.Add("class", "thumb active");
            //    }
            //    else
            //    {
            //        divimg.Attributes.Add("class", "thumb");
            //    }
            //    imgroot.Controls.Add(divimg);

            //    HtmlGenericControl an = new HtmlGenericControl("a");
            //    an.Attributes.Add("href", "#MainContent_mainPreviewImg");
            //    an.Attributes.Add("alt", "");
            //    divimg.Controls.Add(an);

            //    HtmlGenericControl pimg = new HtmlGenericControl("img");
            //    pimg.Attributes.Add("alt", "");
            //    pimg.Attributes.Add("width", "940");
            //    pimg.Attributes.Add("height", "940");
            //    pimg.Attributes.Add("src", "images/Ppic/" + list["name"].ToString() + ".jpg");
            //    an.Controls.Add(pimg);
            //    i++;

            //}

            HtmlAnchor a_addtocart = new HtmlAnchor();
            a_addtocart.ID           = "addtocart" + dt.Rows[0]["id"].ToString();
            a_addtocart.HRef         = "#";
            a_addtocart.Name         = dt.Rows[0]["id"].ToString() + "," + dt.Rows[0]["price"].ToString() + "," + picname + "," + catname + " - " + brandname + " - " + dt.Rows[0]["name"].ToString();
            a_addtocart.ServerClick += new System.EventHandler(Addcart_Click);
            a_addtocart.Attributes.Add("class", "btn buy btn-danger");
            a_addtocart.Attributes.Add("onclick", "addtocart('MainContent_mainPreviewImg');");
            a_addtocart.InnerText = "اضافه به سبد خرید";
            UpdatePanel up = new UpdatePanel();
            up.ContentTemplateContainer.Controls.Add(a_addtocart);
            addtocart_detail.Controls.Add(up);
            set_related(pro_name, id);
        }
        else
        {
            Response.Redirect("shop.aspx");
        }
    }
    public void set_newproduct()
    {
        category cat     = new category();
        brand    brnd    = new brand();
        string   picname = null;

        new_product.InnerHtml = "";
        products  p  = new products();
        DataTable dt = new DataTable();

        dt = p.getproduct_new();
        int i = 0;

        foreach (DataRow dr in dt.Rows)
        {
            DataTable          pname    = p.getonepic(Convert.ToInt32(dr["id"]));
            HtmlGenericControl divspan3 = new HtmlGenericControl("div");
            divspan3.Attributes.Add("class", "span3");

            if (pname.Rows.Count != 0)
            {
                picname = "images/Ppic/" + pname.Rows[0]["name"].ToString() + ".jpg";
            }
            else
            {
                picname = "images/Ppic/noimage.jpg";
            }

            string catname   = cat.getcategory(dr["cat_id"].ToString()).Rows[0]["name"].ToString();
            string brandname = brnd.getbrandbyid(dr["brand_id"].ToString()).Rows[0]["name"].ToString();

            HtmlGenericControl divproduct = new HtmlGenericControl("div");
            divproduct.Attributes.Add("class", "product");

            HtmlGenericControl divproductimg = new HtmlGenericControl("div");
            divproductimg.Attributes.Add("class", "product-img");

            HtmlGenericControl divpicture = new HtmlGenericControl("div");
            divpicture.Attributes.Add("class", "picture");

            HtmlGenericControl imgpicture = new HtmlGenericControl("img");
            imgpicture.Attributes.Add("id", "p-img-new" + dr["id"].ToString());
            imgpicture.Attributes.Add("width", "540");
            imgpicture.Attributes.Add("height", "374");
            imgpicture.Attributes.Add("alt", "");
            imgpicture.Attributes.Add("src", picname);
            divpicture.Controls.Add(imgpicture);

            HtmlGenericControl divimgoverlay = new HtmlGenericControl("div");
            divimgoverlay.Attributes.Add("class", "img-overlay");


            HtmlGenericControl aimgoverlay = new HtmlGenericControl("a");
            aimgoverlay.Attributes.Add("href", "product.aspx?id=" + dr["id"].ToString());
            aimgoverlay.Attributes.Add("class", "btn more btn-primary");
            aimgoverlay.InnerText = "توضیحات بیشتر";
            divimgoverlay.Controls.Add(aimgoverlay);



            HtmlAnchor aimgoverlay2 = new HtmlAnchor();
            aimgoverlay2.ID           = "addtocart" + dr["id"].ToString();
            aimgoverlay2.HRef         = "#";
            aimgoverlay2.Name         = dr["id"].ToString() + "," + dr["price"].ToString() + "," + picname + "," + catname + " - " + brandname + " - " + dr["name"].ToString();
            aimgoverlay2.ServerClick += new System.EventHandler(Addcart_Click);
            aimgoverlay2.Attributes.Add("class", "btn buy btn-danger");
            aimgoverlay2.Attributes.Add("onclick", "addtocart('" + "p-img-new" + dr["id"].ToString() + "');");
            aimgoverlay2.InnerText = "اضافه به سبد خرید";

            UpdatePanel up = new UpdatePanel();
            up.ContentTemplateContainer.Controls.Add(aimgoverlay2);
            divimgoverlay.Controls.Add(up);
            divimgoverlay.Controls.Add(aimgoverlay);
            divpicture.Controls.Add(divimgoverlay);
            divproductimg.Controls.Add(divpicture);
            divproduct.Controls.Add(divproductimg);

            HtmlGenericControl divmaintitle = new HtmlGenericControl("div");
            divmaintitle.Attributes.Add("class", "main-titles no-margin");


            HtmlGenericControl h4maintitle = new HtmlGenericControl("h4");
            h4maintitle.Attributes.Add("class", "title");
            h4maintitle.InnerText = catname + " - " + brandname + " - " + dr["name"].ToString();
            divmaintitle.Controls.Add(h4maintitle);

            HtmlGenericControl h5maintitle = new HtmlGenericControl("h5");
            h5maintitle.Attributes.Add("class", "no-margin");
            h5maintitle.InnerText = String.Format("{0:#,##0}", dr["price"]) + " ریال"; //int.Parse(dr["price"].ToString()).ToString("N1",CultureInfo.InvariantCulture);
            divmaintitle.Controls.Add(h5maintitle);
            divproduct.Controls.Add(divmaintitle);

            HtmlGenericControl pdesc = new HtmlGenericControl("p");
            pdesc.Attributes.Add("class", "desc");
            pdesc.InnerText = dr["detail"].ToString();
            divproduct.Controls.Add(pdesc);

            divspan3.Controls.Add(divproduct);

            new_product.Controls.Add(divspan3);
            if (i != 0 && i % 3 == 0)
            {
                HtmlGenericControl divclearfix = new HtmlGenericControl("div");
                divclearfix.Attributes.Add("class", "clearfix");
                new_product.Controls.Add(divclearfix);
            }
            i++;
        }
    }