Example #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     contenedores = new StaticContenedorDAL();
     if (!IsPostBack)
     {
         double numero = contenedores.GetContenedorInteligentes().ElementAt <ContenedorInteligente>(0).CapacidadTotal;
         this.gvContenedores.DataSource = contenedores.GetContenedorInteligentes();
         this.gvContenedores.DataBind();
         String.Format("{0:0.00}", numero);
         lblPrueba.Text = Convert.ToString(numero);
     }
 }
        protected void registrarContenedorBtn_Click(object sender, EventArgs e)
        {
            if (this.IsValid)
            {
                string numeroSerie    = this.numeroSerieTxt.Text.Trim().ToUpper();
                string region         = this.regionDdl.SelectedValue.ToString();
                int    idSedeSelected = Int32.Parse(sedeDdl.SelectedItem.Value);
                Sede   sedeSelected   = sedes.Find(s => s.Id == idSedeSelected); // Predicado que busca el objeto con el id obtenido en el dropdown

                Contenedor contenedor = new Contenedor()
                {
                    NumeroDeSerie = numeroSerie,
                    Region        = region,
                    Sede          = sedeSelected
                };

                IContenedor dal = new ContenedorDAL();

                dal.Add(contenedor);

                Response.Redirect("DetalleContenedores.aspx");
            }
        }