Ejemplo n.º 1
0
        //metodo insertar
        public string Insertar(DTaller Taller)
        {//inicio insertar
            string        rpta   = "";
            SqlConnection SqlCon = new SqlConnection();

            try
            {
                //conexion
                SqlCon.ConnectionString = Conexion.Cn;
                SqlCon.Open();
                //establecer el comando
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "spinsertar_taller";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                //parametros
                SqlParameter ParId_Taller = new SqlParameter();
                ParId_Taller.ParameterName = "@id_taller";
                ParId_Taller.SqlDbType     = SqlDbType.Int;
                ParId_Taller.Direction     = ParameterDirection.Output;
                SqlCmd.Parameters.Add(ParId_Taller);

                SqlParameter ParDenominacion = new SqlParameter();
                ParDenominacion.ParameterName = "@denominacion";
                ParDenominacion.SqlDbType     = SqlDbType.VarChar;
                ParDenominacion.Size          = 50;
                ParDenominacion.Value         = Taller.Denominacion;
                SqlCmd.Parameters.Add(ParDenominacion);


                //ejecutar el codigo
                rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "EL REGISTRO NO HA SIDO AGREGADO";
            }
            catch (Exception ex)
            {
                rpta = ex.Message + ex.StackTrace;
            }
            finally
            {
                if (SqlCon.State == ConnectionState.Open)
                {
                    SqlCon.Close();
                }
            }
            return(rpta);
        }//fin insertar
Ejemplo n.º 2
0
        }//fin editar

        //metodo eliminar
        public string Eliminar(DTaller Taller)
        {//inicio eliminar
            string        rpta   = "";
            SqlConnection SqlCon = new SqlConnection();

            try
            {
                //conexion
                SqlCon.ConnectionString = Conexion.Cn;
                SqlCon.Open();
                //establecer el comando
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "speliminar_taller";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                //parametros
                SqlParameter ParId_Taller = new SqlParameter();
                ParId_Taller.ParameterName = "@id_taller";
                ParId_Taller.SqlDbType     = SqlDbType.Int;
                ParId_Taller.Value         = Taller.Id_taller;
                SqlCmd.Parameters.Add(ParId_Taller);

                rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "NO SE HA ELIMINADO EL REGISTRO";
            }
            catch (Exception ex)
            {
                rpta = ex.Message + ex.StackTrace;
            }
            finally
            {
                if (SqlCon.State == ConnectionState.Open)
                {
                    SqlCon.Close();
                }
            }
            return(rpta);
        }//fin eliminar