protected void Page_Load(object sender, EventArgs e) { if (Session["voucher"] == null) { Response.Redirect("~/Default.aspx"); return; } PremioNegocio premio = new PremioNegocio(); List <PremioNegocio> listpremios = new List <PremioNegocio>(); listpremios = premio.GetPremios(); List <ImageButton> aImageButton = new List <ImageButton>(); Panel1.Visible = true; int i = 0; foreach (var foo in listpremios) { aImageButton.Add(new ImageButton()); aImageButton[i].ID = "ImageButton" + (i + 1); aImageButton[i].Width = 300; aImageButton[i].Height = 300; aImageButton[i].BorderWidth = 5; aImageButton[i].BorderColor = DefaultColor; aImageButton[i].Click += new ImageClickEventHandler(imageButton_Click); aImageButton[i].ToolTip = foo.Descripcion; aImageButton[i].CommandArgument = foo.IdPremio.ToString(); aImageButton[i].ImageUrl = foo.URL; aImageButton[i].AlternateText = foo.Descripcion; aImageButton[i].Visible = true; Panel1.Controls.Add(aImageButton[i]); // Coloca cada par de imagenes una al lado de la otra y mete un salto de linea para las siguientes if ((i + 1) % 2 == 0) { Panel1.Controls.Add(new LiteralControl("<br />")); } else { Panel1.Controls.Add(new LiteralControl("<span> </span>")); } i++; } auxList = new List <ImageButton>(aImageButton); }
public static List <Premio> listaPremios() { return(PremioNegocio.lista()); }
public static string CompletaParticipante(string nombre, string apellido, string email, string ciudad, string direccion, string CP, string DNI) { var fromAddress = new MailAddress("*****@*****.**", "TPWEB"); var toAddress = new MailAddress(email, nombre + " " + apellido); const string fromPassword = "******"; const string subject = "Sorteo !"; const string body = "Has completado todo y ganado el premio. Pronto te lo llevaran a tu domicilio"; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromAddress.Address, fromPassword) }; Participante nuevo = new Participante(); nuevo.nombre = nombre; nuevo.apellido = apellido; nuevo.email = email; nuevo.ciudad = ciudad; nuevo.direccion = direccion; nuevo.CP = CP; nuevo.DNI = DNI; if (Datos.validacion(nuevo).Count != 0) { string error = "No se puede realizar la operacion porque se encontaron error en los siguiente campos: "; foreach (var item in Datos.validacion(nuevo)) { error += " " + item + ","; } error = error.Remove(error.Length - 1); return("{ \"Error\" :1 ,\"descripcion\": \"" + error + "\"}"); } if (!(bool)HttpContext.Current.Session["EsCliente"]) { if (!PersonaNegocio.InsertarPersona(nuevo)) { return("{ \"Error\" :1 ,\"descripcion\": \"No se pudo cuardar los datos reinten de nuevo\"}"); } } if (VoucherNegocio.CambiarEstado(HttpContext.Current.Session["voucher"].ToString())) { if (PremioNegocio.asignar(nuevo.DNI, HttpContext.Current.Session["voucher"].ToString(), HttpContext.Current.Session["idPremio"].ToString())) { HttpContext.Current.Session["voucher"] = null; HttpContext.Current.Session["idPremio"] = null; HttpContext.Current.Session["gano"] = true; using (var message = new MailMessage(fromAddress, toAddress) { Subject = subject, Body = body }) { smtp.Send(message); } return("{ \"Error\" :0 }"); } else { return("{ \"Error\" :1,\"descripcion\": \"No se puedo enviar el correo\"}"); } } else { return("{ \"Error\" :1 ,\"descripcion\": \"Error en uso de voucher intente nuevamente\"}"); } }