Ejemplo n.º 1
0
 public ServiciosIngresoBD()
 {
     //inicializacion de variables
     conexion = new ConexionesBasicasAbrirCerrarBD();
     nombre   = guiServiciosIngreso.GetNombre();
     codigo   = guiServiciosIngreso.GetCodigo();
     precio   = guiServiciosIngreso.GetPrecio();
 }
Ejemplo n.º 2
0
        //Implementación de método de la interfaz

        /// <summary>
        /// método para agregar datos a servicios
        /// </summary>
        public bool Agregar()
        {
            busqueda = new ServiciosBusquedaBD();
            conexion = new ConexionesBasicasAbrirCerrarBD();
            Nombre   = guiServiciosIngreso.GetNombre();
            Codigo   = guiServiciosIngreso.GetCodigo();
            Precio   = guiServiciosIngreso.GetPrecio();
            try
            {
                if (VerificarInformacion())
                {
                    conexion.AbrirConexion();

                    cmd = new SqlCommand("insert into Multicentro.dbo.servicio (codigoservicio,nombre,precio)" +
                                         " values('" + int.Parse(Codigo) + "', '" + Nombre + "', '" + double.Parse(Precio) + "')", conexion.GetSqlConnection());
                    cmd.ExecuteNonQuery();
                    conexion.CerrarConexion();

                    busqueda.BuscarPorCodigo(guiServiciosIngreso.GetCodigo(), guiServiciosIngreso.GetDataView());
                    MessageBox.Show("Información agregada");
                    return(true);
                }
            }

            catch (FormatException ex)
            {
                MensajesStandard.MensajeFormatoIncorrectoDatos();
                return(false);
            }
            catch (SqlException ex)
            {
                MensajesStandard.MensajeErrorGeneralBaseDatos();
                return(false);
            }
            catch (Exception ex)
            {
                MensajesStandard.MensajeGeneralExcepcionGenerica(ex);
                return(false);
            }
            return(false);
        }