示例#1
0
        //Metodo para modificar contacto

        public void ModificarContacto(int xCodigoContacto, string xNombreContacto, string xDireccionContacto,
                                      int xTelefonoContacto, int xCelularContacto, string xEmailContacto, DateTime xFechaRegistro, int
                                      xCodigoProfesion, int xCodigoPais)
        {
            conexion      cnn = new conexion();
            SqlConnection cn  = new SqlConnection(cnn.LeerConexion());
            SqlCommand    cmd = new SqlCommand("sp_tbContactoModificar", cn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@CodigoContacto", xCodigoContacto);
            cmd.Parameters.AddWithValue("@NombreContacto", xNombreContacto);
            cmd.Parameters.AddWithValue("@DireccionContacto", xDireccionContacto);
            cmd.Parameters.AddWithValue("@TelefonoContacto", Convert.ToString(xTelefonoContacto));
            cmd.Parameters.AddWithValue("@CelularContacto", Convert.ToString(xCelularContacto));
            cmd.Parameters.AddWithValue("@EmailContacto", xEmailContacto);
            cmd.Parameters.AddWithValue("@FechaRegistro", xFechaRegistro);
            cmd.Parameters.AddWithValue("@CodigoProfesion", xCodigoProfesion);
            cmd.Parameters.AddWithValue("@CodigoPais", xCodigoPais);
            try
            {
                cn.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                cn.Dispose();
                cmd.Dispose();
            }
        }
示例#2
0
        //Creamos un metodo que nos permita listar los paises
        //desde el procedimiento almacenado de la sgte. manera
        public DataTable ListarPais()
        {
            //instancia de la clase Conexion
            conexion      cnn = new conexion();
            SqlConnection cn  = new SqlConnection(cnn.LeerConexion());
            //nombre del procedimiento almacenado
            SqlCommand cmd = new SqlCommand("sp_tbPaisListar", cn);

            cmd.CommandType = CommandType.StoredProcedure;
            try
            {
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable      tb = new DataTable();
                da.Fill(tb);
                return(tb);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                cn.Dispose();
                cmd.Dispose();
            }
        }
示例#3
0
        //Metodo para eliminar contacto
        public void EliminarContacto(int xCodigoContacto)
        {
            conexion      cnn = new conexion();
            SqlConnection cn  = new SqlConnection(cnn.LeerConexion());
            SqlCommand    cmd = new SqlCommand("sp_tbContactoEliminar", cn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@CodigoContacto", xCodigoContacto);
            try
            {
                cn.Open();
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                cn.Dispose();
                cmd.Dispose();
            }
        }
示例#4
0
        public DataTable ListarContacto()
        {
            conexion      cnn = new conexion();
            SqlConnection cn  = new SqlConnection(cnn.LeerConexion());
            SqlCommand    cmd = new SqlCommand("sp_tbContactoListar", cn);

            cmd.CommandType = CommandType.StoredProcedure;
            try
            {
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable      tb = new DataTable();
                da.Fill(tb);
                return(tb);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                cn.Dispose();
                cmd.Dispose();
            }
        }