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(); } } }
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; } }
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(); }
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; } }
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(); }
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>" }); } } }
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); } }