Ejemplo n.º 1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (ListBox1.SelectedIndex > -1)
        {
            Adm.TovarModule.ListTovar lr = Adm.Tools.Xmlwr.ReadFromFile <Adm.TovarModule.ListTovar>(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName));
            Adm.TovarModule.Tovar     r  = lr.FindByID(int.Parse(ListBox1.SelectedValue));
            Adm.FotoModule.List_Foto  lf = Adm.Tools.Xmlwr.ReadFromFile <Adm.FotoModule.List_Foto>(Server.MapPath(Adm.FotoModule.DataInfo.Foto_FileName));

            if (FileUpload1.HasFile)
            {
                int c = Adm.Tools.Counters.GetValue(Adm.FotoModule.DataInfo.Foto_ID_Counter, Server);
                c++;
                Adm.Tools.Counters.SetValue(Adm.FotoModule.DataInfo.Foto_ID_Counter, c, Server);

                FileUpload1.SaveAs(Server.MapPath("~/foto/temp/" + c + ".jpg"));

                Adm.Tools.ImageTool.SaveImage(Server.MapPath("~/foto/temp/" + c + ".jpg"), Server.MapPath("~/foto/" + c.ToString() + "s.jpg"), 160, 95);
                Adm.Tools.ImageTool.SaveImage(Server.MapPath("~/foto/temp/" + c + ".jpg"), Server.MapPath("~/foto/" + c.ToString() + "b.jpg"), 800, 95);
                r.Fotos.Add(c);
                Adm.FotoModule.Foto F = new Adm.FotoModule.Foto();
                F.ID = c;
                lf.Items.Add(F);
                Adm.Tools.Xmlwr.WriteToFile(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName), lr);
                Adm.Tools.Xmlwr.WriteToFile(Server.MapPath(Adm.FotoModule.DataInfo.Foto_FileName), lf);
                LoadFotos();
            }
        }
    }
Ejemplo n.º 2
0
 void lb_Click(object sender, EventArgs e)
 {
     if (ListBox1.SelectedIndex > -1)
     {
         Adm.TovarModule.ListTovar lr = Adm.Tools.Xmlwr.ReadFromFile <Adm.TovarModule.ListTovar>(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName));
         Adm.TovarModule.Tovar     r  = lr.FindByID(int.Parse(ListBox1.SelectedValue));
         Adm.FotoModule.List_Foto  lf = Adm.Tools.Xmlwr.ReadFromFile <Adm.FotoModule.List_Foto>(Server.MapPath(Adm.FotoModule.DataInfo.Foto_FileName));
         id = Convert.ToInt32(((LinkButton)sender).ID.Substring(3));
         Adm.FotoModule.Foto F = lf.FindByID(id);
         Panel1.Visible = true;
         TextBox1.Text  = F.Desk;
     }
 }
Ejemplo n.º 3
0
    protected void Save_foto_Click(object sender, EventArgs e)
    {
        Adm.TovarModule.ListTovar lr = Adm.Tools.Xmlwr.ReadFromFile <Adm.TovarModule.ListTovar>(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName));
        Adm.TovarModule.Tovar     r  = lr.FindByID(int.Parse(ListBox1.SelectedValue));
        Adm.FotoModule.List_Foto  lf = Adm.Tools.Xmlwr.ReadFromFile <Adm.FotoModule.List_Foto>(Server.MapPath(Adm.FotoModule.DataInfo.Foto_FileName));

        Panel1.Visible = false;

        Adm.FotoModule.Foto F = lf.FindByID(id);

        F.Desk = TextBox1.Text;

        Adm.Tools.Xmlwr.WriteToFile(Server.MapPath(Adm.FotoModule.DataInfo.Foto_FileName), lf);
        LoadFotos();
    }
Ejemplo n.º 4
0
    protected void Button_Remove_Click(object sender, EventArgs e)
    {
        if (ListBox1.SelectedIndex > -1)
        {
            Adm.TovarModule.ListTovar lr = Adm.Tools.Xmlwr.ReadFromFile <Adm.TovarModule.ListTovar>(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName));
            Adm.TovarModule.Tovar     r  = lr.FindByID(int.Parse(ListBox1.SelectedValue));

            lr.Items.Remove(r);
            ListBox1.Items.Remove(ListBox1.SelectedItem);
            Adm.Tools.Xmlwr.WriteToFile(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName), lr);

            Panel2.Visible = false;
            Image1.Visible = false;
        }
    }
Ejemplo n.º 5
0
    protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ListBox1.SelectedIndex > -1)
        {
            Adm.TovarModule.ListTovar lr = Adm.Tools.Xmlwr.ReadFromFile <Adm.TovarModule.ListTovar>(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName));
            Adm.TovarModule.Tovar     r  = lr.FindByID(int.Parse(ListBox1.SelectedValue));

            Panel1.Visible            = false;
            Tovar_Caption.Text        = r.Caption;
            TB_Price.Text             = r.Price;
            tbKol.Text                = r.Kol.ToString();
            tbText.Text               = r.Desc;
            DDL_Section.SelectedValue = r.Section.ToString();
            spaw1.Text                = r.Desc;
            Panel2.Visible            = true;
        }
    }
Ejemplo n.º 6
0
    protected void Topic_Save_Click(object sender, EventArgs e)
    {
        if (ListBox1.SelectedIndex > -1)
        {
            Adm.TovarModule.ListTovar lr = Adm.Tools.Xmlwr.ReadFromFile <Adm.TovarModule.ListTovar>(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName));
            Adm.TovarModule.Tovar     r  = lr.FindByID(int.Parse(ListBox1.SelectedValue));
            Adm.FotoModule.List_Foto  lf = Adm.Tools.Xmlwr.ReadFromFile <Adm.FotoModule.List_Foto>(Server.MapPath(Adm.FotoModule.DataInfo.Foto_FileName));

            r.Caption = Tovar_Caption.Text;
            r.Desc    = spaw1.Text;
            r.Text    = tbText.Text;

            if (tbKol.Text != r.Kol.ToString())
            {
                int raz = int.Parse(tbKol.Text) - r.Kol;
                int.TryParse(tbKol.Text, out r.Kol);
                r.Change.Add(new ListItem(DateTime.Now.ToShortDateString(), raz.ToString()));
            }
            int.TryParse(DDL_Section.SelectedValue, out r.Section);
            r.Price = TB_Price.Text;

            if (FileUpload2.HasFile)
            {
                int c = Adm.Tools.Counters.GetValue(Adm.FotoModule.DataInfo.Foto_ID_Counter, Server);
                c++;
                Adm.Tools.Counters.SetValue(Adm.FotoModule.DataInfo.Foto_ID_Counter, c, Server);
                FileUpload2.SaveAs(Server.MapPath("~/foto/temp/" + c + ".jpg"));
                Adm.Tools.ImageTool.SaveImage(Server.MapPath("~/foto/temp/" + c + ".jpg"), Server.MapPath("~/foto/" + c + "s.jpg"), 160, 95);
                Adm.Tools.ImageTool.SaveImage(Server.MapPath("~/foto/temp/" + c + ".jpg"), Server.MapPath("~/foto/" + c + "b.jpg"), 800, 95);
                Adm.FotoModule.Foto F = new Adm.FotoModule.Foto();
                F.ID   = c;
                F.Desk = r.Caption;
                lf.Items.Add(F);
                r.Picture = c;
            }

            Adm.Tools.Xmlwr.WriteToFile(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName), lr);
            Adm.Tools.Xmlwr.WriteToFile(Server.MapPath(Adm.FotoModule.DataInfo.Foto_FileName), lf);


            LoadFotos();
            ListBox1.Items[ListBox1.SelectedIndex].Text = r.Caption;
        }
    }
Ejemplo n.º 7
0
    protected void Btn_Remove_foto_Click(object sender, EventArgs e)
    {
        Adm.TovarModule.ListTovar lr = Adm.Tools.Xmlwr.ReadFromFile <Adm.TovarModule.ListTovar>(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName));
        Adm.TovarModule.Tovar     r  = lr.FindByID(int.Parse(ListBox1.SelectedValue));
        Adm.FotoModule.List_Foto  lf = Adm.Tools.Xmlwr.ReadFromFile <Adm.FotoModule.List_Foto>(Server.MapPath(Adm.FotoModule.DataInfo.Foto_FileName));

        r.Fotos.Remove(id);

        Adm.FotoModule.Foto F = lf.FindByID(id);

        lf.Items.Remove(F);

        System.IO.File.Delete(Server.MapPath("~/foto/" + id.ToString() + "b.jpg"));
        System.IO.File.Delete(Server.MapPath("~/foto/" + id.ToString() + "s.jpg"));


        Adm.Tools.Xmlwr.WriteToFile(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName), lr);
        Adm.Tools.Xmlwr.WriteToFile(Server.MapPath(Adm.FotoModule.DataInfo.Foto_FileName), lf);
        LoadFotos();
    }
Ejemplo n.º 8
0
    protected void Button_Add_Click(object sender, EventArgs e)
    {
        Adm.TovarModule.ListTovar lr = Adm.Tools.Xmlwr.ReadFromFile <Adm.TovarModule.ListTovar>(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName));

        int c = Adm.Tools.Counters.GetValue(Adm.TovarModule.DataInfo.Tovar_ID_Counter, Server);

        c++;
        Adm.Tools.Counters.SetValue(Adm.TovarModule.DataInfo.Tovar_ID_Counter, c, Server);

        Adm.TovarModule.Tovar r = new Adm.TovarModule.Tovar();
        r.Caption = "Новый товар";
        r.ID      = c;
        lr.Items.Add(r);
        ListItem it = new ListItem();

        it.Text  = r.Caption;
        it.Value = r.ID.ToString();
        ListBox1.Items.Add(it);
        Adm.Tools.Xmlwr.WriteToFile(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName), lr);
        Image1.Visible = false;
    }
Ejemplo n.º 9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Adm.SectionModule.Sections s  = Adm.Tools.Xmlwr.ReadFromFile <Adm.SectionModule.Sections>(Server.MapPath(Adm.SectionModule.DataInfo.Section_FileName));
        Adm.TovarModule.ListTovar  lr = Adm.Tools.Xmlwr.ReadFromFile <Adm.TovarModule.ListTovar>(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName));

        string s1 = "";

        phCat.Controls.Clear();

        for (int i = 0; i < s.Items.Count; i++)
        {
            s1 += "<p><a class='menu_items' href='catalog.aspx?id=" + s.Items[i].ID.ToString() + "'>" + s.Items[i].Caption + "</a></p>";
        }

        s1 += "<p><a class='menu_items' href='catalog.aspx'>Все разделы</a></p>";

        phCat.Controls.Add(new LiteralControl(s1));

        phRecent.Controls.Clear();

        s1 = "";
        DateTime dt = DateTime.Now.AddMonths(-10);

        Adm.TovarModule.Tovar t = new Adm.TovarModule.Tovar();

        for (int i = 0; i < lr.Items.Count; i++)
        {
            if (lr.Items[i].Date > dt)
            {
                dt = lr.Items[i].Date;
                t  = lr.Items[i];
            }
        }

        s1 += "<div class='item' style='float: none; margin: 10px auto;'><a href='tovar.aspx?id=" + t.ID.ToString() + "'><img src='foto/" + t.Picture + "s.jpg' /></a><div class='t'>" + t.Caption + "</div><div>" + t.Price + "</div></div>";

        phRecent.Controls.Add(new LiteralControl(s1));

        phNews.Controls.Clear();
        s1 = "";

        Adm.NewsModule.List_News ln = Adm.Tools.Xmlwr.ReadFromFile <Adm.NewsModule.List_News>(Server.MapPath(Adm.NewsModule.DataInfo.News_FileName));

        if (ln.Items.Count > 0)
        {
            ln.Items.Reverse();

            for (int i = 0; i < ln.Items.Count && i < 3; i++)
            {
                s1 += "<div class='RNews'>";
                s1 += "<div class='Date'>" + ln.Items[i].Date.Day + " " + ToMon(ln.Items[i].Date.Month) + " " + ln.Items[i].Date.Year + " г.</div>";
                s1 += "<a href=news.aspx?id=" + ln.Items[i].ID.ToString() + " class='News'>" + ln.Items[i].Title + "</a>";
                s1 += "</div>";
            }

            s1 += "<br /><a class='allnews' href='news.aspx'>Все новости</a>";

            phNews.Controls.Add(new LiteralControl {
                Text = s1
            });
        }
    }
Ejemplo n.º 10
0
    void LoadFotos()
    {
        if (ListBox1.SelectedIndex > -1)
        {
            Adm.TovarModule.ListTovar lr = Adm.Tools.Xmlwr.ReadFromFile <Adm.TovarModule.ListTovar>(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName));
            Adm.TovarModule.Tovar     r  = lr.FindByID(int.Parse(ListBox1.SelectedValue));
            Adm.FotoModule.List_Foto  lf = Adm.Tools.Xmlwr.ReadFromFile <Adm.FotoModule.List_Foto>(Server.MapPath(Adm.FotoModule.DataInfo.Foto_FileName));

            PlaceHolder1.Controls.Clear();

            if (System.IO.File.Exists(Server.MapPath("~/foto/") + r.Picture + "s.jpg"))
            {
                Image1.Visible  = true;
                Image1.ImageUrl = "~/foto/" + r.Picture + "s.jpg";
            }
            else
            {
                Image1.Visible = false;
            }

            if (r.Fotos.Count > 0)
            {
                PlaceHolder1.Controls.Add(new Literal {
                    Text = "<div id=\"carousel\"><a class=\"buttons prev\" href=\"#\"><<<</a><div class=\"viewport\">"
                });
                PlaceHolder1.Controls.Add(new Literal {
                    Text = "<ul class=\"overview\">"
                });
                for (int i = 0; i < r.Fotos.Count; i++)
                {
                    Adm.FotoModule.Foto F = lf.FindByID(r.Fotos[i]);

                    PlaceHolder1.Controls.Add(new Literal {
                        Text = "<li>"
                    });
                    LinkButton lb = new LinkButton();
                    lb.ID = "im_" + r.Fotos[i];
                    lb.Controls.Add(new Literal {
                        Text = String.Format("<img src='../foto/{0}s.jpg' style=\"border-width:0px\" />", r.Fotos[i])
                    });
                    lb.Click += new EventHandler(lb_Click);
                    PlaceHolder1.Controls.Add(lb);
                    if (F.Desk == "")
                    {
                        PlaceHolder1.Controls.Add(new Literal {
                            Text = "</li>"
                        });
                    }
                    else
                    {
                        PlaceHolder1.Controls.Add(new Literal {
                            Text = "<br /><span>" + F.Desk + "</span></li>"
                        });
                    }
                }
                PlaceHolder1.Controls.Add(new Literal {
                    Text = "</ul></div><a class=\"buttons next\" href=\"#\">>>></a></div>"
                });
            }
        }
    }
Ejemplo n.º 11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["id"] != null && int.TryParse(Request.QueryString["id"], out id))
        {
            phContent.Controls.Clear();

            Adm.TovarModule.ListTovar lt = Adm.Tools.Xmlwr.ReadFromFile <Adm.TovarModule.ListTovar>(Server.MapPath(Adm.TovarModule.DataInfo.Tovar_FileName));
            Adm.FotoModule.List_Foto  lf = Adm.Tools.Xmlwr.ReadFromFile <Adm.FotoModule.List_Foto>(Server.MapPath(Adm.FotoModule.DataInfo.Foto_FileName));
            Adm.TovarModule.Tovar     it = lt.FindByID(id);

            LiteralControl Lit = new LiteralControl();

            if (it != null)
            {
                Lit.Text += "<h1>" + it.Caption + "</h1>";
                if (it.Picture > 0)
                {
                    Adm.FotoModule.Foto F = lf.FindByID(it.Picture);
                    if (F != null)
                    {
                        System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("~/foto/" + it.Picture + "s.jpg"));
                        int w = img.Width;
                        int h = img.Height;
                        if (img.Width > 200)
                        {
                            float m = (float)w / h;
                            w = 200;
                            h = Convert.ToInt32(w / m);
                        }
                        Lit.Text += "<a title='" + F.Desk + "' rel='lightbox[1]' href='foto/" + F.ID.ToString() + "b.jpg'><img style=\"width:" + w + "px; height:" + h + "px; float:left; margin: 0 20px 20px 0; border: solid 2px #d4d4d4\" src='foto/" + F.ID.ToString() + "s.jpg' /></a>";
                    }
                }

                Lit.Text += "<br /><b>Цена: </b>" + it.Price + "<br />";
                Lit.Text += "<br />" + it.Text;

                Lit.Text += "<br clear='left' /><br />" + it.Desc + "<br /><br />";

                if (it.Fotos.Count > 0)
                {
                    for (int i = 0; i < it.Fotos.Count; i++)
                    {
                        Adm.FotoModule.Foto F = lf.FindByID(it.Fotos[i]);
                        if (F != null)
                        {
                            System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("~/foto/" + it.Fotos[i] + "s.jpg"));
                            int w = img.Width;
                            int h = img.Height;
                            if (img.Width > 200)
                            {
                                float m = (float)w / h;
                                w = 200;
                                h = Convert.ToInt32(w / m);
                            }
                            Lit.Text += "<a title='" + F.Desk + "' rel='lightbox[" + id.ToString() + "]' href='foto/" + it.Fotos[i].ToString() + "b.jpg'><img style=\"border-width:0px; margin-right: 10px; width:" + w + "px; height:" + h + "px;\" src='foto/" + it.Fotos[i].ToString() + "s.jpg' /></a>";
                        }
                    }
                }
            }

            phContent.Controls.Add(Lit);
        }
    }