コード例 #1
0
 private void btnBuscar_Click(object sender, EventArgs e)
 {
     try
     {
         derivado.AbrirConexion();
         string        cod      = txtCodigo.Text;
         string        cadena   = "select descripcion,precio from Articulos where codigo=" + cod;
         SqlCommand    comando  = new SqlCommand(cadena, derivado.Conexion);
         SqlDataReader registro = comando.ExecuteReader();
         if (registro.Read())
         {
             lblDescripcion.Text = registro["descripcion"].ToString();
             lblPrecio.Text      = registro["precio"].ToString();
         }
         else
         {
             MessageBox.Show("No existe un Articulo con el Codigo Ingresado", "Error:");
         }
     }
     catch (Exception d)
     {
         MessageBox.Show(d.Message);
     }
     derivado.CerrarConexion();
 }
コード例 #2
0
        private void btnConsultas_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Aqui Puedes Consultar Todos los Registros.", "Mensage:");
            if (ObjC.Conexion.State != ConnectionState.Closed)
            {
                ObjC.CerrarConexion();
            }
            Mostrar forma = new Mostrar(ObjC);

            forma.ShowDialog();
        }
コード例 #3
0
 private void btnAgregar_Click(object sender, EventArgs e)
 {
     try
     {
         ObjC.AbrirConexion();
         string     descripcion = txtDesArt.Text;
         string     precio      = txtPrecio.Text;
         string     cadena      = "insert into Articulos (descripcion,precio) values('" + descripcion + "'," + precio + ")";
         SqlCommand comando     = new SqlCommand(cadena, ObjC.Conexion);
         comando.ExecuteNonQuery();
         MessageBox.Show("Los Datos se Guardaron Corrrectamente.", "Mensage:");
         txtDesArt.Text = "";
         txtPrecio.Text = "";
     }
     catch (Exception d)
     {
         MessageBox.Show(d.Message);
     }
     if (ObjC.Conexion.State == ConnectionState.Open)
     {
         ObjC.CerrarConexion();
     }
 }