Ejemplo n.º 1
0
        public TB_CA_Lote Ind(int Codigo)
        {
            TB_CA_Lote oLote = new TB_CA_Lote();

            string cConsulta = "select idLote,   FchFabLote,  CantLote, Nombre , ProductoId ";
            cConsulta += "from dbo.TB_CA_Lote lot inner join dbo.TB_AL_Productos prod on lot.Codigo_Producto = prod.ProductoId ";
            cConsulta += "where idLote = " +Codigo.ToString();
            using (SqlConnection connection = new SqlConnection(connectionString))
            using (SqlCommand command = new SqlCommand(cConsulta, connection))
            {
                connection.Open();

                using (SqlDataReader reader = command.ExecuteReader())
                {
                    // Call Read before accessing data.
                    while (reader.Read())
                    {
                        oLote = new TB_CA_Lote()
                        {
                            idLote = int.Parse(reader[0].ToString()),
                            FchFabLote = DateTime.Parse(reader[1].ToString()),
                            CantLote = int.Parse(reader[2].ToString()),
                            Codigo_Producto = int.Parse(reader[4].ToString()),

                            oProducto = new TB_AL_Productos() {
                                Nombre = reader[3].ToString()
                            }
                        };
                    }
                }
            }

            return oLote;
        }
        protected void cboLote_SelectedIndexChanged(object sender, EventArgs e)
        {
            int nCodigoLote = 0;
            try
            {
                nCodigoLote = int.Parse(cboLote.SelectedValue.ToString());
            }
            catch {
            }
            TB_CA_Lote oLote = new TB_CA_Lote();
            oLote=oServicioLote.Ind(nCodigoLote);

            if (oLote != null)
            {
                if (oLote.idLote != 0)
                {

                    lblCodigoProducto.Text = oLote.Codigo_Producto.ToString();
                    lblProducto.Text = oLote.oProducto.Nombre;
                    lblFechaElaboracion.Text = oLote.FchFabLote.ToShortDateString();
                    lblCantidad.Text = oLote.CantLote.ToString();
                    lblMuestra.Text = "?";

                    IList<TB_CA_IngenieriaProducto> oListaIngenieria = new List<TB_CA_IngenieriaProducto>();
                    oListaIngenieria=oServicioIngenieria.ListarPorArticulo(oLote.Codigo_Producto);
                    gvwPrueba.DataSource = oListaIngenieria;
                    gvwPrueba.DataBind();

                }
                else {
                     lblCodigoProducto.Text = "0";
                    lblProducto.Text ="";
                    lblFechaElaboracion.Text = "";
                    lblCantidad.Text = "0";
                    lblMuestra.Text = "?";
                }
            }
            else
            {
                lblCodigoProducto.Text = "0";
                lblProducto.Text = "";
                lblFechaElaboracion.Text = "";
                lblCantidad.Text = "0";
                lblMuestra.Text = "?";
            }
        }